libnx
audout.h
Go to the documentation of this file.
1 /**
2  * @file audout.h
3  * @brief Audio output service.
4  * @author hexkyz
5  * @copyright libnx Authors
6  */
7 #pragma once
8 
9 #include "../audio/audio.h"
10 
11 typedef enum {
12  AudioOutState_Started = 0,
13  AudioOutState_Stopped = 1,
14 } AudioOutState;
15 
16 /// Audio output buffer format
17 typedef struct AudioOutBuffer AudioOutBuffer;
18 
20 {
21  AudioOutBuffer* next; ///< Next buffer. (Unused)
22  void* buffer; ///< Sample buffer (aligned to 0x1000 bytes).
23  u64 buffer_size; ///< Sample buffer size (aligned to 0x1000 bytes).
24  u64 data_size; ///< Size of data inside the buffer.
25  u64 data_offset; ///< Offset of data inside the buffer. (Unused?)
26 };
27 
28 Result audoutInitialize(void);
29 void audoutExit(void);
30 
31 Result audoutListAudioOuts(char *DeviceNames, u32 *DeviceNamesCount);
32 Result audoutOpenAudioOut(const char *DeviceNameIn, char *DeviceNameOut, u32 SampleRateIn, u32 ChannelCountIn, u32 *SampleRateOut, u32 *ChannelCountOut, PcmFormat *Format, AudioOutState *State);
33 Result audoutGetAudioOutState(AudioOutState *State);
34 Result audoutStartAudioOut(void);
35 Result audoutStopAudioOut(void);
36 Result audoutAppendAudioOutBuffer(AudioOutBuffer *Buffer);
37 Result audoutGetReleasedAudioOutBuffer(AudioOutBuffer **Buffer, u32 *ReleasedBuffersCount);
38 Result audoutContainsAudioOutBuffer(AudioOutBuffer *Buffer, bool *ContainsBuffer);
39 
40 /**
41  * @brief Submits an audio sample data buffer for playing and waits for it to finish playing.
42  * @brief Uses \ref audoutAppendAudioOutBuffer and \ref audoutWaitPlayFinish internally.
43  * @param source AudioOutBuffer containing the source sample data to be played.
44  * @param released AudioOutBuffer to receive the played buffer after being released.
45  */
47 
48 /**
49  * @brief Waits for audio playback to finish.
50  * @param released AudioOutBuffer to receive the first played buffer after being released.
51  * @param released_count Pointer to receive the number of played buffers.
52  * @param timeout Timeout value, use U64_MAX to wait until all finished.
53  */
54 Result audoutWaitPlayFinish(AudioOutBuffer **released, u32* released_count, u64 timeout);
55 
56 /// These return the state associated with the currently active audio output device.
57 u32 audoutGetSampleRate(void); ///< Supported sample rate (48000Hz).
58 u32 audoutGetChannelCount(void); ///< Supported channel count (2 channels).
59 PcmFormat audoutGetPcmFormat(void); ///< Supported PCM format (Int16).
60 AudioOutState audoutGetDeviceState(void); ///< Initial device state (stopped).
u32 audoutGetSampleRate(void)
These return the state associated with the currently active audio output device.
Result audoutWaitPlayFinish(AudioOutBuffer **released, u32 *released_count, u64 timeout)
Waits for audio playback to finish.
u32 audoutGetChannelCount(void)
Supported channel count (2 channels).
AudioOutBuffer * next
Next buffer. (Unused)
Definition: audout.h:21
u64 data_size
Size of data inside the buffer.
Definition: audout.h:24
u32 Result
Function error code result type.
Definition: types.h:46
uint64_t u64
64-bit unsigned integer.
Definition: types.h:24
uint32_t u32
32-bit unsigned integer.
Definition: types.h:23
u64 data_offset
Offset of data inside the buffer. (Unused?)
Definition: audout.h:25
AudioOutState audoutGetDeviceState(void)
Initial device state (stopped).
Audio output buffer format.
Definition: audout.h:19
Result audoutPlayBuffer(AudioOutBuffer *source, AudioOutBuffer **released)
Submits an audio sample data buffer for playing and waits for it to finish playing.
void * buffer
Sample buffer (aligned to 0x1000 bytes).
Definition: audout.h:22
PcmFormat audoutGetPcmFormat(void)
Supported PCM format (Int16).
u64 buffer_size
Sample buffer size (aligned to 0x1000 bytes).
Definition: audout.h:23