blues-fun opened a new pull request, #4052: URL: https://github.com/apache/nuttx-apps/pull/4052
*Note: Please adhere to [Contributing Guidelines](https://github.com/apache/nuttx/blob/master/CONTRIBUTING.md).* ## Summary * Why change is necessary: kernel #21741 widened `ac_chmap` in `struct audio_caps_s` to `uint32_t` so devices with more than eight channels (microphone arrays) can be described. The three tools still narrow `chmap` to `uint8_t` at their API and parse the command-line value with a decimal-only parser, so a 32-bit channel map is silently truncated and hex notation is not accepted. * What functional part of the code is being changed: `include/system/nxplayer.h`, `nxrecorder.h`, `nxlooper.h` and the corresponding `system/nxplayer`, `system/nxrecorder`, `system/nxlooper` sources. * How the change exactly work: * The `chmap` parameter of `nxplayer_playraw()`, `nxrecorder_recordinternal()` and `nxlooper_loopback()` is widened from `uint8_t` to `uint32_t`; internal helpers follow. * The `playraw`, `record`, `recordraw` and `loopback` commands parse `chmap` with `strtoul()` instead, so hex values such as `0x80000003` are accepted and no longer collapse to 0 as with the old parser. * The value is passed unchanged into `cap_desc.caps.ac_chmap`, which is `uint32_t` after #21741. Commits (4): * system/nxplayer: support 32-bit chmap * system/nxrecorder: support 32-bit chmap * system/nxlooper: support 32-bit chmap * system/nxplayer, system/nxlooper: fix nxstyle errors (The last commit braces the one-line if/else branches in the nxplayer mediadir command and adds the blank lines after declarations in nxlooper that nxstyle requires; checkpatch checks touched files as a whole. It is kept separate so the functional commits stay reviewable on their own.) ## Impact * Is new feature added? Is existing feature changed? YES -- chmap parameters widened to 32 bits and hex parsing added. * Impact on user (will user need to adapt to change)? NO for existing callers: widening a parameter is source compatible and a 8-bit map value keeps its meaning. Applications that include the headers must rebuild (ABI of the three functions changes). * Impact on build (will build process change)? NO. * Impact on hardware (will arch(s) / board(s) / driver(s) change)? NO. * Impact on documentation (is update required / provided)? NO -- command syntax is unchanged, only more values are accepted. * Impact on security (any sort of implications)? NO. * Impact on compatibility (backward/forward/interoperability)? YES, narrowly: it is the apps-side counterpart of kernel #21741 (merged 11-13). Against a kernel without #21741 the upper bits would be dropped by the kernel `uint8_t ac_chmap`; against current master both sides are 32 bits. ## 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:alsa with CONFIG_AUDIO_FAKE, 64-bit (SIM_M32 off), built on apache master d9b891b2bea with this branch in nuttx-apps. Build and link clean; checkpatch passes. Hex chmap reaches the driver with both tools (in.pcm is 2ch/16bit/48kHz): 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/pcm0p nxplayer> playraw /host/in.pcm 2 16 48000 0x3 nxplayer> q nsh> 32-bit-only map (bit 31) accepted by recordraw, three seconds recorded clean, and the old decimal form still works for playraw: nsh> mount -t hostfs -o fs=/tmp/audio-test /host nsh> nxrecorder NxRecorder version 1.00 h for commands, q to exit nxrecorder> device /dev/audio/pcm0c nxrecorder> recordraw /host/out.pcm 2 16 48000 0x80000003 nxrecorder> stop nxrecorder> q nsh> nxplayer NxPlayer version 1.05 h for commands, q to exit nxplayer> device /dev/audio/pcm0p nxplayer> playraw /host/in.pcm 2 16 48000 3 nxplayer> q nsh> $ ls -la /tmp/audio-test/out.pcm -rw-rw-r-- 1 mi mi 565248 Nov 16 11:15 /tmp/audio-test/out.pcm nxlooper `loopback 0x5` parses and starts with a hex map as well. Before the change the command line read chmap with `sscanf("%d")`, which turned `0x3` into 0, so the hex form was not usable at all. Not tested: protected and kernel builds, other architectures, hardware with more than eight channels (no such device on hand; the 0x80000003 run only proves the bits are not truncated on the way to the driver). -- 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]
