libnx v4.10.0
Loading...
Searching...
No Matches
audout.h
Go to the documentation of this file.
1/**
2 * @file audout.h
3 * @brief Audio output service.
4 * @author hexkyz, TotalJustice
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#define AUDOUT_MAX_DELAY (1000000000ULL)
14
15typedef enum {
16 AudioOutState_Started = 0,
17 AudioOutState_Stopped = 1,
18} AudioOutState;
19
20/// Audio output buffer format
21typedef struct AudioOutBuffer AudioOutBuffer;
22
24{
25 AudioOutBuffer* next; ///< Next buffer. (Unused)
26 void* buffer; ///< Sample buffer (aligned to 0x1000 bytes).
27 u64 buffer_size; ///< Sample buffer size (aligned to 0x1000 bytes).
28 u64 data_size; ///< Size of data inside the buffer.
29 u64 data_offset; ///< Offset of data inside the buffer. (Unused?)
30};
31
32/// Initialize audout.
34
35/// Exit audout.
36void audoutExit(void);
37
38/// Initialize audout:a. Removed in [11.0.0].
40
41/// Exit audout:a.
42void audoutaExit(void);
43
44/// Initialize audout:d. Removed in [11.0.0].
46
47/// Exit audout:d.
48void audoutdExit(void);
49
50/// Gets the Service object for the actual audout service session.
52
53/// Gets the Service object for IAudioOut.
55
56/// Gets the Service for audout:a.
58
59/// Gets the Service for audout:d.
61
62Result audoutListAudioOuts(char *DeviceNames, s32 count, u32 *DeviceNamesCount);
63Result audoutOpenAudioOut(const char *DeviceNameIn, char *DeviceNameOut, u32 SampleRateIn, u32 ChannelCountIn, u32 *SampleRateOut, u32 *ChannelCountOut, PcmFormat *Format, AudioOutState *State);
64Result audoutGetAudioOutState(AudioOutState *State);
65Result audoutStartAudioOut(void);
66Result audoutStopAudioOut(void);
67
68/// Submits an \ref AudioOutBuffer for playing.
70
71Result audoutGetReleasedAudioOutBuffer(AudioOutBuffer **Buffer, u32 *ReleasedBuffersCount);
72Result audoutContainsAudioOutBuffer(AudioOutBuffer *Buffer, bool *ContainsBuffer);
73
74/// Only available with [4.0.0+].
76/// Only available with [4.0.0+].
78/// Only available with [4.0.0+].
80/// Only available with [6.0.0+].
82/// Only available with [6.0.0+].
84
85/**
86 * @brief Submits an audio sample data buffer for playing and waits for it to finish playing.
87 * @brief Uses \ref audoutAppendAudioOutBuffer and \ref audoutWaitPlayFinish internally.
88 * @param source AudioOutBuffer containing the source sample data to be played.
89 * @param released AudioOutBuffer to receive the played buffer after being released.
90 */
92
93/**
94 * @brief Waits for audio playback to finish.
95 * @param released AudioOutBuffer to receive the first played buffer after being released.
96 * @param released_count Pointer to receive the number of played buffers.
97 * @param timeout Timeout value, use UINT64_MAX to wait until all finished.
98 */
99Result audoutWaitPlayFinish(AudioOutBuffer **released, u32* released_count, u64 timeout);
100
101/// These return the state associated with the currently active audio output device.
102u32 audoutGetSampleRate(void); ///< Supported sample rate (48000Hz).
103u32 audoutGetChannelCount(void); ///< Supported channel count (2 channels).
104PcmFormat audoutGetPcmFormat(void); ///< Supported PCM format (Int16).
105AudioOutState audoutGetDeviceState(void); ///< Initial device state (stopped).
106
107Result audoutaRequestSuspend(u64 pid, u64 delay); // [4.0.0+]
108Result audoutaRequestResume(u64 pid, u64 delay); // [4.0.0+]
109Result audoutaGetProcessMasterVolume(u64 pid, float* volume_out);
110Result audoutaSetProcessMasterVolume(u64 pid, u64 delay, float volume);
111Result audoutaGetProcessRecordVolume(u64 pid, float* volume_out); // [4.0.0+]
112Result audoutaSetProcessRecordVolume(u64 pid, u64 delay, float volume); // [4.0.0+]
113
114Result audoutdRequestSuspendForDebug(u64 pid, u64 delay);
115Result audoutdRequestResumeForDebug(u64 pid, u64 delay);
PcmFormat
PcmFormat.
Definition audio.h:12
Service * audoutGetServiceSession_AudioOut(void)
Gets the Service object for IAudioOut.
void audoutExit(void)
Exit audout.
PcmFormat audoutGetPcmFormat(void)
Supported PCM format (Int16).
Result audoutAppendAudioOutBuffer(AudioOutBuffer *Buffer)
Submits an AudioOutBuffer for playing.
Service * audoutaGetServiceSession(void)
Gets the Service for audout:a.
Result audoutSetAudioOutVolume(float volume)
Only available with [6.0.0+].
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 audoutdInitialize(void)
Initialize audout:d. Removed in [11.0.0].
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+].
void audoutdExit(void)
Exit audout:d.
Service * audoutdGetServiceSession(void)
Gets the Service for audout:d.
Service * audoutGetServiceSession(void)
Gets the Service object for the actual audout service session.
Result audoutaInitialize(void)
Initialize audout:a. Removed in [11.0.0].
Result audoutGetAudioOutBufferCount(u32 *count)
Only available with [4.0.0+].
void audoutaExit(void)
Exit audout:a.
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:24
u64 buffer_size
Sample buffer size (aligned to 0x1000 bytes).
Definition audout.h:27
u64 data_offset
Offset of data inside the buffer. (Unused?)
Definition audout.h:29
AudioOutBuffer * next
Next buffer. (Unused)
Definition audout.h:25
u64 data_size
Size of data inside the buffer.
Definition audout.h:28
void * buffer
Sample buffer (aligned to 0x1000 bytes).
Definition audout.h:26
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