From 04c71a2f1d94d84fc447ff03fbebcdb97aade55e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Sat, 5 Dec 2009 10:46:49 +0000 Subject: [PATCH] * Removed code duplication, SetBufferGroup() will now use AllocateBuffers() instead of doing the same manually. * AllocateBuffers() is now returning a status code. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34499 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/media/SoundPlayNode.cpp | 18 ++++++++---------- src/kits/media/SoundPlayNode.h | 2 +- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/kits/media/SoundPlayNode.cpp b/src/kits/media/SoundPlayNode.cpp index c8421e5bc4..9e9799c365 100644 --- a/src/kits/media/SoundPlayNode.cpp +++ b/src/kits/media/SoundPlayNode.cpp @@ -273,20 +273,16 @@ SoundPlayNode::SetBufferGroup(const media_source& forSource, // group, otherwise we'll deadlock waiting for that buffer to be recycled! delete fBufferGroup; // waits for all buffers to recycle + if (newGroup != NULL) { // we were given a valid group; just use that one from now on fBufferGroup = newGroup; - } else { - // we were passed a NULL group pointer; that means we construct - // our own buffer group to use from now on - size_t size = fOutput.format.u.raw_audio.buffer_size; - int32 count = int32(fLatency / BufferDuration() + 1 + 1); - if (count < 3) - count = 3; - fBufferGroup = new BBufferGroup(size, count); + return B_OK; } - return B_OK; + // we were passed a NULL group pointer; that means we construct + // our own buffer group to use from now on + return AllocateBuffers(); } @@ -786,7 +782,7 @@ SoundPlayNode::HandleParameter(const media_timed_event* event, } -void +status_t SoundPlayNode::AllocateBuffers() { CALLED(); @@ -809,6 +805,8 @@ SoundPlayNode::AllocateBuffers() ERROR("SoundPlayNode::AllocateBuffers: BufferGroup::InitCheck() " "failed\n"); } + + return fBufferGroup->InitCheck(); } diff --git a/src/kits/media/SoundPlayNode.h b/src/kits/media/SoundPlayNode.h index b81eadbe1b..c6544029c7 100644 --- a/src/kits/media/SoundPlayNode.h +++ b/src/kits/media/SoundPlayNode.h @@ -128,7 +128,7 @@ protected: bigtime_t lateness, bool realTimeEvent = false); - void AllocateBuffers(); + status_t AllocateBuffers(); BBuffer* FillNextBuffer(bigtime_t eventTime); private: