|
|
The PCM bufferThis page is part of an attempt to document the software codec playback code.GeneralThe PCM buffer contains raw PCM data to be (or being) sent to the audio output. The codecs allocate space in the buffer and puts the decoded audio in the allocated space. It has two auxiliary buffers, the crossfade and voice buffers, used for mixing.Regular PCM playbackYou can allocate space in the buffer for later playback by calling thepcmbuf_request_buffer() function. It will reserve space in the buffer which will later be queued for playback when you call the pcmbuf_write_complete() function.
Step 1 - allocate buffer spaceWhen you want to add a chunk of audio to the PCM buffer, you must first reserve the buffer space. Here's how the buffer may look before you begin. DirectedGraph Error (25):*DirectedGraphPlugin error:*You then reserve some space:$GV_FILE_PATH environment variable set; exiting 01: 02: This sandboxing mechanism is no longer supported 03: Problem executing /usr/bin/dot: '/usr/bin/dot /home/rockbox/foswiki/working/tmp/DiGraphPlugini4d2Jop3sC.dot -Tpng -o/home/rockbox/foswiki/working/tmp/DGPtDOiREDHnk.png 2> /home/rockbox/foswiki/working/tmp/DiGraphPlugini4d2Jop3sC.dot.err ', got: 04: /usr/bin/dot exited with rc=1 05: char *ptr; /* Pointer to the requested buffer */ size_t size; /* How many bytes I managed to reserve */ ptr = pcmbuf_request_buffer(0x2000, &size); /* The 'size' variable now holds the number of bytes reserved */ Step 2 - Fill with data and queue itYou have now reserved buffer space for your audio data, but the buffer is not yet added to the PCM queue for playback. It is now time to fill the buffer with PCM data. DirectedGraph Error (25):*DirectedGraphPlugin error:*You now fill the buffer with audio data and call$GV_FILE_PATH environment variable set; exiting 01: 02: This sandboxing mechanism is no longer supported 03: Problem executing /usr/bin/dot: '/usr/bin/dot /home/rockbox/foswiki/working/tmp/DiGraphPluginAd0aip4JbC.dot -Tpng -o/home/rockbox/foswiki/working/tmp/DGPZ0w9MEmmbQ.png 2> /home/rockbox/foswiki/working/tmp/DiGraphPluginAd0aip4JbC.dot.err ', got: 04: /usr/bin/dot exited with rc=1 05: pcmbuf_write_complete() to add the audio data to the PCM queue. In this example, I fill it with zeroes.
memset(ptr, 0, size); pcmbuf_write_complete(size); /* After this, the 'ptr' pointer is no longer valid */DirectedGraph Error (25): *DirectedGraphPlugin error:*$GV_FILE_PATH environment variable set; exiting 01: 02: This sandboxing mechanism is no longer supported 03: Problem executing /usr/bin/dot: '/usr/bin/dot /home/rockbox/foswiki/working/tmp/DiGraphPlugint0KRZOhNPI.dot -Tpng -o/home/rockbox/foswiki/working/tmp/DGPbwwN5B4Tr3.png 2> /home/rockbox/foswiki/working/tmp/DiGraphPlugint0KRZOhNPI.dot.err ', got: 04: /usr/bin/dot exited with rc=1 05: Special case 1 - crossfadecomingSpecial case 2 - voicecomingr16 - 29 Oct 2023 - 16:24:05 - AdminUser
Copyright © by the contributing authors.
|