libnx  v4.7.0
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 "../types.h"
10 #include "../audio/audio.h"
11 #include "../sf/service.h"
12 
13 typedef enum {
14  AudioOutState_Started = 0,
15  AudioOutState_Stopped = 1,
16 } AudioOutState;
17 
18 /// Audio output buffer format
19 typedef struct AudioOutBuffer AudioOutBuffer;
20 
22 {
23  AudioOutBuffer* next; ///< Next buffer. (Unused)
24  void* buffer; ///< Sample buffer (aligned to 0x1000 bytes).
25  u64 buffer_size; ///< Sample buffer size (aligned to 0x1000 bytes).
26  u64 data_size; ///< Size of data inside the buffer.
27  u64 data_offset; ///< Offset of data inside the buffer. (Unused?)
28 };
29 
30 /// Initialize audout.
32 
33 /// Exit audout.
34 void audoutExit(void);
35 
36 /// Gets the Service object for the actual audout service session.
38 
39 /// Gets the Service object for IAudioOut.
41 
42 Result audoutListAudioOuts(char *DeviceNames, s32 count, u32 *DeviceNamesCount);
43 Result audoutOpenAudioOut(const char *DeviceNameIn, char *DeviceNameOut, u32 SampleRateIn, u32 ChannelCountIn, u32 *SampleRateOut, u32 *ChannelCountOut, PcmFormat *Format, AudioOutState *State);
44 Result audoutGetAudioOutState(AudioOutState *State);
45 Result audoutStartAudioOut(void);
46 Result audoutStopAudioOut(void);
47 
48 /// Submits an \ref AudioOutBuffer for playing.
50 
51 Result audoutGetReleasedAudioOutBuffer(AudioOutBuffer **Buffer, u32 *ReleasedBuffersCount);
52 Result audoutContainsAudioOutBuffer(AudioOutBuffer *Buffer, bool *ContainsBuffer);
53 
54 /// Only available with [4.0.0+].
56 /// Only available with [4.0.0+].
58 /// Only available with [4.0.0+].
60 /// Only available with [6.0.0+].
62 /// Only available with [6.0.0+].
64 
65 /**
66  * @brief Submits an audio sample data buffer for playing and waits for it to finish playing.
67  * @brief Uses \ref audoutAppendAudioOutBuffer and \ref audoutWaitPlayFinish internally.
68  * @param source AudioOutBuffer containing the source sample data to be played.
69  * @param released AudioOutBuffer to receive the played buffer after being released.
70  */
72 
73 /**
74  * @brief Waits for audio playback to finish.
75  * @param released AudioOutBuffer to receive the first played buffer after being released.
76  * @param released_count Pointer to receive the number of played buffers.
77  * @param timeout Timeout value, use UINT64_MAX to wait until all finished.
78  */
79 Result audoutWaitPlayFinish(AudioOutBuffer **released, u32* released_count, u64 timeout);
80 
81 /// These return the state associated with the currently active audio output device.
82 u32 audoutGetSampleRate(void); ///< Supported sample rate (48000Hz).
83 u32 audoutGetChannelCount(void); ///< Supported channel count (2 channels).
84 PcmFormat audoutGetPcmFormat(void); ///< Supported PCM format (Int16).
85 AudioOutState audoutGetDeviceState(void); ///< Initial device state (stopped).
PcmFormat
PcmFormat.
Definition: audio.h:12
void audoutExit(void)
Exit audout.
PcmFormat audoutGetPcmFormat(void)
Supported PCM format (Int16).
Result audoutAppendAudioOutBuffer(AudioOutBuffer *Buffer)
Submits an AudioOutBuffer for playing.
Result audoutSetAudioOutVolume(float volume)
Only available with [6.0.0+].
Service * audoutGetServiceSession_AudioOut(void)
Gets the Service object for IAudioOut.
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.
Result audoutPlayBuffer(AudioOutBuffer *source, AudioOutBuffer **released)
Submits an audio sample data buffer for playing and waits for it to finish playing.
Result audoutInitialize(void)
Initialize audout.
u32 audoutGetChannelCount(void)
Supported channel count (2 channels).
Result audoutGetAudioOutPlayedSampleCount(u64 *count)
Only available with [4.0.0+].
Result audoutGetAudioOutBufferCount(u32 *count)
Only available with [4.0.0+].
Service * audoutGetServiceSession(void)
Gets the Service object for the actual audout service session.
Result audoutGetAudioOutVolume(float *volume)
Only available with [6.0.0+].
Result audoutFlushAudioOutBuffers(bool *flushed)
Only available with [4.0.0+].
AudioOutState audoutGetDeviceState(void)
Initial device state (stopped).
Audio output buffer format.
Definition: audout.h:22
u64 buffer_size
Sample buffer size (aligned to 0x1000 bytes).
Definition: audout.h:25
u64 data_offset
Offset of data inside the buffer. (Unused?)
Definition: audout.h:27
AudioOutBuffer * next
Next buffer. (Unused)
Definition: audout.h:23
u64 data_size
Size of data inside the buffer.
Definition: audout.h:26
void * buffer
Sample buffer (aligned to 0x1000 bytes).
Definition: audout.h:24
Service object structure.
Definition: service.h:14
uint64_t u64
64-bit unsigned integer.
Definition: types.h:22
u32 Result
Function error code result type.
Definition: types.h:44
int32_t s32
32-bit signed integer.
Definition: types.h:27
uint32_t u32
32-bit unsigned integer.
Definition: types.h:21