libnx
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 "../audio/audio.h"
10 
11 typedef enum {
12  AudioInState_Started = 0,
13  AudioInState_Stopped = 1,
14 } AudioInState;
15 
16 /// Audio input buffer format
17 typedef struct AudioInBuffer AudioInBuffer;
18 
20 {
21  AudioInBuffer* 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 audinInitialize(void);
29 void audinExit(void);
30 
31 Result audinListAudioIns(char *DeviceNames, u32 *DeviceNamesCount);
32 Result audinOpenAudioIn(const char *DeviceNameIn, char *DeviceNameOut, u32 SampleRateIn, u32 ChannelCountIn, u32 *SampleRateOut, u32 *ChannelCountOut, PcmFormat *Format, AudioInState *State);
33 Result audinGetAudioInState(AudioInState *State);
34 Result audinStartAudioIn(void);
35 Result audinStopAudioIn(void);
36 Result audinAppendAudioInBuffer(AudioInBuffer *Buffer);
37 Result audinGetReleasedAudioInBuffer(AudioInBuffer **Buffer, u32 *ReleasedBuffersCount);
38 Result audinContainsAudioInBuffer(AudioInBuffer *Buffer, bool *ContainsBuffer);
39 
40 /**
41  * @brief Submits an audio sample data buffer for capturing and waits for it to finish capturing.
42  * @brief Uses \ref audinAppendAudioInBuffer and \ref audinWaitCaptureFinish internally.
43  * @param source AudioInBuffer containing the buffer to hold the captured sample data.
44  * @param released AudioInBuffer to receive the captured buffer after being released.
45  */
47 
48 /**
49  * @brief Waits for audio capture to finish.
50  * @param released AudioInBuffer to receive the first captured buffer after being released.
51  * @param released_count Pointer to receive the number of captured buffers.
52  * @param timeout Timeout value, use U64_MAX to wait until all finished.
53  */
54 Result audinWaitCaptureFinish(AudioInBuffer **released, u32* released_count, u64 timeout);
55 
56 /// These return the state associated with the currently active audio input device.
57 u32 audinGetSampleRate(void); ///< Supported sample rate (48000Hz).
58 u32 audinGetChannelCount(void); ///< Supported channel count (2 channels).
59 PcmFormat audinGetPcmFormat(void); ///< Supported PCM format (Int16).
60 AudioInState audinGetDeviceState(void); ///< Initial device state (stopped).
u64 buffer_size
Sample buffer size (aligned to 0x1000 bytes).
Definition: audin.h:23
Result audinCaptureBuffer(AudioInBuffer *source, AudioInBuffer **released)
Submits an audio sample data buffer for capturing and waits for it to finish capturing.
u32 Result
Function error code result type.
Definition: types.h:46
AudioInBuffer * next
Next buffer. (Unused)
Definition: audin.h:21
uint64_t u64
64-bit unsigned integer.
Definition: types.h:24
AudioInState audinGetDeviceState(void)
Initial device state (stopped).
uint32_t u32
32-bit unsigned integer.
Definition: types.h:23
Result audinWaitCaptureFinish(AudioInBuffer **released, u32 *released_count, u64 timeout)
Waits for audio capture to finish.
PcmFormat audinGetPcmFormat(void)
Supported PCM format (Int16).
void * buffer
Sample buffer (aligned to 0x1000 bytes).
Definition: audin.h:22
u32 audinGetChannelCount(void)
Supported channel count (2 channels).
u64 data_size
Size of data inside the buffer.
Definition: audin.h:24
u32 audinGetSampleRate(void)
These return the state associated with the currently active audio input device.
u64 data_offset
Offset of data inside the buffer. (Unused?)
Definition: audin.h:25
Audio input buffer format.
Definition: audin.h:19