Problem writing to PCM plugin
I'm currently trying to implement support for user defined pcm plugins in PortAudio ALSA (ALSA-lib 1.05), and I've got as far as discovering the pcms. In order to test I defined a routing plugin, which moves data from channel 0/1 to 16/17 (S/PDIF) on my Hammerfall Lite. With aplay this plugin works just fine, but when I open it with PortAudio the same way as with any hardware device, the output is simply silent (I can't listen to any of the ADAT channels since I lack ADAT gear). Defining a simple plugin which does nothing but drive my onboard nForce2 (routing fails with this assertion: 'pcm_plug.c:363: snd_pcm_plug_change_channels: Assertion `snd_pcm_format_linear(slv->format)' failed') works the same as if I open the hw device.
The obvious difference to aplay I can think of is that we use floating point format in the PortAudio tests, so there is an intermediate conversion before the audio gets to the routing plugin. Could this be the cause of the problem? If you wish I can provide output from snd_pcm_dump.
Thanks
Arve Knudsen
-------------------------------------------------------
SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media 100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33 Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285
Quoted 3 lines · Arve Knudsen
point format in the PortAudio tests, so there is an intermediate conversion before the audio gets to the routing plugin. Could this be the cause of the problem? If you wish I can provide output from
snd_pcm_dump.
Yes, send the dump, please.
Jaroslav
-----
Jaroslav Kysela <[email protected]>
Linux Kernel Sound Maintainer
ALSA Project, SUSE Labs
-------------------------------------------------------
SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media 100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33 Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285
Quoted 6 lines · Arve Knudsen
pcm_plug.c:363:
snd_pcm_plug_change_channels: Assertion `snd_pcm_format_linear(slv->format)' failed'The obvious difference to aplay I can think of is that we use floating point format in the PortAudio tests, so there is an intermediate conversion before the audio gets to the routing plugin.
The route plugin doesn't support floating point formats. Try wrapping it into a lfloat (or plug) plugin.
HTH
Clemens
-------------------------------------------------------
SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media 100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33 Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285
The plugin:
pcm.9636SPDIF {
type plug
slave.pcm "hw:1"
ttable.0.16 1
ttable.1.17 1
}The dump:
Plug PCM: Linear Integer <-> Linear Float conversion PCM (S32_LE) Its setup is:
stream : PLAYBACK
access : MMAP_INTERLEAVED
format : FLOAT_LE
subformat : STD
channels : 2
rate : 44100
exact rate : 44100 (44100/1)
msbits : 32buffer_size : 2048period_size : 1024period_time : 23219tick_time : 1000tstamp_mode : MMAPperiod_step : 1sleep_min : 0avail_min : 1024xfer_align : 1start_threshold : 1024stop_threshold : 2048silence_threshold: 0silence_size : 2147483647
boundary : 1073741824
Slave: Route conversion PCM (sformat=S32_LE)
Transformation table:
0 <- none
1 <- none
Its setup is:
stream : PLAYBACK
access : MMAP_INTERLEAVED
format : S32_LE
subformat : STD
channels : 2
rate : 44100
exact rate : 44100 (44100/1)
msbits : 32buffer_size : 2048period_size : 1024period_time : 23219tick_time : 1000tstamp_mode : MMAPperiod_step : 1sleep_min : 0avail_min : 1024xfer_align : 1start_threshold : 1024stop_threshold : 2048silence_threshold: 0silence_size : 2147483647
boundary : 1073741824
Slave: Route conversion PCM (sformat=S32_LE)
Transformation table:
0 <- none
1 <- none
2 <- none
3 <- none
4 <- none
5 <- none
6 <- none
7 <- none
8 <- none
9 <- none
10 <- none
11 <- none
12 <- none
13 <- none
14 <- none
15 <- none
16 <- 0
17 <- 1
Its setup is:
stream : PLAYBACK
access : MMAP_INTERLEAVED
format : S32_LE
subformat : STD
channels : 2
rate : 44100
exact rate : 44100 (44100/1)
msbits : 32buffer_size : 2048period_size : 1024period_time : 23219tick_time : 1000tstamp_mode : MMAPperiod_step : 1sleep_min : 0avail_min : 1024xfer_align : 1start_threshold : 1024stop_threshold : 2048silence_threshold: 0silence_size : 2147483647
boundary : 1073741824
Slave: Hardware PCM card 1 'RME Digi9636 (Rev 1.5)' device 0 subdevice 0
Its setup is:
stream : PLAYBACK
access : MMAP_NONINTERLEAVED
format : S32_LE
subformat : STD
channels : 18
rate : 44100
exact rate : 44100 (44100/1)
msbits : 24buffer_size : 2048period_size : 1024period_time : 23219tick_time : 1000tstamp_mode : MMAPperiod_step : 1sleep_min : 0avail_min : 1024xfer_align : 1start_threshold : 1024stop_threshold : 2048silence_threshold: 0silence_size : 2147483647
boundary : 1073741824
Quoted 6 lines · Jaroslav Kysela
Quoted 3 lines · Arve Knudsen
point format in the PortAudio tests, so there is an intermediate conversion before the audio gets to the routing plugin. Could this be the cause of the problem? If you wish I can provide output from
snd_pcm_dump.
Quoted 8 lines
Yes, send the dump, please.
Jaroslav
-----
Jaroslav Kysela <[email protected]>
Linux Kernel Sound Maintainer
ALSA Project, SUSE Labs
-------------------------------------------------------
SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media 100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33 Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285
Actually the plugin is of type "plug", and according to snd_pcm_dump it seems ALSA-lib takes care of converting the sample format. Only getting to know the plugin system here ...
Regards
Arve Knudsen
Quoted 8 lines · Clemens Ladisch
Quoted 6 lines · Arve Knudsen
pcm_plug.c:363:
snd_pcm_plug_change_channels: Assertion `snd_pcm_format_linear(slv->format)' failed'The obvious difference to aplay I can think of is that we use floating point format in the PortAudio tests, so there is an intermediate conversion before the audio gets to the routing plugin.
Quoted 8 lines
The route plugin doesn't support floating point formats. Try wrapping it into a lfloat (or plug) plugin.
HTH
Clemens
-------------------------------------------------------
SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media 100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33 Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285
Quoted 6 lines · Arve Knudsen
Based on your suggestion I rewrote the plugin, so it wraps a route plugin. And now things work as I would expect. I must say I'm still confused on the issue, as I haven't found any explanation why my original approach wouldn't work. What's the difference between defining a translation table directly inside a "plug" plugin, and aggregating a slave "route" plugin within a "plug"?
There was an error in the plug plugin - one route plugin was inserted by mistake. This patch will fix the wrong plug behaviour:
Index: pcm_plug.c
===================================================================
RCS file: /cvsroot/alsa/alsa-lib/src/pcm/pcm_plug.c,v retrieving revision 1.126
pcm_plug.c +5 -3
@@ -53,7 +53,7 @@int srate;enum snd_pcm_plug_route_policy route_policy;snd_pcm_route_ttable_entry_t *ttable; -int ttable_ok; +int ttable_ok, ttable_last;unsigned int tt_ssize, tt_cused, tt_sused; } snd_pcm_plug_t;
@@ -361,7 +361,8 @@snd_pcm_route_ttable_entry_t *ttable;int err;assert (snd_pcm_format_linear (slv->format)); -if (clt->channels == slv->channels && !plug->ttable) +if (clt->channels == slv->channels && + (!plug->ttable || !plug->ttable_last))return 0 ;if (clt->rate != slv->rate && clt->channels > slv->channels)
@@ -560,7 +561,7 @@ };snd_pcm_plug_params_t p = *slave;unsigned int k =0 ; - plug->ttable_ok =0 ; + plug->ttable_ok = plug->ttable_last =0 ; while (client->format != p.format || client->channels != p.channels || client->rate != p.rate ||
@@ -584,6 +585,7 @@if (plug->ttable && !plug->ttable_ok) {snd_pcm_t *new;int err; + plug->ttable_last =1 ; err =snd_pcm_plug_change_channels (pcm, &new, client, &p);if (err <0 ) {snd_pcm_plug_clear (pcm);
Jaroslav
-----
Jaroslav Kysela <[email protected]>
Linux Kernel Sound Maintainer
ALSA Project, SUSE Labs
-------------------------------------------------------
SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media 100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33 Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285
Based on your suggestion I rewrote the plugin, so it wraps a route plugin. And now things work as I would expect. I must say I'm still confused on the issue, as I haven't found any explanation why my original approach wouldn't work. What's the difference between defining a translation table directly inside a "plug" plugin, and aggregating a slave "route" plugin within a "plug"?
Sort of weird that the plugin caused an assertion only when used in combination with the nForce2 chip, and not the Hammerfall (just silent operation).
Thanks
Arve Knudsen
Quoted 18 lines · Clemens Ladisch
Quoted 6 lines · Arve Knudsen
pcm_plug.c:363:
snd_pcm_plug_change_channels: Assertion `snd_pcm_format_linear(slv->format)' failed'The obvious difference to aplay I can think of is that we use floating point format in the PortAudio tests, so there is an intermediate conversion before the audio gets to the routing plugin.
The route plugin doesn't support floating point formats. Try wrapping it into a lfloat (or plug) plugin.
HTH
Clemens
Quoted 9 lines
-------------------------------------------------------
SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media 100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33 Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285
_______________________________________________
Alsa-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/alsa-devel
-------------------------------------------------------
SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media 100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33 Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285