A simple enough task you would think. How do I play a wav file from the command line?
aplay myfile.wav returns the following
aplay: Playing ‘myfile.wav’:Signed 16 bit Little Endian
buffer_bytes = (1024,1024) omin=0 omax=0 int=1 empty=0
period_bytes = (128,128) omin=0 omax=0 int=1 empty=0
cannot prepare channel: errno =-22
Aplay:Failed in pcm_prepare
Note I only want to do this from CLI. I am NOT a software developer, I’m just trying to check out some magoh red boards before sending them off to my software developer.
Our final objective is to play audio from out custom linux application (won’t be using legato platform)
cm info all
Device: WP7607
IMEI: 359779080143064
IMEISV: 5
FSN: VN851171271310
Firmware Version: SWI9X07Y_02.18.05.00 000000 jenkins 2018/07/19 17:40:21
Bootloader Version: SWI9X07Y_02.18.05.00 000000 jenkins 2018/07/19 17:40:21
MCU Version: 002.009
PRI Part Number (PN): 9908767
PRI Revision: 001.001
Carrier PRI Name: GENERIC
Carrier PRI Revision: 002.041_000
SKU: 1104218
Last Reset Cause: Power Down
Resets Count: Expected: 15 Unexpected: 0
Strangely enough, I tried the AT!AVAUDIO method and it played the file. I then tried again using aplay and it worked. This is consistent: aplay will only work if I microcom to /dev/ttyAT and use the AT!AVAUDIO command.
The amix commands don’t work, they just report “control not found”
This helps me to test the hardware - but it is obviously going to make things messy to play audio files from a custom Linux program. So what exactly is the missing part here, what did the AT command do exactly to make it work?
Or, to put it another way, what is the correct procedure to play audio from a custom Linux application?
Yes I know that, but I would like to know what is the AT command doing that makes it work?
We may not be only playing files (e.g. using a text-to-speech library) so may want to output to the sound device directly. Also, we will need to control the mixer settings to allow separate left/right balance.
Also, I plan to use a different codec IC. How would that affect the operation of the built-in AT command for playing / volume adjustment?
Didn’t you say “aplay will only work if I microcom to /dev/ttyAT and use the AT!AVAUDIO command”?
You can play a dummy file after power on.
After that you can use aplay.
I know, but that really is a bodge. I would like to know WHY, so I can make sure that it will always work, in all circumstances and preferably for future revisions of hardware & firmware. It’s asking for trouble relying on some obscure undocumented artifact of a some function.
I also need the mixer to set left & right volume but that doesn’t seem to work either.
This will be used for a commercial product, so I need a consistent & reliable operation.
There is something seriously half-assed about this software platform. amix before & after yeilds exactly the same (which incidentally exposes something else broken - the redirect > doesn’t work so I had to use PuTTY logging to capture the output), I won’t post the output here as it’s 1600 lines ling.
This is what I enter from the cmd line
root@swi-mdm9x28-wp:~# aplay ready.wav
aplay: Playing 'ready.wav':Signed 16 bit Little Endian
buffer_bytes = (1024,1024) omin=0 omax=0 int=1 empty=0
period_bytes = (128,128) omin=0 omax=0 int=1 empty=0
cannot prepare channel: errno =-22
Aplay:Failed in pcm_prepare
microcom /dev/ttyAT
AT!AVAUDIO=1,1,/home/root/ready.wav
OK
<CTRL-AX to quit>
root@swi-mdm9x28-wp:~# aplay ready.wav
aplay: Playing 'ready.wav':Signed 16 bit Little Endian
buffer_bytes = (1024,1024) omin=0 omax=0 int=1 empty=0
period_bytes = (128,128) omin=0 omax=0 int=1 empty=0
Aplay: Done playing
So in the absence of anything helpful, let’s start with the error message. What does errno -22 mean?
Maybe this will help: this is the output from dmesg after each stage:
aplay attempt - fail
[ 105.398240] MDM Media1: ASoC: no backend DAIs enabled for MDM Media1
[ 105.402660] q6asm_callback: cmd = 0x10bcd returned error = 0x1
[ 105.402741] __q6asm_cmd: DSP returned error[ADSP_EFAILED] opcode 68557
[ 105.398240] MDM Media1: ASoC: no backend DAIs enabled for MDM Media1
[ 105.402660] q6asm_callback: cmd = 0x10bcd returned error = 0x1
[ 105.402741] __q6asm_cmd: DSP returned error[ADSP_EFAILED] opcode 68557
[ 121.121063] sierra_startup_monitor
[ 150.685702] MDM Media1: ASoC: no backend DAIs enabled for MDM Media1
[ 150.689626] q6asm_callback: cmd = 0x10bcd returned error = 0x1
[ 150.689710] __q6asm_cmd: DSP returned error[ADSP_EFAILED] opcode 68557
AT command play - works
[ 194.027962] afe_send_custom_topology_block: AFE SVC cal has invalid size: 0!
[ 194.027990] afe_send_custom_topology: No cal sent for cal_index 7! ret -22
[ 194.028006] afe_get_cal_topology_id: [AFE_TOPOLOGY_CAL] not initialized for this port 4096
[ 194.046531] q6asm_callback: cmd = 0x10da1 returned error = 0x3
[ 194.046615] q6asm_send_cal: DSP returned error[3] audio audstrm cal send
[ 194.054185] adm_callback: cmd = 0x10328 returned error = 0x3
[ 194.054257] send_adm_cal_block: DSP returned error[ADSP_EUNSUPPORTED]
[ 194.614128] aplay (1773) used greatest stack depth: 4520 bytes left
aplay command - works
[ 234.309229] afe_get_cal_topology_id: [AFE_TOPOLOGY_CAL] not initialized for this port 4096
[ 234.321106] q6asm_callback: cmd = 0x10da1 returned error = 0x3
[ 234.321169] q6asm_send_cal: DSP returned error[3] audio audstrm cal send
[ 234.325585] adm_callback: cmd = 0x10328 returned error = 0x3
[ 234.325637] send_adm_cal_block: DSP returned error[ADSP_EUNSUPPORTED]
AT Command playback works. I do not want to use AT commands for my application use case. I need to read and write samples from/to mic locally for a VoIP application.