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?
Quoted 2 lines · Timur Tabi
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 makessnd_pcm_hw_params_set_rate_near() fail?
At Tue, 23 Oct 2007 14:40:26 -0500,
Quoted 24 lines · Timur Tabi
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
Quoted 4 lines
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
Quoted 13 lines · Takashi Iwai
Quoted 12 lines · Timur Tabi
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
Quoted 5 lines
Quoted 2 lines
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
Quoted 16 lines · Clemens Ladisch
Quoted 15 lines · Takashi Iwai
Quoted 14 lines · Timur Tabi
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 hardwareI was under the impression that ALSA can do format and sample rate conversion if necessary, but I guess that's not always the case.
Quoted 8 lines
Quoted 2 lines
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.
Quoted 11 lines · Rene Herman
Quoted 2 lines · Clemens Ladisch
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
Quoted 7 lines · Clemens Ladisch
Quoted 5 lines · Rene Herman
Quoted 2 lines · Clemens Ladisch
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:
Quoted 8 lines
Quoted 5 lines
===
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.
Quoted 16 lines · Clemens Ladisch
Quoted 15 lines · Takashi Iwai
Quoted 14 lines · Timur Tabi
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 hardwareI was under the impression that ALSA can do format and sample rate conversion if necessary, but I guess that's not always the case.
Quoted 8 lines
Quoted 2 lines
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?
Quoted 10 lines · Timur Tabi
Quoted 4 lines · Clemens Ladisch
Quoted 1 line · Takashi Iwai
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.
Quoted 6 lines
So I added this .asoundrc:
pcm.!default {
type hw
card 0
}
This disables all automatic conversions.
Quoted 1 line
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
Quoted 1 line · Clemens Ladisch
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?
Quoted 7 lines
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.
Quoted 6 lines · Timur Tabi
Quoted 1 line · Clemens Ladisch
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
Quoted 1 line · Clemens Ladisch
mplayer disables ALSA's sample rate conversion and always uses its own.
I don't think that's true. 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?
Quoted 4 lines · Timur Tabi
Quoted 1 line · Clemens Ladisch
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.
Quoted 3 lines
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
Quoted 6 lines · Clemens Ladisch
Quoted 3 lines · Timur Tabi
Quoted 1 line · Clemens Ladisch
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?
Quoted 10 lines · Timur Tabi
Quoted 6 lines · Clemens Ladisch
Quoted 3 lines · Timur Tabi
Quoted 1 line · Clemens Ladisch
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