MediaConnection: BufferSize should be inherited

* While it's trivial for audio to calculate the buffer size,
it isn't the same for video.
This commit is contained in:
Barrett17 2018-02-25 23:37:07 +01:00
parent 78fea9cd2d
commit 9cf18a39cd
4 changed files with 20 additions and 20 deletions

View File

@ -51,7 +51,7 @@ public:
// Represents the buffer size, depends on the format set or negotiated
// for this connection.
size_t BufferSize() const;
virtual size_t BufferSize() const = 0;
// Disconnect this connection. When a connection is disconnected,
// it can be reused as brand new.

View File

@ -114,6 +114,9 @@ public:
void* Cookie() const;
virtual size_t BufferSize() const;
virtual void SetBufferSize(size_t bufferSize);
protected:
BSimpleMediaConnection(
media_connection_kinds kinds);
@ -122,6 +125,8 @@ protected:
process_hook fProcessHook;
notify_hook fNotifyHook;
void* fBufferCookie;
size_t fBufferSize;
};

View File

@ -120,25 +120,6 @@ BMediaConnection::Release()
}
size_t
BMediaConnection::BufferSize() const
{
CALLED();
switch (fConnection.format.type) {
case B_MEDIA_RAW_AUDIO:
return fConnection.format.u.raw_audio.buffer_size;
case B_MEDIA_RAW_VIDEO:
return fConnection.format.u.raw_video.display.bytes_per_row *
fConnection.format.u.raw_video.display.line_count;
default:
return 0;
}
}
void
BMediaConnection::Connected(const media_format& format)
{

View File

@ -150,6 +150,20 @@ BSimpleMediaConnection::Cookie() const
}
size_t
BSimpleMediaConnection::BufferSize() const
{
return fBufferSize;
}
void
BSimpleMediaConnection::SetBufferSize(size_t bufferSize)
{
fBufferSize = bufferSize;
}
BSimpleMediaInput::BSimpleMediaInput()
:
BMediaConnection(B_MEDIA_INPUT),