[alsa-devel] Confused about 'default' device
I'm having a hard time understand when ALSA does sample rate and format conversion, and when it doesn't.
When I issue the following command:
mplayer -ao alsa filename.mov -v
I get this output:
Building audio filter chain for 48000Hz/2ch/s24le -> 0Hz/0ch/s8... [libaf] Adding filter dummy [dummy] Was reinitialized: 48000Hz/2ch/s24le [dummy] Was reinitialized: 48000Hz/2ch/s24le alsa-init: requested format: 48000 Hz, 2 channels, 11 alsa-init: using ALSA 1.0.8 alsa-init: setup for 1/2 channel(s) alsa-init: using device default alsa-init: pcm opend in blocking mode alsa-init: format s24le are not supported by hardware, trying default alsa-lib: pcm_plug.c:729:(snd_pcm_plug_hw_refine_schange) Unable to find an usable access for 'default' alsa-init: unable to set format: Invalid argument
Sure enough, my device can't handle s24le. It can only handle s16be.
I was under the impression that ALSA can do format and sample rate conversion if necessary, but I guess that's not always the case. I know ALSA has a bunch of plug-ins for that, but I guess they're not used by default.
What do I need to do to tell ALSA to convert s24le to s16be?
Timur Tabi wrote:
I'm having a hard time understand when ALSA does sample rate and format conversion, and when it doesn't.
Some more info:
I'm trying to play a movie with 441000 Hz audio.
If I specify "-ao alsa", mplayer calls snd_pcm_hw_params_set_rate_near() with a value of 44100. The call fails and returns an error code.
If I specify "-ao alsa:device=hw=0.0", snd_pcm_hw_params_set_rate_near() does not fail, even though it's being passed the same parameters.
So what is it about the default device that makes snd_pcm_hw_params_set_rate_near() fail?
At Tue, 23 Oct 2007 14:40:26 -0500, Timur Tabi wrote:
I'm having a hard time understand when ALSA does sample rate and format conversion, and when it doesn't.
When I issue the following command:
mplayer -ao alsa filename.mov -v
I get this output:
Building audio filter chain for 48000Hz/2ch/s24le -> 0Hz/0ch/s8... [libaf] Adding filter dummy [dummy] Was reinitialized: 48000Hz/2ch/s24le [dummy] Was reinitialized: 48000Hz/2ch/s24le alsa-init: requested format: 48000 Hz, 2 channels, 11 alsa-init: using ALSA 1.0.8 alsa-init: setup for 1/2 channel(s) alsa-init: using device default alsa-init: pcm opend in blocking mode alsa-init: format s24le are not supported by hardware, trying default alsa-lib: pcm_plug.c:729:(snd_pcm_plug_hw_refine_schange) Unable to find an usable access for 'default' alsa-init: unable to set format: Invalid argument
Sure enough, my device can't handle s24le. It can only handle s16be.
I was under the impression that ALSA can do format and sample rate conversion if necessary, but I guess that's not always the case.
It does. mplayer seems to try first the hardware device without conversion and falls back to "default" PCM. The problem appears to be the access type, such as, SND_PCM_ACCESS_RW_INTERLEAVED, MMAP, etc.
Try to set LIBASOUND_DEBUG=1 to see what parameters are being used.
Takashi
Takashi Iwai wrote:
Timur Tabi wrote:
I'm having a hard time understand when ALSA does sample rate and format conversion, and when it doesn't.
When I issue the following command:
mplayer -ao alsa filename.mov -v
I get this output: ... alsa-init: using device default alsa-init: format s24le are not supported by hardware
I was under the impression that ALSA can do format and sample rate conversion if necessary, but I guess that's not always the case.
It does. mplayer seems to try first the hardware device without conversion and falls back to "default" PCM.
In this case, it uses only the "default" PCM device. There seems to be some problem with its definition.
Are there any definitions in ~/.asoundrc or /etc/asound.conf? If not, what driver is used, and does it have a file in /usr/share/alsa/cards/?
Regards, Clemens
On 10/24/2007 01:37 PM, Clemens Ladisch wrote:
Takashi Iwai wrote:
Timur Tabi wrote:
I'm having a hard time understand when ALSA does sample rate and format conversion, and when it doesn't.
When I issue the following command:
mplayer -ao alsa filename.mov -v
I get this output: ... alsa-init: using device default alsa-init: format s24le are not supported by hardware
I was under the impression that ALSA can do format and sample rate conversion if necessary, but I guess that's not always the case.
It does. mplayer seems to try first the hardware device without conversion and falls back to "default" PCM.
In this case, it uses only the "default" PCM device. There seems to be some problem with its definition.
Are there any definitions in ~/.asoundrc or /etc/asound.conf? If not, what driver is used, and does it have a file in /usr/share/alsa/cards/?
Just in case you guys missed it -- he posted:
=== alsa-init: using ALSA 1.0.8 ===
Isn't 1.0.8 from before ALSA did any mixing by default?
Rene.
Rene Herman wrote:
On 10/24/2007 01:37 PM, Clemens Ladisch wrote:
In this case, it uses only the "default" PCM device. There seems to be some problem with its definition.
Just in case you guys missed it -- he posted:
=== alsa-init: using ALSA 1.0.8 ===
Isn't 1.0.8 from before ALSA did any mixing by default?
The default "default" device would do automatic sample format conversion even in that version.
Regards, Clemens
On 10/24/2007 02:41 PM, Clemens Ladisch wrote:
Rene Herman wrote:
On 10/24/2007 01:37 PM, Clemens Ladisch wrote:
In this case, it uses only the "default" PCM device. There seems to be some problem with its definition.
Just in case you guys missed it -- he posted:
=== alsa-init: using ALSA 1.0.8 ===
Isn't 1.0.8 from before ALSA did any mixing by default?
The default "default" device would do automatic sample format conversion even in that version.
Erm, yes, wasn't about mixing. Misread. Never mind.
Rene.
Clemens Ladisch wrote:
Takashi Iwai wrote:
Timur Tabi wrote:
I'm having a hard time understand when ALSA does sample rate and format conversion, and when it doesn't.
When I issue the following command:
mplayer -ao alsa filename.mov -v
I get this output: ... alsa-init: using device default alsa-init: format s24le are not supported by hardware
I was under the impression that ALSA can do format and sample rate conversion if necessary, but I guess that's not always the case.
It does. mplayer seems to try first the hardware device without conversion and falls back to "default" PCM.
In this case, it uses only the "default" PCM device. There seems to be some problem with its definition.
Are there any definitions in ~/.asoundrc or /etc/asound.conf? If not, what driver is used, and does it have a file in /usr/share/alsa/cards/?
Ok, I made some progress.
According to http://alsa.opensrc.org/.asoundrc, because I'm using ALSA 1.0.8, I need to have an .asoundrc. So I added this .asoundrc:
pcm.!default { type hw card 0 } ctl.!default { type hw card 0 }
And now sample rate conversion works! However, sample format conversion does not work. When I try to play a movie with an s24le sound track, I get this:
$ MPlayer-1.0rc1/mplayer -ao alsa video/320x240/sm3_sneak_peek.mov MPlayer 1.0rc1-3.3.5 (C) 2000-2006 MPlayer Team AltiVec found CPU: PowerPC
Playing video/320x240/sm3_sneak_peek.mov. ISO: File Type Major Brand: Original QuickTime Quicktime/MOV file format detected. VIDEO: [avc1] 320x240 24bpp 29.970 fps 0.0 kbps ( 0.0 kbyte/s) vo: couldn't open the X11 display ()! vo: couldn't open the X11 display ()! VO XOverlay need a subdriver vo: couldn't open the X11 display ()! ========================================================================== Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family Selected video codec: [ffh264] vfm: ffmpeg (FFmpeg H.264) ========================================================================== ========================================================================== Opening audio decoder: [pcm] Uncompressed PCM audio decoder AUDIO: 48000 Hz, 2 ch, s24le, 2304.0 kbit/100.00% (ratio: 288000->288000) Selected audio codec: [pcm] afm: pcm (Uncompressed PCM) ========================================================================== alsa-init: format s24le are not supported by hardware, trying default alsa-init: unable to set format: Invalid argument Could not open/initialize audio device -> no sound. Audio: no sound Starting playback... VDec: vo config request - 320 x 240 (preferred colorspace: Planar YV12) Could not find matching colorspace - retrying with -vf scale... Opening video filter: [scale] VDec: using Planar YV12 as output csp (no 0) Movie-Aspect is undefined - no prescaling applied. SwScaler: using unscaled yuv420p -> rgb32 special converter VO: [fbdev] 320x240 => 320x240 ARGB V: 2.4 74/ 74 4% 5% 0.0% 0 0 Exiting... (Quit)
Does this mean that sample rate conversion is supported, but not sample format conversion?
Timur Tabi wrote:
Clemens Ladisch wrote:
Takashi Iwai wrote:
Timur Tabi wrote:
Are there any definitions in ~/.asoundrc or /etc/asound.conf? If not, what driver is used, and does it have a file in /usr/share/alsa/cards/?
Ok, I made some progress.
According to http://alsa.opensrc.org/.asoundrc, because I'm using ALSA 1.0.8, I need to have an .asoundrc.
You'd need it to activate dmix, but sample rate/format conversion already works with earlier versions.
So I added this .asoundrc:
pcm.!default { type hw card 0 }
This disables all automatic conversions.
And now sample rate conversion works!
Well, it always worked because mplayer does it itself.
Please try this:
pcm.!default = "plughw:0"
And if this works, there is something wrong with you default device definitions. Please tell us the driver name and whether it has a file in /usr/share/alsa/cards/.
Regards, Clemens
Clemens Ladisch wrote:
Well, it always worked because mplayer does it itself.
I'm confused. Are you saying the addition of .asoundrc somehow forces mplayer to do sample-rate conversion where before it didn't because it assumed that Alsa would do it?
Please try this:
pcm.!default = "plughw:0"
And if this works, there is something wrong with you default device definitions. Please tell us the driver name and whether it has a file in /usr/share/alsa/cards/.
I definitely did not add anything to /usr/share/alsa/cards for my audio driver.
Timur Tabi wrote:
Clemens Ladisch wrote:
Well, it always worked because mplayer does it itself.
I'm confused. Are you saying the addition of .asoundrc somehow forces mplayer to do sample-rate conversion where before it didn't because it assumed that Alsa would do it?
mplayer disables ALSA's sample rate conversion and always uses its own.
Regards, Clemens
Timur Tabi wrote:
Clemens Ladisch wrote:
mplayer disables ALSA's sample rate conversion and always uses its own.
I don't think that's true.
It's true if you use alsa-lib 1.0.9 or later.
If it always uses its own, then how much it works on some video files and not others, and how come including a .asoundrc changes the behavior of mplayer?
mplayer relies on ALSA to do sample _format_ conversion.
Regards, Clemens
Clemens Ladisch wrote:
Timur Tabi wrote:
Clemens Ladisch wrote:
mplayer disables ALSA's sample rate conversion and always uses its own.
I don't think that's true.
It's true if you use alsa-lib 1.0.9 or later.
What is different between 1.0.8 and 1.0.9 that triggers mplayer to behave differently?
Timur Tabi wrote:
Clemens Ladisch wrote:
Timur Tabi wrote:
Clemens Ladisch wrote:
mplayer disables ALSA's sample rate conversion and always uses its own.
I don't think that's true.
It's true if you use alsa-lib 1.0.9 or later.
What is different between 1.0.8 and 1.0.9 that triggers mplayer to behave differently?
alsa-lib 1.0.9 allows do disable its resampler.
Regards, Clemens
participants (4)
-
Clemens Ladisch
-
Rene Herman
-
Takashi Iwai
-
Timur Tabi