Files
RetroArch/samples/audio/switch_audio/switch.h
LibretroAdmin 46e6cd3631 switch_audio: write_avail and buffer_size count every queued buffer
The driver takes back the buffers the service has released without
waiting, so write_avail is those buffers plus the rest of the one
being filled, and buffer_size every buffer carrying its chunk. A
buffer is appended once it holds its chunk: the latency setting in
bytes, spread across the buffers. A write fills buffers in turn until
its audio is taken or none is free, which is what write_avail
reported. The unused thread, mutex and condvar shims and the append
timestamp go.

samples/audio/switch_audio runs the libnx build against a stand-in
<switch.h> whose audout service plays buffers out on the test's word,
and checks every write takes exactly the room reported.
2026-10-02 12:58:15 +02:00

38 lines
1.0 KiB
C

/* A stand-in <switch.h>: the libnx audout surface
* audio/drivers/switch_audio.c uses, so the driver builds and runs on
* the host. audout_mock.c is the service: a queue of appended buffers
* that plays out, oldest first, when the test says so. */
#ifndef SWITCH_AUDIO_MOCK_SWITCH_H
#define SWITCH_AUDIO_MOCK_SWITCH_H
#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
typedef uint32_t u32;
typedef uint64_t u64;
typedef int64_t s64;
typedef u32 Result;
typedef struct AudioOutBuffer AudioOutBuffer;
struct AudioOutBuffer
{
AudioOutBuffer *next;
void *buffer;
u64 buffer_size;
u64 data_size;
u64 data_offset;
};
Result audoutInitialize(void);
void audoutExit(void);
Result audoutStartAudioOut(void);
Result audoutStopAudioOut(void);
Result audoutAppendAudioOutBuffer(AudioOutBuffer *buffer);
Result audoutGetReleasedAudioOutBuffer(AudioOutBuffer **buffer, u32 *released_count);
Result audoutWaitPlayFinish(AudioOutBuffer **released, u32 *released_count, u64 timeout);
u32 audoutGetSampleRate(void);
#endif