Handle PulseAudio case where no data can be written.

This commit is contained in:
Brandon Wright 2017-11-24 19:35:49 -06:00
parent 76e25cbb6f
commit e292045572
1 changed files with 15 additions and 1 deletions

View File

@ -268,9 +268,23 @@ S9xPulseSoundDriver::samples_available (void)
bytes = MIN (bytes, (samples << (Settings.SixteenBitSound ? 1 : 0))); bytes = MIN (bytes, (samples << (Settings.SixteenBitSound ? 1 : 0)));
if (!bytes)
return;
lock (); lock ();
pa_stream_begin_write (stream, &output_buffer, &bytes); if (pa_stream_begin_write (stream, &output_buffer, &bytes) != 0)
{
pa_stream_flush (stream, NULL, NULL);
unlock ();
return;
}
if (bytes <= 0 || !output_buffer)
{
unlock ();
return;
}
S9xMixSamples ((uint8 *) output_buffer, bytes >> (Settings.SixteenBitSound ? 1 : 0)); S9xMixSamples ((uint8 *) output_buffer, bytes >> (Settings.SixteenBitSound ? 1 : 0));
pa_stream_write (stream, output_buffer, bytes, NULL, 0, PA_SEEK_RELATIVE); pa_stream_write (stream, output_buffer, bytes, NULL, 0, PA_SEEK_RELATIVE);