Running "pulseaudio" and "alsa" together.

Sean McNamara smcnam at gmail.com
Sat Jun 2 06:43:11 PDT 2012


Hi,

On Sat, Jun 2, 2012 at 9:02 AM, Ajay Garg <ajay at activitycentral.com> wrote:
> Hi all.
>
> I have been banging my head for over 5 days now; went through whatever
> google-literature I could possibly through.
> But I guess I will have to ask the experts :|
>
>
> I will list down my queries with the story regarding that query, so as to
> maintain modularity as far as possible.
>
>
> I have a x86-based Fedora-14 Dell laptop; and a XO-1.

What is your XO-1 running? Is it also Fedora 14? You didn't specify,
unless you implied that the XO-1 is running the same as the Dell.

>
>
> A)
> On my Dell laptop, the following work seamlessly, and I am able to enjoy the
> mp3.
>
> (i)    gst-launch filesrc location=/path/to/mp3 ! mad ! alsasink
>
> (ii)   gst-launch filesrc location=/path/to/mp3 ! mad ! pulsesink
>
>
> However, on my XO-1, only the following works ::
>
>
> (i)    gst-launch filesrc location=/path/to/mp3 ! mad ! alsasink
>
> whereas the following shows the "pulsesink" plugin not found error ::
>
> (ii)   gst-launch filesrc location=/path/to/mp3 ! mad ! pulsesink
>
>
> I figured out that the package "gstreamer-plugins-good" is required for the
> "pulsesink" plugin.
>
> So, I did "gst-inspect" on both machines, and "rpm -qa | grep
> gstreamer-plugins-good" on both the machines.
>
> To my horror, I saw that the package
> "gstreamer-plugins-good-0.10.26-1.fc14.i686" was installed on both the Dell
> machine, and the XO-1, but only the Dell laptop showed the presence of
> "pulsesink".
>
> Why could this difference be ?
>

I don't know for sure, but if the pulseaudio plugin for gstreamer has
an unresolved link-time dependency, the gstreamer plugin loader won't
be able to load it. So for example if libpulse is not available...

Sounds like you manually messed with the XO-1 to some degree, as it
should not be in this state out of the box. In fact I can practically
guarantee that it *isn't*. You, or some software you installed, took
some action to bring the machine into this state. The default install
of Fedora Gnome has been shipping with the gstreamer plugin for
pulseaudio and pulseaudio itself for quite some time; definitely since
Fedora 14 or even earlier. You should be able to come out of a clean
install and immediately play gstreamer audio through pulseaudio with
no tweaking whatsoever. So the fact that yours is borked points to
something that has happened after installation.


>
>
>
>
>
> B)
> Anyhow, I copied "libgstpulse.so" from my Dell machine to the XO-1.
> Thereafter, "pulsesink" could be recognised on the XO-1.
>
> However, "gst-launch filesrc location=/path/to/mp3 ! mad ! pulsesink"
> resulted in a sound only on Dell, and  not XO-1.

Did you run gst-launch with the -v switch for verbose? Sounds like
pulseaudio isn't running, or you don't have the pulseaudio libraries
installed.

gst-launch-0.10 -v audiotestsrc ! volume volume=0.4 ! audioconvert !
pulsesink #warning: generated sound may be loud if it works, turn down
your speakers

If it produces any output on the console, post it back to the ML.

>
> So, I researched further, and concluded that I needed to install
> "alsa-plugins-pulseaudio" on the XO-1, so as to set up the pulseaudio
> server, and have the alsa-device as the "other end of the pulseaudio proxy".

That is incorrect. The pulseaudio plugin for libasound2 (the
user-space ALSA library) is designed to allow applications coded
against the ALSA API to have their sound re-routed through pulseaudio.
alsa-plugins-pulseaudio does NOT affect the way that pulseaudio itself
plays audio to its ALSA backend, because pulseaudio itself
automatically detects (using one of the detection modules) your
hardware sound cards.

Also, pulseaudio is not a "proxy" in this setup; you're just trying to
play audio locally.


>
> So, I installed the package.
>
> However, SOUND HAS STOPPED PLAYING COMPLETELY ON THE XO-1 (the only time I
> hear some sound is during boot-up time).

This isn't very surprising to me, considering that you already stated
that pulsesink isn't playing audio. Your PA daemon is somehow not
configured correctly or is not running in the first place.

alsa-plugins-pulseaudio is designed so that any well-behaved ALSA
application will try to play audio through the "pulse" software device
at the ALSA layer (libasound2). To get technical, it remaps the
"default" device to an instance of the "type pulse" device, so that an
application calling

snd_pcm_open(&pcm, "default", ...)

will actually be sending the audio through pulseaudio, rather than
"directly" through ALSA. This is done because 99.9% of the audio
devices out there only support software mixing, so you won't be able
to simultaneously listen to pulseaudio playing its own audio AND some
application playing audio directly to the ALSA hardware, e.g. with:

snd_pcm_open(&pcm, "hw:0", ...)

Thus, to avoid this problem, pulseaudio (and also ALSA) developers
have been trying to educate application developers on how to safely
write ALSA code so that it will use a default plugin if available, and
if not, then it goes to the hardware directly. Once you install
alsa-plugins-pulseaudio, the hardware path is still available, but
it's not the "default" device. So the "default" device tries to
connect to pulseaudio.

>
> If I remove "alsa-plugins-pulseaudio", I can again hear the sound via
> "alsasink", but not through "pulsesink".

This is in line with my explanation above.

>
> If I re-install "alsa-plugins-pulseaudio", I can not hear sound through
> "alsasink", nor "pulsesink",
> (
>     not even after doing the following steps ::
>
>                            pulsesudio --kill
>                            sudo rm -r ~/.pulse
>                            sudo rm -r ~/.pulse-cookie
>                            pulseaudio --start
>
>                            <trying to run the mp3 with sudo previleges.>

Well there's one potential problem. You will normally not be able to
run audio applications as root if your pulseaudio daemon is started as
a user. And you really, really, really shouldn't run pulseaudio as
root (p.s. sudo == running as root), either. So basically, unless you
have a very compelling need to run audio as root, don't do it. Start
pulseaudio as a regular user, and run your audio applications... as a
regular user.

Instead of pulseaudio --start, can you post the log output of:

pulseaudio --daemonize=false -vvvv

to the ML?

> )
>
>
> So, what other thing could I possibly do?

P.S. - Fedora *17* is out now, so unless you have some specific reason
not to upgrade (I can't think of one), you'd be better off doing so. A
lot of bugs have been fixed in the audio stack since. Fedora isn't
exactly the best distro for running an ancient release for years; for
that type of setup I'd recommend RHEL/CentOS or Debian Stable.

>
>
>
> Will be grateful for a reply.
>
>
> Thanks and Regards,
> Ajay
>
>
>
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
>


More information about the gstreamer-devel mailing list