libnx/nx/include/switch/services/audout.h
Mike H cde07068dd Return result from audoutPlayBuffer (#46)
* Return result from audoutPlayBuffer
* Add alignment note in header file
2018-02-19 16:43:58 -05:00

62 lines
2.2 KiB
C

/**
* @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 (aligned to 0x1000 bytes).
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.
*/
Result 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).