Revert "MultiAudioNode: Fix and polish output locking issues"
This reverts commit 19da5e15c3.
This commit is contained in:
@@ -173,7 +173,6 @@ MultiAudioNode::MultiAudioNode(BMediaAddOn* addon, const char* name,
|
||||
BBufferConsumer(B_MEDIA_RAW_AUDIO),
|
||||
BBufferProducer(B_MEDIA_RAW_AUDIO),
|
||||
BMediaEventLooper(),
|
||||
fRunOutput(false),
|
||||
fBufferLock("multi audio buffers"),
|
||||
fThread(-1),
|
||||
fDevice(device),
|
||||
@@ -1173,8 +1172,6 @@ MultiAudioNode::_HandleBuffer(const media_timed_event* event,
|
||||
fprintf(stderr," <- LATE BUFFER : %" B_PRIdBIGTIME "\n", lateness);
|
||||
buffer->Recycle();
|
||||
} else {
|
||||
BAutolock _(fBufferLock);
|
||||
|
||||
//WriteBuffer(buffer, *channel);
|
||||
// TODO: This seems like a very fragile mechanism to wait until
|
||||
// the previous buffer for this channel has been processed...
|
||||
@@ -1780,13 +1777,18 @@ MultiAudioNode::_OutputThread()
|
||||
|
||||
// init the performance time computation
|
||||
{
|
||||
fBufferLock.Lock();
|
||||
BAutolock locker(fBufferLock);
|
||||
fTimeComputer.Init(fOutputPreferredFormat.u.raw_audio.frame_rate,
|
||||
system_time());
|
||||
fBufferLock.Unlock();
|
||||
}
|
||||
|
||||
while (fRunOutput) {
|
||||
while (true) {
|
||||
// TODO: why this semaphore??
|
||||
if (acquire_sem_etc(fBufferFreeSem, 1, B_RELATIVE_TIMEOUT, 0)
|
||||
== B_BAD_SEM_ID) {
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
BAutolock locker(fBufferLock);
|
||||
// make sure the buffers don't change while we're playing with them
|
||||
|
||||
@@ -1834,6 +1836,9 @@ MultiAudioNode::_OutputThread()
|
||||
_WriteZeros(*input, input->fBufferCycle);
|
||||
//PRINT(("MultiAudioNode::Runthread WriteZeros\n"));
|
||||
}
|
||||
|
||||
// mark buffer free
|
||||
release_sem(fBufferFreeSem);
|
||||
} else {
|
||||
//PRINT(("playback_buffer_cycle non ok input : %i\n", i));
|
||||
}
|
||||
@@ -2043,14 +2048,21 @@ MultiAudioNode::_StartOutputThreadIfNeeded()
|
||||
if (fThread >= 0)
|
||||
return B_OK;
|
||||
|
||||
fRunOutput = true;
|
||||
// allocate buffer free semaphore
|
||||
fBufferFreeSem = create_sem(
|
||||
fDevice->BufferList().return_playback_buffers - 1,
|
||||
"multi_audio out buffer free");
|
||||
if (fBufferFreeSem < B_OK)
|
||||
return fBufferFreeSem;
|
||||
|
||||
PublishTime(-50, 0, 0);
|
||||
|
||||
fThread = spawn_thread(_OutputThreadEntry, "multi_audio audio output",
|
||||
B_REAL_TIME_PRIORITY, this);
|
||||
if (fThread < B_OK)
|
||||
if (fThread < B_OK) {
|
||||
delete_sem(fBufferFreeSem);
|
||||
return fThread;
|
||||
}
|
||||
|
||||
resume_thread(fThread);
|
||||
return B_OK;
|
||||
@@ -2061,8 +2073,7 @@ status_t
|
||||
MultiAudioNode::_StopOutputThread()
|
||||
{
|
||||
CALLED();
|
||||
|
||||
fRunOutput = false;
|
||||
delete_sem(fBufferFreeSem);
|
||||
|
||||
status_t exitValue;
|
||||
wait_for_thread(fThread, &exitValue);
|
||||
|
||||
@@ -208,7 +208,6 @@ private:
|
||||
|
||||
private:
|
||||
status_t fInitStatus;
|
||||
bool fRunOutput;
|
||||
|
||||
BMediaAddOn* fAddOn;
|
||||
int32 fId;
|
||||
@@ -228,6 +227,7 @@ private:
|
||||
// not the defaults that are in the parameters
|
||||
bigtime_t fBufferPeriod;
|
||||
|
||||
sem_id fBufferFreeSem;
|
||||
thread_id fThread;
|
||||
MultiAudioDevice* fDevice;
|
||||
bool fTimeSourceStarted;
|
||||
|
||||
Reference in New Issue
Block a user