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:
parent
78fea9cd2d
commit
9cf18a39cd
@ -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.
|
||||
|
@ -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;
|
||||
};
|
||||
|
||||
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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),
|
||||
|
Loading…
Reference in New Issue
Block a user