mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-04 13:29:59 -05:00
pacat: always fully fulfill write requests
Make sure we always fulfill write requests from the server. If we don't the server won't ask us again and playback will stay stuck. https://tango.0pointer.de/pipermail/pulseaudio-discuss/2010-February/006611.html
This commit is contained in:
parent
b9bcc7c733
commit
d57ba82414
1 changed files with 34 additions and 21 deletions
|
|
@ -195,7 +195,10 @@ static void stream_write_callback(pa_stream *s, size_t length, void *userdata) {
|
||||||
|
|
||||||
pa_assert(sndfile);
|
pa_assert(sndfile);
|
||||||
|
|
||||||
if (pa_stream_begin_write(s, &data, &length) < 0) {
|
for (;;) {
|
||||||
|
size_t data_length = length;
|
||||||
|
|
||||||
|
if (pa_stream_begin_write(s, &data, &data_length) < 0) {
|
||||||
pa_log(_("pa_stream_begin_write() failed: %s"), pa_strerror(pa_context_errno(context)));
|
pa_log(_("pa_stream_begin_write() failed: %s"), pa_strerror(pa_context_errno(context)));
|
||||||
quit(1);
|
quit(1);
|
||||||
return;
|
return;
|
||||||
|
|
@ -204,19 +207,29 @@ static void stream_write_callback(pa_stream *s, size_t length, void *userdata) {
|
||||||
if (readf_function) {
|
if (readf_function) {
|
||||||
size_t k = pa_frame_size(&sample_spec);
|
size_t k = pa_frame_size(&sample_spec);
|
||||||
|
|
||||||
if ((bytes = readf_function(sndfile, data, (sf_count_t) (length/k))) > 0)
|
if ((bytes = readf_function(sndfile, data, (sf_count_t) (data_length/k))) > 0)
|
||||||
bytes *= (sf_count_t) k;
|
bytes *= (sf_count_t) k;
|
||||||
|
|
||||||
} else
|
} else
|
||||||
bytes = sf_read_raw(sndfile, data, (sf_count_t) length);
|
bytes = sf_read_raw(sndfile, data, (sf_count_t) data_length);
|
||||||
|
|
||||||
if (bytes > 0)
|
if (bytes > 0)
|
||||||
pa_stream_write(s, data, (size_t) bytes, NULL, 0, PA_SEEK_RELATIVE);
|
pa_stream_write(s, data, (size_t) bytes, NULL, 0, PA_SEEK_RELATIVE);
|
||||||
else
|
else
|
||||||
pa_stream_cancel_write(s);
|
pa_stream_cancel_write(s);
|
||||||
|
|
||||||
if (bytes < (sf_count_t) length)
|
/* EOF? */
|
||||||
|
if (bytes < (sf_count_t) data_length) {
|
||||||
start_drain();
|
start_drain();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Request fulfilled */
|
||||||
|
if ((size_t) bytes >= length)
|
||||||
|
break;
|
||||||
|
|
||||||
|
length -= bytes;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue