libnx  v4.8.0
audin.h
Go to the documentation of this file.
1 /**
2  * @file audin.h
3  * @brief Audio input 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  AudioInState_Started = 0,
15  AudioInState_Stopped = 1,
16 } AudioInState;
17 
18 /// Audio input buffer format
19 typedef struct AudioInBuffer AudioInBuffer;
20 
22 {
23  AudioInBuffer* 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 audin.
32 
33 /// Exit audin.
34 void audinExit(void);
35 
36 /// Gets the Service object for the actual audin service session.
38 
39 /// Gets the Service object for IAudioIn.
41 
42 Result audinListAudioIns(char *DeviceNames, s32 count, u32 *DeviceNamesCount);
43 Result audinOpenAudioIn(const char *DeviceNameIn, char *DeviceNameOut, u32 SampleRateIn, u32 ChannelCountIn, u32 *SampleRateOut, u32 *ChannelCountOut, PcmFormat *Format, AudioInState *State);
44 Result audinGetAudioInState(AudioInState *State);
45 Result audinStartAudioIn(void);
46 Result audinStopAudioIn(void);
47 
48 /// Submits an \ref AudioInBuffer for capturing.
50 
51 Result audinGetReleasedAudioInBuffer(AudioInBuffer **Buffer, u32 *ReleasedBuffersCount);
52 Result audinContainsAudioInBuffer(AudioInBuffer *Buffer, bool *ContainsBuffer);
53 
54 /**
55  * @brief Submits an audio sample data buffer for capturing and waits for it to finish capturing.
56  * @brief Uses \ref audinAppendAudioInBuffer and \ref audinWaitCaptureFinish internally.
57  * @param source AudioInBuffer containing the buffer to hold the captured sample data.
58  * @param released AudioInBuffer to receive the captured buffer after being released.
59  */
61 
62 /**
63  * @brief Waits for audio capture to finish.
64  * @param released AudioInBuffer to receive the first captured buffer after being released.
65  * @param released_count Pointer to receive the number of captured buffers.
66  * @param timeout Timeout value, use UINT64_MAX to wait until all finished.
67  */
68 Result audinWaitCaptureFinish(AudioInBuffer **released, u32* released_count, u64 timeout);
69 
70 /// These return the state associated with the currently active audio input device.
71 u32 audinGetSampleRate(void); ///< Supported sample rate (48000Hz).
72 u32 audinGetChannelCount(void); ///< Supported channel count (2 channels).
73 PcmFormat audinGetPcmFormat(void); ///< Supported PCM format (Int16).
74 AudioInState audinGetDeviceState(void); ///< Initial device state (stopped).
Result audinInitialize(void)
Initialize audin.
u32 audinGetSampleRate(void)
These return the state associated with the currently active audio input device.
Service * audinGetServiceSession_AudioIn(void)
Gets the Service object for IAudioIn.
Result audinWaitCaptureFinish(AudioInBuffer **released, u32 *released_count, u64 timeout)
Waits for audio capture to finish.
Result audinAppendAudioInBuffer(AudioInBuffer *Buffer)
Submits an AudioInBuffer for capturing.
void audinExit(void)
Exit audin.
Result audinCaptureBuffer(AudioInBuffer *source, AudioInBuffer **released)
Submits an audio sample data buffer for capturing and waits for it to finish capturing.
PcmFormat audinGetPcmFormat(void)
Supported PCM format (Int16).
u32 audinGetChannelCount(void)
Supported channel count (2 channels).
AudioInState audinGetDeviceState(void)
Initial device state (stopped).
Service * audinGetServiceSession(void)
Gets the Service object for the actual audin service session.
PcmFormat
PcmFormat.
Definition: audio.h:12
Audio input buffer format.
Definition: audin.h:22
AudioInBuffer * next
Next buffer. (Unused)
Definition: audin.h:23
u64 data_size
Size of data inside the buffer.
Definition: audin.h:26
u64 buffer_size
Sample buffer size (aligned to 0x1000 bytes).
Definition: audin.h:25
u64 data_offset
Offset of data inside the buffer. (Unused?)
Definition: audin.h:27
void * buffer
Sample buffer (aligned to 0x1000 bytes).
Definition: audin.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