I have created an application using audioService.le_audio in Legato to play audio from a file. However, sometimes after waking up from system suspend mode, I encounter the following error:
Legato: =ERR= | audioDaemon[2958]/alsa_intf T=main | pa_pcm_alsa.c InitPcmPlaybackCapture() 471 | PCM is not ready (pcm error: )
Legato: =ERR= | audioDaemon[2958]/audio T=main | le_media.c le_media_PlaySamples() 1919 | PCM cannot be open
Legato: =ERR= | audioDaemon[2958] | cannot open device '/dev/snd/pcmC0D0p', errno 16
When I get this error, the sound file does not play. When I check with ‘fuser’ for ‘/dev/snd/pcmC0D0p’, I see that it is in use. Manually restarting the app with ‘audioService’ resolves the issue. Why is this happening, and how can I fix it in source code?
It is being used by audioDaemon. I am able to play the audio file. However, sometimes I encounter this error. If I don’t fix it, the audio file won’t play.
Legato: =ERR= | audioDaemon[2958]/alsa_intf T=main | pa_pcm_alsa.c InitPcmPlaybackCapture() 471 | PCM is not ready (pcm error: )
Legato: =ERR= | audioDaemon[2958]/audio T=main | le_media.c le_media_PlaySamples() 1919 | PCM cannot be open
Legato: =ERR= | audioDaemon[2958] | cannot open device '/dev/snd/pcmC0D0p', errno 16
This error repeats every time I play an audio file because the /dev/snd/pcmC0D0p is busy or already opened.
I am not yet familiar with how the system goes into suspend. However, I believe it does not enter suspend mode before the audio file finishes. I think this situation occurs when the system wakes up.
Okay, I will try this. In the meantime, I am leaving a log for the entire process. The error repeats after this point. The starting point is ‘Cannot set hw params’.
root@swi-mdm9x28-wp:~# logread -f | grep pcm
Nov 29 08:46:25 user.info Legato: INFO | AppExe[2907] | The device /dev/snd/pcmC0D0p is not in use.
Nov 29 08:56:25 user.info Legato: INFO | AppExe[2907] | The device /dev/snd/pcmC0D0p is not in use.
Nov 29 08:56:25 user.err Legato: =ERR= | audioDaemon[2935]/alsa_intf T=main | pa_pcm_alsa.c SetPcmParamsPlayback() 162 | Cannot set hw params
Nov 29 08:56:25 user.err Legato: =ERR= | audioDaemon[2935]/alsa_intf T=main | pa_pcm_alsa.c InitPcmPlaybackCapture() 464 | Failed in set_params
Nov 29 08:57:25 user.info Legato: INFO | AppExe[2907] | The device /dev/snd/pcmC0D0p is in use. PID: 2935
Nov 29 08:57:26 user.err Legato: =ERR= | audioDaemon[2935]/alsa_intf T=main | pa_pcm_alsa.c InitPcmPlaybackCapture() 471 | PCM is not ready (pcm error: )
Nov 29 08:57:26 user.err Legato: =ERR= | audioDaemon[2935] | cannot open device '/dev/snd/pcmC0D0p', errno 16
Nov 29 08:57:42 user.info Legato: INFO | AppExe[2907] | The device /dev/snd/pcmC0D0p is in use. PID: 2935
Nov 29 08:57:43 user.err Legato: =ERR= | audioDaemon[2935]/alsa_intf T=main | pa_pcm_alsa.c InitPcmPlaybackCapture() 471 | PCM is not ready (pcm error: )
Nov 29 08:57:43 user.err Legato: =ERR= | audioDaemon[2935] | cannot open device '/dev/snd/pcmC0D0p', errno 16
Audio connections (le_audio_CreateConnector, le_audio_OpenPlayer and le_audio_OpenSpeaker) are established, and then the file starts playing. After the audio playback is finished, all audio connections are closed, and it goes into suspend mode. When i want to play again, these connections are re-established, the file plays, connections are closed again, and it goes into suspend mode. This process repeats.
If I do this within the code, the application stops. The application uses the le_audio API, and stopping it because of using it. How can I release this pcm? Also, The main reason is ‘Cannot set hw params’. I need to solve this issue without stop App.
i guess probably this is because some audio close routine has not been run completely.
You might need to keep module wake up before closing audio routine.
Another workaround is that you can start a new unsandboxed application to specifically do audio play.
Then there is no problem to restart this standalone application.
When you need to play audio, you can “app restart audioService”, and then use script to call this standalone application to play audio