* [PATCH] alsa-plugins/pulse: Implement 'pause'.
@ 2009-06-17 20:55 Troy Moure
2009-06-17 21:37 ` Lennart Poettering
0 siblings, 1 reply; 4+ messages in thread
From: Troy Moure @ 2009-06-17 20:55 UTC (permalink / raw)
To: patch; +Cc: Takashi Iwai, alsa-devel, Lennart Poettering
Just cork or uncork the stream to pause or unpause it.
Signed-off-by: Troy Moure <twmoure@szypr.net>
---
I'm not very familiar with alsa or pulseaudio, so this might not be
right. If it is, feel free to apply it, though.
It *does* fix my problem, which was that pause and unpause didn't work in
'cmus' after I upgraded to Fedora 11. Since the pulse plug-in didn't
support snd_pcm_pause, pausing in cmus would just cause cmus to stop
writing to the buffer, leading to buffer underruns in pulseaudio. With
this patch, pausing in cmus works perfectly for me.
If this should be fixed another way, please let me know what it is!
Thanks.
pulse/pcm_pulse.c | 20 ++++++++++++++++++++
1 files changed, 20 insertions(+), 0 deletions(-)
diff --git a/pulse/pcm_pulse.c b/pulse/pcm_pulse.c
index db8d1e1..c322884 100644
--- a/pulse/pcm_pulse.c
+++ b/pulse/pcm_pulse.c
@@ -739,6 +739,25 @@ static int pulse_close(snd_pcm_ioplug_t * io)
return 0;
}
+static int pulse_pause(snd_pcm_ioplug_t * io, int enable)
+{
+ snd_pcm_pulse_t *pcm = io->private_data;
+ int err = 0;
+
+ assert (pcm);
+ assert (pcm->p);
+
+ pa_threaded_mainloop_lock(pcm->p->mainloop);
+
+ if (pcm->stream)
+ if (!pa_stream_cork(pcm->stream, enable, NULL, NULL))
+ err = -EIO;
+
+ pa_threaded_mainloop_unlock(pcm->p->mainloop);
+
+ return err;
+}
+
static const snd_pcm_ioplug_callback_t pulse_playback_callback = {
.start = pulse_start,
.stop = pulse_stop,
@@ -750,6 +769,7 @@ static const snd_pcm_ioplug_callback_t pulse_playback_callback = {
.prepare = pulse_prepare,
.hw_params = pulse_hw_params,
.close = pulse_close,
+ .pause = pulse_pause
};
--
1.6.2.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] alsa-plugins/pulse: Implement 'pause'.
2009-06-17 20:55 [PATCH] alsa-plugins/pulse: Implement 'pause' Troy Moure
@ 2009-06-17 21:37 ` Lennart Poettering
[not found] ` <alpine.LFD.2.00.0906181444420.6800@troy-laptop>
0 siblings, 1 reply; 4+ messages in thread
From: Lennart Poettering @ 2009-06-17 21:37 UTC (permalink / raw)
To: Troy Moure; +Cc: Takashi Iwai, alsa-devel, patch
On Wed, 17.06.09 21:55, Troy Moure (twmoure@szypr.net) wrote:
> Just cork or uncork the stream to pause or unpause it.
Looks mostly good to me, but:
> +static int pulse_pause(snd_pcm_ioplug_t * io, int enable)
> +{
> + snd_pcm_pulse_t *pcm = io->private_data;
> + int err = 0;
> +
> + assert (pcm);
> + assert (pcm->p);
> +
> + pa_threaded_mainloop_lock(pcm->p->mainloop);
> +
> + if (pcm->stream)
> + if (!pa_stream_cork(pcm->stream, enable, NULL, NULL))
> + err = -EIO;
pa_stream_cork() will return a pa_operation object on success. The
least you need to do is call pa_operation_unref() on it, which you can
safely do right-away. Otherwise this will leak memory.
Lennart
--
Lennart Poettering Red Hat, Inc.
lennart [at] poettering [dot] net
http://0pointer.net/lennart/ GnuPG 0x1A015CC4
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] alsa-plugins/pulse: Implement 'pause'.
[not found] ` <alpine.LFD.2.00.0906181444420.6800@troy-laptop>
@ 2009-06-18 14:40 ` Lennart Poettering
2009-06-18 16:15 ` Takashi Iwai
1 sibling, 0 replies; 4+ messages in thread
From: Lennart Poettering @ 2009-06-18 14:40 UTC (permalink / raw)
To: Troy Moure; +Cc: Takashi Iwai, alsa-devel, patch
On Thu, 18.06.09 14:55, Troy Moure (twmoure@szypr.net) wrote:
> > pa_stream_cork() will return a pa_operation object on success. The
> > least you need to do is call pa_operation_unref() on it, which you can
> > safely do right-away. Otherwise this will leak memory.
> >
> > Lennart
>
> Thanks, Lennart, for looking at the first verson I sent. I've added a
> call to pa_operation_unref() as you suggested.
Looks good to me now.
>
> pulse/pcm_pulse.c | 25 +++++++++++++++++++++++++
> 1 files changed, 25 insertions(+), 0 deletions(-)
>
> diff --git a/pulse/pcm_pulse.c b/pulse/pcm_pulse.c
> index db8d1e1..c276839 100644
> --- a/pulse/pcm_pulse.c
> +++ b/pulse/pcm_pulse.c
> @@ -739,6 +739,30 @@ static int pulse_close(snd_pcm_ioplug_t * io)
> return 0;
> }
>
> +static int pulse_pause(snd_pcm_ioplug_t * io, int enable)
> +{
> + snd_pcm_pulse_t *pcm = io->private_data;
> + int err = 0;
> +
> + assert (pcm);
> + assert (pcm->p);
> +
> + pa_threaded_mainloop_lock(pcm->p->mainloop);
> +
> + if (pcm->stream) {
> + pa_operation *o;
> + o = pa_stream_cork(pcm->stream, enable, NULL, NULL);
> + if (o)
> + pa_operation_unref(o);
> + else
> + err = -EIO;
> + }
> +
> + pa_threaded_mainloop_unlock(pcm->p->mainloop);
> +
> + return err;
> +}
> +
> static const snd_pcm_ioplug_callback_t pulse_playback_callback = {
> .start = pulse_start,
> .stop = pulse_stop,
> @@ -750,6 +774,7 @@ static const snd_pcm_ioplug_callback_t pulse_playback_callback = {
> .prepare = pulse_prepare,
> .hw_params = pulse_hw_params,
> .close = pulse_close,
> + .pause = pulse_pause
> };
>
>
Lennart
--
Lennart Poettering Red Hat, Inc.
lennart [at] poettering [dot] net
http://0pointer.net/lennart/ GnuPG 0x1A015CC4
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] alsa-plugins/pulse: Implement 'pause'.
[not found] ` <alpine.LFD.2.00.0906181444420.6800@troy-laptop>
2009-06-18 14:40 ` [PATCH v2] " Lennart Poettering
@ 2009-06-18 16:15 ` Takashi Iwai
1 sibling, 0 replies; 4+ messages in thread
From: Takashi Iwai @ 2009-06-18 16:15 UTC (permalink / raw)
To: Troy Moure; +Cc: alsa-devel, Lennart Poettering
At Thu, 18 Jun 2009 14:55:21 +0100 (BST),
Troy Moure wrote:
>
> Just cork or uncork the stream to pause or unpause it.
>
> Signed-off-by: Troy Moure <twmoure@szypr.net>
Applied now. Thanks!
Takashi
> ---
> On Wed, 17 Jun 2009, Lennart Poettering wrote:
>
> > Looks mostly good to me, but:
> >
> ...
> >
> > pa_stream_cork() will return a pa_operation object on success. The
> > least you need to do is call pa_operation_unref() on it, which you can
> > safely do right-away. Otherwise this will leak memory.
> >
> > Lennart
>
> Thanks, Lennart, for looking at the first verson I sent. I've added a
> call to pa_operation_unref() as you suggested.
>
> pulse/pcm_pulse.c | 25 +++++++++++++++++++++++++
> 1 files changed, 25 insertions(+), 0 deletions(-)
>
> diff --git a/pulse/pcm_pulse.c b/pulse/pcm_pulse.c
> index db8d1e1..c276839 100644
> --- a/pulse/pcm_pulse.c
> +++ b/pulse/pcm_pulse.c
> @@ -739,6 +739,30 @@ static int pulse_close(snd_pcm_ioplug_t * io)
> return 0;
> }
>
> +static int pulse_pause(snd_pcm_ioplug_t * io, int enable)
> +{
> + snd_pcm_pulse_t *pcm = io->private_data;
> + int err = 0;
> +
> + assert (pcm);
> + assert (pcm->p);
> +
> + pa_threaded_mainloop_lock(pcm->p->mainloop);
> +
> + if (pcm->stream) {
> + pa_operation *o;
> + o = pa_stream_cork(pcm->stream, enable, NULL, NULL);
> + if (o)
> + pa_operation_unref(o);
> + else
> + err = -EIO;
> + }
> +
> + pa_threaded_mainloop_unlock(pcm->p->mainloop);
> +
> + return err;
> +}
> +
> static const snd_pcm_ioplug_callback_t pulse_playback_callback = {
> .start = pulse_start,
> .stop = pulse_stop,
> @@ -750,6 +774,7 @@ static const snd_pcm_ioplug_callback_t pulse_playback_callback = {
> .prepare = pulse_prepare,
> .hw_params = pulse_hw_params,
> .close = pulse_close,
> + .pause = pulse_pause
> };
>
>
> --
> 1.6.2.2
>
>
>
>
>
> >
> > --
> > Lennart Poettering Red Hat, Inc.
> > lennart [at] poettering [dot] net
> > http://0pointer.net/lennart/ GnuPG 0x1A015CC4
> >
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2009-06-18 16:15 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-06-17 20:55 [PATCH] alsa-plugins/pulse: Implement 'pause' Troy Moure
2009-06-17 21:37 ` Lennart Poettering
[not found] ` <alpine.LFD.2.00.0906181444420.6800@troy-laptop>
2009-06-18 14:40 ` [PATCH v2] " Lennart Poettering
2009-06-18 16:15 ` Takashi Iwai
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.