* 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
This commit is contained in:
Axel Dörfler 2009-12-05 10:46:49 +00:00
parent ca8b3261b1
commit 04c71a2f1d
2 changed files with 9 additions and 11 deletions

View File

@ -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();
}

View File

@ -128,7 +128,7 @@ protected:
bigtime_t lateness,
bool realTimeEvent = false);
void AllocateBuffers();
status_t AllocateBuffers();
BBuffer* FillNextBuffer(bigtime_t eventTime);
private: