blues-fun opened a new pull request, #21777: URL: https://github.com/apache/nuttx/pull/21777
*Note: Please adhere to [Contributing Guidelines](https://github.com/apache/nuttx/blob/master/CONTRIBUTING.md).* ## Summary * Why change is necessary: the pending codec libraries and the in-tree applications need a way to select LC3, Speex and SILK, to configure the Speex and Opus encoders with typed fields, and to receive driver events without creating a named message queue of their own. The audio_fake driver also crashes in stop() after its worker exits on its own, which breaks the test suite. * What functional part of the code is being changed: include/nuttx/audio/audio.h, the audio upper half (audio/audio.c), the audio_fake driver (drivers/audio/audio_fake.c) and Documentation/os/audio. * How the change exactly work: * AUDIO_FMT_LC3, AUDIO_FMT_SPEEX and AUDIO_FMT_SILK are appended to the format id list. The options union already described LC3 and Speex, but there was no id to select them, and none for the SILK speech codec. * audio_enc_spx_s and audio_enc_opus_s are added to union audio_codec_options_u, so Speex and Opus encoder settings are typed fields instead of a generic option string. The union does not grow. * AUDIOIOC_GETPARAMTER is the read counterpart of AUDIOIOC_SETPARAMTER and returns any driver parameter as a key=value string. * AUDIOIOC_REGISTERMQ accepts AUDIO_MQ_KERNEL: the upper half creates the queue for that open file and removes it on AUDIOIOC_UNREGISTERMQ or close(), so a library can drive the device through its file descriptor alone. Events are read with the new AUDIOIOC_RECEIVEMSG or with poll(). The application-supplied queue path is unchanged. * audio_fake: a worker that exits on its own (processing error, or the last buffer of a playback) closes its message queue on the way out, and the following stop() sent into the closed queue and crashed in nxmq_verify_send(). stop() now waits on an exit semaphore the worker posts as its last action, and skips the stop message when the worker is already gone, which also makes stop() safe to call twice. start() reaps a self-exited worker before reinitializing the device. ## Impact * Is new feature added? Is existing feature changed? YES — new format ids, encoder option structs, AUDIOIOC_GETPARAMTER, AUDIO_MQ_KERNEL/AUDIOIOC_RECEIVEMSG, and a crash fix in audio_fake. * Impact on user (will user need to adapt to change)? NO — all changes are additive; existing ids keep their values, the union size does not change, and the application-supplied queue path is unchanged. * Impact on build (will build process change)? NO. * Impact on hardware (will arch(s) / board(s) / driver(s) change)? NO — audio_fake changes are internal to the driver. * Impact on documentation (is update required / provided)? YES — provided in Documentation/os/audio. * Impact on security (any sort of implications)? NO. * Impact on compatibility (backward/forward/interoperability)? NO. ## Testing I confirm that changes are verified on local setup and works as intended: * Build Host(s): Linux x86_64, gcc (Ubuntu 13.4.0). * Target(s): sim with the audio_fake playback/capture devices; BES platform (Cortex-M55) hardware. * Steps to reproduce: mount a hostfs with a raw PCM file (2ch/16bit/48kHz), run nxplayer, `device /dev/audio/pcm2p`, `playraw <file> 2 16 48000 3`. Before the fix the session dumps core after the playback ends; with the fix it exits clean. Testing logs before change (upstream master): nsh> mount -t hostfs -o fs=/tmp/audio-test /host nsh> nxplayer NxPlayer version 1.05 h for commands, q to exit nxplayer> device /dev/audio/pcm2p nxplayer> playraw /host/in.pcm 2 16 48000 3 nxplayer> timeout: the monitored command dumped core Testing logs after change: nsh> mount -t hostfs -o fs=/tmp/audio-test /host nsh> nxplayer NxPlayer version 1.05 h for commands, q to exit nxplayer> device /dev/audio/pcm2p nxplayer> playraw /host/in.pcm 2 16 48000 3 nxplayer> q nsh> Also verified on sim: nxplayer playraw and nxrecorder recordraw run clean against the new upper half, and checkpatch passes. Tested on BES platform (Cortex-M55) hardware. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
