Files
RetroArch/samples/audio/switch_audren/malloc.h
LibretroAdmin d16f0c5122 switch_audren: the renderer stays on the writer's thread, without a lock
libnx's audrv is not thread-safe, and write_avail() was the one call
the frontend made from another thread - rate control's fill, every
frame, while the audio thread wrapper writes - which is what the mutex
around every renderer call was for, an audrvUpdate() service call
included. The writer now publishes the room in an atomic after every
append and update, and write_avail() from any thread but the writer's
reads that instead of calling into the renderer; on the writer's own
thread, the frontend writing without the wrapper, it updates as
before. Write, wait_writable, start and stop record their thread. A
non-blocking write that finds no free buffer updates once and takes
what that frees, as the update write_avail() made before every write
used to, and goes on filling while buffers are free.

samples/audio/switch_audren runs the driver's libnx build against a
stand-in <switch.h> whose renderer thread plays a wave buffer a frame:
every renderer call comes from the writer while another thread reads
write_avail(), a write_avail() on the writer's thread sees what played,
non-blocking writes keep taking audio, stop and start pause and resume
the voice. It builds with MinGW as well, and runs in CI plain, under
ASan and UBSan, and under TSan.
2026-10-08 09:04:12 +02:00

17 lines
486 B
C

/* <malloc.h> for the driver's memalign(): the host's own, and on
* Windows, where there is none, a plain allocation the driver's free()
* can release - the stand-in renderer reads the pool, the alignment is
* the console's. */
#ifndef SWITCH_AUDREN_MOCK_MALLOC_H
#define SWITCH_AUDREN_MOCK_MALLOC_H
#include_next <malloc.h>
#ifdef _WIN32
#include <stdlib.h>
static __inline void *memalign(size_t alignment, size_t size)
{
(void)alignment;
return malloc(size);
}
#endif
#endif