* Switching from default to plughw:0,0
@ 2016-09-10 23:33 Gonzalo Garramuño
2016-09-10 23:46 ` Clemens Ladisch
0 siblings, 1 reply; 5+ messages in thread
From: Gonzalo Garramuño @ 2016-09-10 23:33 UTC (permalink / raw)
To: alsa-devel
I have coded an application that uses ALSA and plays back movie's
audios, together with their videos. I have pulseaudio installed by
default as it comes with Ubuntu Xenian.
My goal is to provide the user with an easy pull-down where they can
select the audio device to play the audio in.
The first audio device is "default" and defaults to ALSA's default in
the Ubuntu Sound Preferences. All that works fine. I can change the
Ubuntu Sound Preferences and the default driver immediately picks up the
other cards or outputs in the system.
My problem is that when I choose the default, which is equivalent to
plughw:0,0, when I go to force select in my program the plughw:0,0 (HDA
Intel PCH: ALC1150 Analog), I get a Device or resource busy.
Sure enough, if I do:
$ fuser -v /dev/snd/*
USUARIO ORDEN DE ACCESO PID
/dev/snd/controlC0: gga 3594 F.... pulseaudio
/dev/snd/controlC1: gga 3594 F.... pulseaudio
/dev/snd/pcmC0D0p: gga 4821 F...m pulseaudio
I am very careful in closing the audio before reopening it again.
However the resource remains busy for about 7 seconds. Then it turns into:
USUARIO ORDEN DE ACCESO PID
/dev/snd/controlC0: gga 3594 F.... pulseaudio
/dev/snd/controlC1: gga 3594 F.... pulseaudio
/dev/snd/pcmC0D0p: gga 4821 F...m mrViewer
and the audio works again. My close function looks like:
bool ALSAEngine::close()
{
if ( _pcm_handle )
{
int err = snd_pcm_drop( _pcm_handle );
if ( err < 0 )
{
std::cerr << "ERROR: [alsa] snd_pcm_drop failed with "
<< snd_strerror(err)
<< std::endl;
}
err = snd_pcm_close( _pcm_handle );
if ( err < 0 )
{
std::cerr << "ERROR: [alsa] snd_pcm_close failed with "
<< snd_strerror(err)
<< std::endl;
}
_pcm_handle = NULL;
}
return true;
}
and the open function (simplified till it fails).
bool ALSAEngine::open( const unsigned channels,
const unsigned freq,
const AudioFormat format,
const unsigned bits )
{
try
{
close();
int status;
unsigned int test_format = (unsigned int) format;
char buf[256];
/* Open the audio device */
/* Name of device should depend on # channels in spec */
_pcm_handle = NULL;
status = snd_pcm_open(&_pcm_handle, device().c_str(),
SND_PCM_STREAM_PLAYBACK, 0);
if ( status < 0 || _pcm_handle == NULL ) {
sprintf( buf, _("Couldn't open audio device %s: %s"),
device().c_str(), snd_strerror(status));
THROW(buf);
}
....snip.....
}
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Switching from default to plughw:0,0
2016-09-10 23:33 Switching from default to plughw:0,0 Gonzalo Garramuño
@ 2016-09-10 23:46 ` Clemens Ladisch
2016-09-11 1:20 ` Gonzalo Garramuño
[not found] ` <19f3ac8e-cd79-2b03-824f-330350c5bc82@gmail.com>
0 siblings, 2 replies; 5+ messages in thread
From: Clemens Ladisch @ 2016-09-10 23:46 UTC (permalink / raw)
To: Gonzalo Garramuño, alsa-devel
Gonzalo Garramuño wrote:
> My problem is that when I choose the default, which is equivalent to plughw:0,0
The default actually is PulseAudio or dmix.
Regards,
Clemens
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Switching from default to plughw:0,0
2016-09-10 23:46 ` Clemens Ladisch
@ 2016-09-11 1:20 ` Gonzalo Garramuño
[not found] ` <19f3ac8e-cd79-2b03-824f-330350c5bc82@gmail.com>
1 sibling, 0 replies; 5+ messages in thread
From: Gonzalo Garramuño @ 2016-09-11 1:20 UTC (permalink / raw)
To: Clemens Ladisch, alsa-devel
El 10/09/16 a las 20:46, Clemens Ladisch escribió:
> Gonzalo Garramuño wrote:
>> My problem is that when I choose the default, which is equivalent to plughw:0,0
> The default actually is PulseAudio or dmix.
>
>
> Regards,
> Clemens
I can confirm this is a bug in alsa/pulseaudio. I managed to get the
same behavior out of vlc, by calling it with:
vlc -A alsa --alsa-audio-device plughw:0,0
/media/gga/Datos/movies/trailers/Frozen-Let_it_go.mp4
and then switching back and forth between Pulse Audio Sound Server and
HDA Intel PCH. When switching back to intel (plughw:0,0), the resource
is busy and the audio fails.
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Switching from default to plughw:0,0
[not found] ` <19f3ac8e-cd79-2b03-824f-330350c5bc82@gmail.com>
@ 2016-09-11 10:58 ` Clemens Ladisch
2016-09-11 17:40 ` Gonzalo Garramuño
0 siblings, 1 reply; 5+ messages in thread
From: Clemens Ladisch @ 2016-09-11 10:58 UTC (permalink / raw)
To: Gonzalo Garramuño; +Cc: alsa-devel
Gonzalo Garramuño wrote:
> El 10/09/16 a las 20:46, Clemens Ladisch escribió:
>> Gonzalo Garramuño wrote:
>>> My problem is that when I choose the default, which is equivalent to plughw:0,0
>>
>> The default actually is PulseAudio or dmix.
>
> dmix is not installed in my system
It's part of ALSA.
> Do I have to deal with the pulseaudio api, instead of the ALSA api?
When PulseAudio is configured as the default, it can be accessed through the ALSA API.
Anyway, the correct name for the default device is "default".
To get a list of devices, see "aplay -L".
Regards,
Clemens
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Switching from default to plughw:0,0
2016-09-11 10:58 ` Clemens Ladisch
@ 2016-09-11 17:40 ` Gonzalo Garramuño
0 siblings, 0 replies; 5+ messages in thread
From: Gonzalo Garramuño @ 2016-09-11 17:40 UTC (permalink / raw)
To: alsa-devel; +Cc: Clemens Ladisch
El 11/09/16 a las 07:58, Clemens Ladisch escribió:
> When PulseAudio is configured as the default, it can be accessed through the ALSA API.
How exactly?
>
> Anyway, the correct name for the default device is "default".
>
> To get a list of devices, see "aplay -L".
Here's the output of aplay -L
$ aplay -L
default
Playback/recording through the PulseAudio sound server
null
Discard all samples (playback) or generate zero samples (capture)
pulse
PulseAudio Sound Server
sysdefault:CARD=PCH
HDA Intel PCH, ALC1150 Analog
Default Audio Device
front:CARD=PCH,DEV=0
HDA Intel PCH, ALC1150 Analog
Front speakers
surround21:CARD=PCH,DEV=0
HDA Intel PCH, ALC1150 Analog
2.1 Surround output to Front and Subwoofer speakers
surround40:CARD=PCH,DEV=0
HDA Intel PCH, ALC1150 Analog
4.0 Surround output to Front and Rear speakers
surround41:CARD=PCH,DEV=0
HDA Intel PCH, ALC1150 Analog
4.1 Surround output to Front, Rear and Subwoofer speakers
surround50:CARD=PCH,DEV=0
HDA Intel PCH, ALC1150 Analog
5.0 Surround output to Front, Center and Rear speakers
surround51:CARD=PCH,DEV=0
HDA Intel PCH, ALC1150 Analog
5.1 Surround output to Front, Center, Rear and Subwoofer speakers
surround71:CARD=PCH,DEV=0
HDA Intel PCH, ALC1150 Analog
7.1 Surround output to Front, Center, Side, Rear and Woofer speakers
iec958:CARD=PCH,DEV=0
HDA Intel PCH, ALC1150 Digital
IEC958 (S/PDIF) Digital Audio Output
dmix:CARD=PCH,DEV=0
HDA Intel PCH, ALC1150 Analog
Direct sample mixing device
dmix:CARD=PCH,DEV=1
HDA Intel PCH, ALC1150 Digital
Direct sample mixing device
dsnoop:CARD=PCH,DEV=0
HDA Intel PCH, ALC1150 Analog
Direct sample snooping device
dsnoop:CARD=PCH,DEV=1
HDA Intel PCH, ALC1150 Digital
Direct sample snooping device
hw:CARD=PCH,DEV=0
HDA Intel PCH, ALC1150 Analog
Direct hardware device without any conversions
hw:CARD=PCH,DEV=1
HDA Intel PCH, ALC1150 Digital
Direct hardware device without any conversions
plughw:CARD=PCH,DEV=0
HDA Intel PCH, ALC1150 Analog
Hardware device with all software conversions
plughw:CARD=PCH,DEV=1
HDA Intel PCH, ALC1150 Digital
Hardware device with all software conversions
hdmi:CARD=NVidia,DEV=0
HDA NVidia, HDMI 0
HDMI Audio Output
hdmi:CARD=NVidia,DEV=1
HDA NVidia, HDMI 1
HDMI Audio Output
hdmi:CARD=NVidia,DEV=2
HDA NVidia, HDMI 2
HDMI Audio Output
hdmi:CARD=NVidia,DEV=3
HDA NVidia, HDMI 3
HDMI Audio Output
dmix:CARD=NVidia,DEV=3
HDA NVidia, HDMI 0
Direct sample mixing device
dmix:CARD=NVidia,DEV=7
HDA NVidia, HDMI 1
Direct sample mixing device
dmix:CARD=NVidia,DEV=8
HDA NVidia, HDMI 2
Direct sample mixing device
dmix:CARD=NVidia,DEV=9
HDA NVidia, HDMI 3
Direct sample mixing device
dsnoop:CARD=NVidia,DEV=3
HDA NVidia, HDMI 0
Direct sample snooping device
dsnoop:CARD=NVidia,DEV=7
HDA NVidia, HDMI 1
Direct sample snooping device
dsnoop:CARD=NVidia,DEV=8
HDA NVidia, HDMI 2
Direct sample snooping device
dsnoop:CARD=NVidia,DEV=9
HDA NVidia, HDMI 3
Direct sample snooping device
hw:CARD=NVidia,DEV=3
HDA NVidia, HDMI 0
Direct hardware device without any conversions
hw:CARD=NVidia,DEV=7
HDA NVidia, HDMI 1
Direct hardware device without any conversions
hw:CARD=NVidia,DEV=8
HDA NVidia, HDMI 2
Direct hardware device without any conversions
hw:CARD=NVidia,DEV=9
HDA NVidia, HDMI 3
Direct hardware device without any conversions
plughw:CARD=NVidia,DEV=3
HDA NVidia, HDMI 0
Hardware device with all software conversions
plughw:CARD=NVidia,DEV=7
HDA NVidia, HDMI 1
Hardware device with all software conversions
plughw:CARD=NVidia,DEV=8
HDA NVidia, HDMI 2
Hardware device with all software conversions
plughw:CARD=NVidia,DEV=9
HDA NVidia, HDMI 3
Hardware device with all software conversions
>
> Regards,
> Clemens
Thanks, Clemens. My code works with the "default" device. On the
gnome-control-center, I am able to switch the default device and all
works fine.
My problem is when I want my program to specify the device to use
directly from the GUI: plughw:0,0. The device is in control of
pulseaudio and does not release it until about 7 seconds go by with no
audio. I tried a similar set up in vlc and the result was the same (vlc
reported that it could not open the device), so I know it is not my code.
Let me know how can I control pulseaudio to close immediately the
virtual device it opens.
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2016-09-11 17:40 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-09-10 23:33 Switching from default to plughw:0,0 Gonzalo Garramuño
2016-09-10 23:46 ` Clemens Ladisch
2016-09-11 1:20 ` Gonzalo Garramuño
[not found] ` <19f3ac8e-cd79-2b03-824f-330350c5bc82@gmail.com>
2016-09-11 10:58 ` Clemens Ladisch
2016-09-11 17:40 ` Gonzalo Garramuño
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).