audio_output: workaround for deadlock
During debugging, I found a deadlock between flushAudioBuffer() and the audio_output_task(): audio_output_task() didn't notice that there is a command, and flushAudioBuffer() waited forever in notify_wait(). I am not sure yet what is the real cause; work around this for now by waking up non-finished audio outputs in every iteration.
This commit is contained in:
parent
05f66e04a4
commit
e2a12deead
@ -281,7 +281,7 @@ static int flushAudioBuffer(void)
|
||||
int finished = 1;
|
||||
|
||||
for (i = 0; i < audioOutputArraySize; ++i) {
|
||||
const struct audio_output *ao = &audioOutputArray[i];
|
||||
struct audio_output *ao = &audioOutputArray[i];
|
||||
|
||||
if (!audio_output_is_open(ao))
|
||||
continue;
|
||||
@ -295,8 +295,10 @@ static int flushAudioBuffer(void)
|
||||
closed if the play func
|
||||
returned an error */
|
||||
audioDeviceStates[i] = DEVICE_ENABLE;
|
||||
} else
|
||||
} else {
|
||||
finished = 0;
|
||||
audio_output_signal(ao);
|
||||
}
|
||||
}
|
||||
|
||||
if (finished)
|
||||
|
@ -86,6 +86,12 @@ int audio_output_open(struct audio_output *audioOutput,
|
||||
return ret;
|
||||
}
|
||||
|
||||
void
|
||||
audio_output_signal(struct audio_output *ao)
|
||||
{
|
||||
notify_signal(&ao->notify);
|
||||
}
|
||||
|
||||
void audio_output_play(struct audio_output *audioOutput,
|
||||
const char *playChunk, size_t size)
|
||||
{
|
||||
|
@ -30,6 +30,15 @@ struct tag;
|
||||
int audio_output_init(struct audio_output *, ConfigParam * param);
|
||||
int audio_output_open(struct audio_output *audioOutput,
|
||||
const struct audio_format *audioFormat);
|
||||
|
||||
/**
|
||||
* Wakes up the audio output thread. This is part of a workaround for
|
||||
* a deadlock bug, and should be removed as soon as the real cause is
|
||||
* fixed. XXX
|
||||
*/
|
||||
void
|
||||
audio_output_signal(struct audio_output *ao);
|
||||
|
||||
void audio_output_play(struct audio_output *audioOutput,
|
||||
const char *playChunk, size_t size);
|
||||
void audio_output_cancel(struct audio_output *audioOutput);
|
||||
|
Loading…
Reference in New Issue
Block a user