On 8/27/2023 5:25 AM, Tim Hardisty wrote:
Looking a little more at the write function of audio_ops_s it is not used by 
any existing driver and is documented to be for device-specific 
information...so it is not portable in terms of playing tones by simply writing 
PCM data word by word. I get that now.

So I'm thinking the right way is possibly either:

1) Complete the "tone" support of nxplayer - it exists as a command parameter 
but has no underlying code/functions

2) create a tone player as a standalone (example) app that opens /dev/audio/pcm%d and makes use of the audio_ops_s functions and 
ioctls to set up a NuttX sound system compliant device and play tones. That is then portable and can be used with any supported audio 
device without having to use nxplayer in its entirety. e.g you could run, from nsh something like: "pcmtone <device> 
<samp_rate> <freq> <millesecs>" so "pcm_tone /dev/pcm0 48 1000 500" to play a 1kHz tone using 48 
sampling for 500ms. Looks like there are similar functions "out there" I could reference.

You cannot open or access any audio driver from an application. It is type struct audio_ops_s.  That cannot be opened.  Only character devices can be opened (or block and MTD devices which have a character device proxy later.  In order to open any charter driver, it must export a struct file_operations which the class D driver does not.

But you can add a character driver proxy similar to tone.c that will allow you do do exactly what you want

Reply via email to