forked from switchbrew/libnx
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial audio support (switchbrew#43)
Initial audio support
- Loading branch information
Showing
3 changed files
with
507 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/** | ||
* @file audout.h | ||
* @brief Audio output service. | ||
* @author hexkyz | ||
* @copyright libnx Authors | ||
*/ | ||
#pragma once | ||
|
||
#include "../types.h" | ||
|
||
typedef enum { | ||
PcmFormat_Invalid = 0, | ||
PcmFormat_INT8 = 1, | ||
PcmFormat_INT16 = 2, | ||
PcmFormat_INT24 = 3, | ||
PcmFormat_INT32 = 4, | ||
PcmFormat_FLOAT = 5, | ||
PcmFormat_ADPCM = 6, | ||
} PcmFormat; | ||
|
||
typedef enum { | ||
AudioOutState_Started = 0, | ||
AudioOutState_Stopped = 1, | ||
} AudioOutState; | ||
|
||
/// Audio output buffer format | ||
typedef struct AudioOutBuffer AudioOutBuffer; | ||
|
||
struct AudioOutBuffer | ||
{ | ||
AudioOutBuffer* next; ///< Next buffer. | ||
void* buffer; ///< Sample buffer. | ||
u64 buffer_size; ///< Sample buffer size. | ||
u64 data_size; ///< Size of data inside the buffer. | ||
u64 data_offset; ///< Offset of data inside the buffer. | ||
}; | ||
|
||
Result audoutInitialize(void); | ||
void audoutExit(void); | ||
|
||
Result audoutListAudioOuts(char *DeviceNames, u32 *DeviceNamesCount); | ||
Result audoutOpenAudioOut(const char *DeviceNameIn, char *DeviceNameOut, u32 SampleRateIn, u32 ChannelCountIn, u32 *SampleRateOut, u32 *ChannelCountOut, PcmFormat *Format, AudioOutState *State); | ||
Result audoutGetAudioOutState(AudioOutState *State); | ||
Result audoutStartAudioOut(void); | ||
Result audoutStopAudioOut(void); | ||
Result audoutAppendAudioOutBuffer(AudioOutBuffer *Buffer); | ||
Result audoutGetReleasedAudioOutBuffer(AudioOutBuffer *Buffer, u32 *ReleasedBuffersCount); | ||
Result audoutContainsAudioOutBuffer(AudioOutBuffer *Buffer, bool *ContainsBuffer); | ||
|
||
/** | ||
* @brief Submits an audio sample data buffer for playing. | ||
* @param source AudioOutBuffer containing the source sample data to be played. | ||
* @param released AudioOutBuffer to receive the last played buffer. | ||
*/ | ||
void audoutPlayBuffer(AudioOutBuffer *source, AudioOutBuffer *released); | ||
|
||
/// These return the state associated with the currently active audio output device. | ||
u32 audoutGetSampleRate(void); ///< Supported sample rate (48000Hz). | ||
u32 audoutGetChannelCount(void); ///< Supported channel count (2 channels). | ||
PcmFormat audoutGetPcmFormat(void); ///< Supported PCM format (INT16). | ||
AudioOutState audoutGetDeviceState(void); ///< Initial device state (stopped). |
Oops, something went wrong.