properly reflect xrun state back to the application. Required to make xmms

work with the pulse plugin for alsa
This commit is contained in:
Lennart Poettering 2007-10-01 19:44:48 +00:00
parent 2eafd7786a
commit ad57e02a15
2 changed files with 89 additions and 1 deletions

82
1.0.14-state-xrun.patch Normal file
View File

@ -0,0 +1,82 @@
--- alsa-plugins-1.0.14.lennart/pulse/pcm_pulse.c 2007-09-24 01:43:01.000000000 +0200
+++ alsa-plugins-1.0.14/pulse/pcm_pulse.c 2007-10-01 21:36:53.000000000 +0200
@@ -36,6 +36,7 @@
/* Since ALSA expects a ring buffer we must do some voodoo. */
size_t last_size;
size_t ptr;
+ int underrun;
size_t offset;
@@ -90,7 +91,9 @@
if (err < 0) {
err = -EIO;
goto finish;
- }
+ } else
+ pcm->underrun = 0;
+
finish:
pa_threaded_mainloop_unlock(pcm->p->mainloop);
@@ -200,6 +203,9 @@
err = snd_pcm_bytes_to_frames(io->pcm, pcm->ptr);
+ if (pcm->underrun)
+ err = -EPIPE;
+
finish:
pa_threaded_mainloop_unlock(pcm->p->mainloop);
@@ -231,6 +237,10 @@
*delayp = snd_pcm_bytes_to_frames(io->pcm, pa_usec_to_bytes(lat, &pcm->ss));
+ /* Yes, this is evil, and we're not supposed to do this. */
+ if (pcm->underrun && pcm->io.state == SND_PCM_STATE_RUNNING)
+ pcm->io.state = SND_PCM_STATE_XRUN;
+
finish:
pa_threaded_mainloop_unlock(pcm->p->mainloop);
@@ -273,6 +283,7 @@
pulse_poll_deactivate(pcm->p);
err = size;
+ pcm->underrun = 0;
finish:
pa_threaded_mainloop_unlock(pcm->p->mainloop);
@@ -354,6 +365,15 @@
pulse_poll_activate(pcm->p);
}
+static void stream_underrun_cb(pa_stream *p, void *userdata) {
+ snd_pcm_pulse_t *pcm = userdata;
+
+ assert(pcm);
+ assert(pcm->p);
+
+ pcm->underrun = 1;
+}
+
static int pulse_pcm_poll_descriptors_count(snd_pcm_ioplug_t *io)
{
snd_pcm_pulse_t *pcm = io->private_data;
@@ -461,6 +481,7 @@
if (io->stream == SND_PCM_STREAM_PLAYBACK) {
pa_stream_set_write_callback(pcm->stream, stream_request_cb, pcm);
+ pa_stream_set_underflow_callback(pcm->stream, stream_underrun_cb, pcm);
pa_stream_connect_playback(pcm->stream, pcm->device, &pcm->buffer_attr,
PA_STREAM_AUTO_TIMING_UPDATE | PA_STREAM_INTERPOLATE_TIMING, NULL, NULL);
} else {
@@ -480,6 +501,7 @@
pcm->last_size = 0;
pcm->ptr = 0;
pcm->offset = 0;
+ pcm->underrun = 0;
finish:
pa_threaded_mainloop_unlock(pcm->p->mainloop);

View File

@ -1,6 +1,6 @@
Name: alsa-plugins Name: alsa-plugins
Version: 1.0.14 Version: 1.0.14
Release: 3%{?dist} Release: 4%{?dist}
Summary: The Advanced Linux Sound Architecture (ALSA) Plugins Summary: The Advanced Linux Sound Architecture (ALSA) Plugins
# All packages are LGPLv2+ with the exception of samplerate which is GPLv2+ # All packages are LGPLv2+ with the exception of samplerate which is GPLv2+
License: GPLv2+ and LGPLv2+ License: GPLv2+ and LGPLv2+
@ -14,6 +14,7 @@ Source4: samplerate.conf
Source5: upmix.conf Source5: upmix.conf
Source6: vdownmix.conf Source6: vdownmix.conf
Patch0: 1.0.14-buffer-attr.patch Patch0: 1.0.14-buffer-attr.patch
Patch1: 1.0.14-state-xrun.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: alsa-lib-devel BuildRequires: alsa-lib-devel
@ -95,6 +96,7 @@ surround".
%prep %prep
%setup -q -n %{name}-%{version} %setup -q -n %{name}-%{version}
%patch0 -p1 -b .buffer_attr %patch0 -p1 -b .buffer_attr
%patch1 -p1 -b .state_xrun
%build %build
%configure --disable-static \ %configure --disable-static \
@ -162,6 +164,10 @@ rm -rf $RPM_BUILD_ROOT
%{_libdir}/alsa-lib/libasound_module_pcm_vdownmix.so %{_libdir}/alsa-lib/libasound_module_pcm_vdownmix.so
%changelog %changelog
* Mon Oct 1 2007 Lennart Poettering <lpoetter@redhat.com> - 1.0.14-4
- In the pulse plugin: reflect the XRUN state back to the application.
Makes XMMS work on top of the alsa plugin. (#307341)
* Mon Sep 24 2007 Lennart Poettering <lpoetter@redhat.com> - 1.0.14-3 * Mon Sep 24 2007 Lennart Poettering <lpoetter@redhat.com> - 1.0.14-3
- Change PulseAudio buffering defaults to more sane values - Change PulseAudio buffering defaults to more sane values