mirror of
https://github.com/switchbrew/libnx.git
synced 2025-07-03 18:12:14 +02:00
Add functions for state retrieval
This commit is contained in:
parent
d4c586bdb8
commit
f523371474
@ -12,6 +12,11 @@
|
|||||||
static Service g_audoutSrv;
|
static Service g_audoutSrv;
|
||||||
static Service g_audoutIAudioOut;
|
static Service g_audoutIAudioOut;
|
||||||
|
|
||||||
|
static u32 g_sampleRate = 0;
|
||||||
|
static u32 g_channelCount = 0;
|
||||||
|
static PcmFormat g_pcmFormat = PcmFormat_Invalid;
|
||||||
|
static AudioOutState g_deviceState = AudioOutState_Stopped;
|
||||||
|
|
||||||
Result audoutInitialize(void)
|
Result audoutInitialize(void)
|
||||||
{
|
{
|
||||||
if (serviceIsActive(&g_audoutSrv))
|
if (serviceIsActive(&g_audoutSrv))
|
||||||
@ -22,17 +27,12 @@ Result audoutInitialize(void)
|
|||||||
|
|
||||||
// Setup the default device
|
// Setup the default device
|
||||||
if (R_SUCCEEDED(rc))
|
if (R_SUCCEEDED(rc))
|
||||||
{
|
{
|
||||||
u32 SampleRate = 0;
|
|
||||||
u32 ChannelCount = 0;
|
|
||||||
PcmFormat Format = 0;
|
|
||||||
AudioOutState State = 0;
|
|
||||||
|
|
||||||
// Passing an empty device name will open the default "DeviceOut"
|
// Passing an empty device name will open the default "DeviceOut"
|
||||||
char DeviceNameIn[DEVICE_NAME_LENGTH] = {0};
|
char DeviceNameIn[DEVICE_NAME_LENGTH] = {0};
|
||||||
char DeviceNameOut[DEVICE_NAME_LENGTH] = {0};
|
char DeviceNameOut[DEVICE_NAME_LENGTH] = {0};
|
||||||
|
|
||||||
rc = audoutOpenAudioOut(DeviceNameIn, DeviceNameOut, DEFAULT_SAMPLE_RATE, CHANNEL_COUNT_MAGIC, &SampleRate, &ChannelCount, &Format, &State);
|
rc = audoutOpenAudioOut(DeviceNameIn, DeviceNameOut, DEFAULT_SAMPLE_RATE, CHANNEL_COUNT_MAGIC, &g_sampleRate, &g_channelCount, &g_pcmFormat, &g_deviceState);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (R_FAILED(rc))
|
if (R_FAILED(rc))
|
||||||
@ -43,10 +43,31 @@ Result audoutInitialize(void)
|
|||||||
|
|
||||||
void audoutExit(void)
|
void audoutExit(void)
|
||||||
{
|
{
|
||||||
|
g_sampleRate = 0;
|
||||||
|
g_channelCount = 0;
|
||||||
|
g_pcmFormat = PcmFormat_Invalid;
|
||||||
|
g_deviceState = AudioOutState_Stopped;
|
||||||
|
|
||||||
serviceClose(&g_audoutIAudioOut);
|
serviceClose(&g_audoutIAudioOut);
|
||||||
serviceClose(&g_audoutSrv);
|
serviceClose(&g_audoutSrv);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
u32 audoutGetSampleRate(void) {
|
||||||
|
return g_sampleRate;
|
||||||
|
}
|
||||||
|
|
||||||
|
u32 audoutGetChannelCount(void) {
|
||||||
|
return g_channelCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
PcmFormat audoutGetPcmFormat(void) {
|
||||||
|
return g_pcmFormat;
|
||||||
|
}
|
||||||
|
|
||||||
|
AudioOutState audoutGetDeviceState(void) {
|
||||||
|
return g_deviceState;
|
||||||
|
}
|
||||||
|
|
||||||
Result audoutListAudioOuts(char *DeviceNames, u32 *DeviceNamesCount) {
|
Result audoutListAudioOuts(char *DeviceNames, u32 *DeviceNamesCount) {
|
||||||
IpcCommand c;
|
IpcCommand c;
|
||||||
ipcInitialize(&c);
|
ipcInitialize(&c);
|
||||||
|
Loading…
Reference in New Issue
Block a user