Skip to content

Commit

Permalink
Apply clang-format changes
Browse files Browse the repository at this point in the history
  • Loading branch information
korli committed Apr 5, 2024
1 parent a782577 commit 7b95cde
Show file tree
Hide file tree
Showing 30 changed files with 897 additions and 1,137 deletions.
137 changes: 62 additions & 75 deletions source/AdapterIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,17 @@

class RelativePositionIO : public BPositionIO {
public:
RelativePositionIO(BAdapterIO* owner, BPositionIO* buffer,
bigtime_t timeout)
:
BPositionIO(),
fOwner(owner),
fBackPosition(0),
fStartOffset(0),
fBuffer(buffer),
fTimeout(timeout)
RelativePositionIO(BAdapterIO* owner, BPositionIO* buffer, bigtime_t timeout)
: BPositionIO(),
fOwner(owner),
fBackPosition(0),
fStartOffset(0),
fBuffer(buffer),
fTimeout(timeout)
{
}

virtual ~RelativePositionIO()
{
delete fBuffer;
}
virtual ~RelativePositionIO() { delete fBuffer; }

status_t ResetStartOffset(off_t offset)
{
Expand Down Expand Up @@ -105,26 +100,21 @@ class RelativePositionIO : public BPositionIO {
return B_OK;
}

virtual ssize_t ReadAt(off_t position, void* buffer,
size_t size)
virtual ssize_t ReadAt(off_t position, void* buffer, size_t size)
{
AutoReadLocker _(fLock);

return fBuffer->ReadAt(
_PositionToRelative(position), buffer, size);

return fBuffer->ReadAt(_PositionToRelative(position), buffer, size);
}

virtual ssize_t WriteAt(off_t position,
const void* buffer, size_t size)
virtual ssize_t WriteAt(off_t position, const void* buffer, size_t size)
{
AutoWriteLocker _(fLock);

return fBuffer->WriteAt(
_PositionToRelative(position), buffer, size);
return fBuffer->WriteAt(_PositionToRelative(position), buffer, size);
}

virtual off_t Seek(off_t position, uint32 seekMode)
virtual off_t Seek(off_t position, uint32 seekMode)
{
AutoWriteLocker _(fLock);

Expand All @@ -140,14 +130,14 @@ class RelativePositionIO : public BPositionIO {
return _RelativeToPosition(fBuffer->Position());
}

virtual status_t SetSize(off_t size)
virtual status_t SetSize(off_t size)
{
AutoWriteLocker _(fLock);

return fBuffer->SetSize(_PositionToRelative(size));
}

virtual status_t GetSize(off_t* size) const
virtual status_t GetSize(off_t* size) const
{
AutoReadLocker _(fLock);

Expand Down Expand Up @@ -194,51 +184,35 @@ class RelativePositionIO : public BPositionIO {
return ((flags & B_MEDIA_SEEKABLE) == B_MEDIA_SEEKABLE);
}

const BPositionIO* Buffer() const
{
return fBuffer;
}
const BPositionIO* Buffer() const { return fBuffer; }

private:
off_t _PositionToRelative(off_t position) const { return position - fStartOffset; }

off_t _PositionToRelative(off_t position) const
{
return position - fStartOffset;
}
off_t _RelativeToPosition(off_t position) const { return position + fStartOffset; }

off_t _RelativeToPosition(off_t position) const
{
return position + fStartOffset;
}
BAdapterIO* fOwner;
off_t fBackPosition;
off_t fStartOffset;

BAdapterIO* fOwner;
off_t fBackPosition;
off_t fStartOffset;
BPositionIO* fBuffer;

BPositionIO* fBuffer;
mutable RWLocker fLock;

mutable RWLocker fLock;

bigtime_t fTimeout;
bigtime_t fTimeout;
};


BAdapterIO::BAdapterIO(int32 flags, bigtime_t timeout)
:
fFlags(flags),
fBuffer(NULL),
fTotalSize(0),
fOpened(false),
fSeekSem(-1),
fInputAdapter(NULL)
: fFlags(flags), fBuffer(NULL), fTotalSize(0), fOpened(false), fSeekSem(-1), fInputAdapter(NULL)
{
CALLED();

fBuffer = new RelativePositionIO(this, new BMallocIO(), timeout);
}


BAdapterIO::BAdapterIO(const BAdapterIO &)
BAdapterIO::BAdapterIO(const BAdapterIO&)
{
// copying not allowed...
}
Expand Down Expand Up @@ -293,19 +267,17 @@ BAdapterIO::Seek(off_t position, uint32 seekMode)
off_t size = 0;

if (seekMode == SEEK_CUR)
absolutePosition = Position()+position;
absolutePosition = Position() + position;
else if (seekMode == SEEK_END) {
if (GetSize(&size) != B_OK)
return B_NOT_SUPPORTED;

absolutePosition = size-position;
absolutePosition = size - position;
}

status_t ret = _EvaluateWait(absolutePosition, 0);

if (ret == B_RESOURCE_UNAVAILABLE && fBuffer->IsStreaming()
&& fBuffer->IsSeekable()) {

if (ret == B_RESOURCE_UNAVAILABLE && fBuffer->IsStreaming() && fBuffer->IsSeekable()) {
fSeekSem = create_sem(0, "BAdapterIO seek sem");

if (SeekRequested(absolutePosition) != B_OK)
Expand Down Expand Up @@ -445,8 +417,8 @@ BAdapterIO::_EvaluateWait(off_t pos, off_t size)
if (GetSize(&totalSize) != B_OK)
TRACE("BAdapterIO::ReadAt: Can't get our size!\n");

TRACE("BAdapterIO::_EvaluateWait TS %" B_PRId64 " P %" B_PRId64
" S %" B_PRId64 "\n", totalSize, pos, size);
TRACE("BAdapterIO::_EvaluateWait TS %" B_PRId64 " P %" B_PRId64 " S %" B_PRId64 "\n", totalSize,
pos, size);

status_t err = fBuffer->EvaluatePosition(pos, totalSize);

Expand All @@ -461,16 +433,10 @@ BAdapterIO::_EvaluateWait(off_t pos, off_t size)
}


BInputAdapter::BInputAdapter(BAdapterIO* io)
:
fIO(io)
{
}
BInputAdapter::BInputAdapter(BAdapterIO* io) : fIO(io) {}


BInputAdapter::~BInputAdapter()
{
}
BInputAdapter::~BInputAdapter() {}


ssize_t
Expand All @@ -481,11 +447,32 @@ BInputAdapter::Write(const void* buffer, size_t size)


// FBC
void BAdapterIO::_ReservedAdapterIO1() {}
void BAdapterIO::_ReservedAdapterIO2() {}
void BAdapterIO::_ReservedAdapterIO3() {}
void BAdapterIO::_ReservedAdapterIO4() {}
void BAdapterIO::_ReservedAdapterIO5() {}

void BInputAdapter::_ReservedInputAdapter1() {}
void BInputAdapter::_ReservedInputAdapter2() {}
void
BAdapterIO::_ReservedAdapterIO1()
{
}
void
BAdapterIO::_ReservedAdapterIO2()
{
}
void
BAdapterIO::_ReservedAdapterIO3()
{
}
void
BAdapterIO::_ReservedAdapterIO4()
{
}
void
BAdapterIO::_ReservedAdapterIO5()
{
}

void
BInputAdapter::_ReservedInputAdapter1()
{
}
void
BInputAdapter::_ReservedInputAdapter2()
{
}
82 changes: 39 additions & 43 deletions source/AdapterIO.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,83 +18,79 @@ class RelativePositionIO;

class BInputAdapter {
public:
virtual ssize_t Write(const void* buffer, size_t size);
virtual ssize_t Write(const void* buffer, size_t size);

private:
friend class BAdapterIO;

BInputAdapter(BAdapterIO* io);
virtual ~BInputAdapter();
BInputAdapter(BAdapterIO* io);
virtual ~BInputAdapter();

BAdapterIO* fIO;
BAdapterIO* fIO;

virtual void _ReservedInputAdapter1();
virtual void _ReservedInputAdapter2();
virtual void _ReservedInputAdapter1();
virtual void _ReservedInputAdapter2();

uint32 _reserved[2];
uint32 _reserved[2];
};


class BAdapterIO : public BMediaIO {
public:
BAdapterIO(
int32 flags,
bigtime_t timeout);
virtual ~BAdapterIO();
BAdapterIO(int32 flags, bigtime_t timeout);
virtual ~BAdapterIO();

virtual void GetFlags(int32* flags) const;
virtual void GetFlags(int32* flags) const;

virtual ssize_t ReadAt(off_t position, void* buffer,
size_t size);
virtual ssize_t WriteAt(off_t position,
const void* buffer, size_t size);
virtual ssize_t ReadAt(off_t position, void* buffer, size_t size);
virtual ssize_t WriteAt(off_t position, const void* buffer, size_t size);

virtual off_t Seek(off_t position, uint32 seekMode);
virtual off_t Position() const;
virtual off_t Seek(off_t position, uint32 seekMode);
virtual off_t Position() const;

virtual status_t SetSize(off_t size);
virtual status_t GetSize(off_t* size) const;
virtual status_t SetSize(off_t size);
virtual status_t GetSize(off_t* size) const;

virtual status_t Open();
virtual status_t Open();

virtual bool IsRunning() const;
virtual bool IsRunning() const;

void SeekCompleted();
status_t SetBuffer(BPositionIO* buffer);
void SeekCompleted();
status_t SetBuffer(BPositionIO* buffer);

status_t FlushRead();
status_t FlushRead();

BInputAdapter* BuildInputAdapter();
BInputAdapter* BuildInputAdapter();

protected:
friend class BInputAdapter;

virtual status_t SeekRequested(off_t position);
virtual status_t SeekRequested(off_t position);

ssize_t BackWrite(const void* buffer, size_t size);
ssize_t BackWrite(const void* buffer, size_t size);

private:
status_t _EvaluateWait(off_t pos, off_t size);
status_t _EvaluateWait(off_t pos, off_t size);

int32 fFlags;
int32 fFlags;

RelativePositionIO* fBuffer;
off_t fTotalSize;
bool fOpened;
sem_id fSeekSem;
RelativePositionIO* fBuffer;
off_t fTotalSize;
bool fOpened;
sem_id fSeekSem;

BInputAdapter* fInputAdapter;
BInputAdapter* fInputAdapter;

BAdapterIO(const BAdapterIO&);
BAdapterIO& operator=(const BAdapterIO&);
BAdapterIO(const BAdapterIO&);
BAdapterIO& operator=(const BAdapterIO&);

virtual void _ReservedAdapterIO1();
virtual void _ReservedAdapterIO2();
virtual void _ReservedAdapterIO3();
virtual void _ReservedAdapterIO4();
virtual void _ReservedAdapterIO5();
virtual void _ReservedAdapterIO1();
virtual void _ReservedAdapterIO2();
virtual void _ReservedAdapterIO3();
virtual void _ReservedAdapterIO4();
virtual void _ReservedAdapterIO5();

uint32 _reserved[5];
uint32 _reserved[5];
};

#endif // _ADAPTER_IO_H
17 changes: 8 additions & 9 deletions source/Debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,30 +31,29 @@
#undef DEBUG
#undef MSG

//#define TRACING
//#define DEBUGGING
//#define PROFILING
// #define TRACING
// #define DEBUGGING
// #define PROFILING

#ifdef DEBUGGING
#define DEBUG(x...) fprintf(stderr, __FILE__ " - " x)
#else
#define DEBUG(x...)
#endif // DEBUGGING
#endif // DEBUGGING
#ifdef TRACING
#define TRACE(x...) fprintf(stderr, __FILE__ " - " x)
#else
#define TRACE(x...)
#endif // TRACING
#endif // TRACING
#define MSG(x...) fprintf(stderr, __FILE__ " - " x)
#ifdef PROFILING
#define PROFILE_START bigtime_t timer = system_time()
#define PROFILE_MEASURE(action) \
TRACE("%s took %2.6f seconds\r\n", action, \
(system_time() - timer) / 1000000.0f)
TRACE("%s took %2.6f seconds\r\n", action, (system_time() - timer) / 1000000.0f)
#else
#define PROFILE_START
#define PROFILE_MEASURE(action)
#endif // PROFILING
#endif // PROFILING


#endif // _DEBUG_H
#endif // _DEBUG_H
Loading

0 comments on commit 7b95cde

Please sign in to comment.