[alsa-devel] PCM parameters in file plugin

Pavel Hofman pavel.hofman at insite.cz
Tue Jan 6 12:33:42 CET 2009


Jaroslav Kysela wrote:
> On Tue, 6 Jan 2009, Pavel Hofman wrote:
> 
>> Pavel Hofman napsal(a):
>>> Hello,
>>>
>>> I am working on a file plugin patch to allow adding PCM parameters 
>>> (rate, format) to  the name of the file created (plus the ability to run 
>>> an external command via popen, such as upsampling with sox). I got stuck 
>>> in trying to obtain these parameters in pcm_file.c:_snd_pcm_file_open(). 
>>> Is it actually possible or the information is not available at the time 
>>> of opening the file (and the whole patch is thus nonsense)?
>>>
>>> Thanks a lot for help.
>>>
>> I am now opening the output file in pcm_file.c:snd_pcm_file_write_bytes.
>> Surprisingly it seems to work fine. Could such hack be accepted as a
>> patch to the plugin (if coded properly)? Is there a better place to open 
>> the file?
> 
> The file should be opened in the hw_params callback (all PCM parameters 
> are known in this time). Also, extending filename with PCM parameters 
> should be optional (configurable). But the idea looks nice.
> 
> 						Jaroslav


Hi,

Thanks a lot for your hint. Here is a preliminary version of the patch 
for review (no docs updated, no clean formatting).

The changes are moving the opening of output file to hw_params callback, 
support for replacement codes in the file parameter,  and support for 
piping to external commands when the file parameter starts with |.

This is a working ".asoundrc on steroids" (upsampling to 96kHz using the 
quality algorithm of sox)

pcm.raw {
          type file
          slave {
                  pcm null
          }
          format "raw"
          file "| sox -V -c %c -%b -r %r -s -t raw - -t raw -4 - rate -v 
-s 96000 | aplay -v -t raw -r 96000 -c %c -f S32_LE -Dhw:0"
}

Thanks a lot for comments.

Regards,

Pavel.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pcm_file.c.patch
Type: text/x-diff
Size: 9485 bytes
Desc: not available
Url : http://mailman.alsa-project.org/pipermail/alsa-devel/attachments/20090106/d4b4cfc1/attachment.bin 


More information about the Alsa-devel mailing list