From 7dbb90ee665d9870b616b621d29533f812dfa386 Mon Sep 17 00:00:00 2001 From: HookedBehemoth Date: Mon, 6 Apr 2020 23:29:27 +0200 Subject: [PATCH] add remaining IAudioOut commands (#393) --- nx/include/switch/services/audout.h | 11 +++++++++ nx/source/services/audout.c | 38 +++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/nx/include/switch/services/audout.h b/nx/include/switch/services/audout.h index 2f18f676..8a49a9b2 100644 --- a/nx/include/switch/services/audout.h +++ b/nx/include/switch/services/audout.h @@ -51,6 +51,17 @@ Result audoutAppendAudioOutBuffer(AudioOutBuffer *Buffer); Result audoutGetReleasedAudioOutBuffer(AudioOutBuffer **Buffer, u32 *ReleasedBuffersCount); Result audoutContainsAudioOutBuffer(AudioOutBuffer *Buffer, bool *ContainsBuffer); +/// Only available with [4.0.0+]. +Result audoutGetAudioOutBufferCount(u32 *count); +/// Only available with [4.0.0+]. +Result audoutGetAudioOutPlayedSampleCount(u64 *count); +/// Only available with [4.0.0+]. +Result audoutFlushAudioOutBuffers(bool *flushed); +/// Only available with [6.0.0+]. +Result audoutSetAudioOutVolume(float volume); +/// Only available with [6.0.0+]. +Result audoutGetAudioOutVolume(float *volume); + /** * @brief Submits an audio sample data buffer for playing and waits for it to finish playing. * @brief Uses \ref audoutAppendAudioOutBuffer and \ref audoutWaitPlayFinish internally. diff --git a/nx/source/services/audout.c b/nx/source/services/audout.c index 607b7ee1..0f579120 100644 --- a/nx/source/services/audout.c +++ b/nx/source/services/audout.c @@ -220,3 +220,41 @@ Result audoutContainsAudioOutBuffer(AudioOutBuffer *Buffer, bool *ContainsBuffer if (R_SUCCEEDED(rc) && ContainsBuffer) *ContainsBuffer = out & 1; return rc; } + +Result audoutGetAudioOutBufferCount(u32 *count) { + if (hosversionBefore(4,0,0)) + return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer); + + return serviceDispatchOut(&g_audoutIAudioOut, 9, *count); +} + +Result audoutGetAudioOutPlayedSampleCount(u64 *count) { + if (hosversionBefore(4,0,0)) + return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer); + + return serviceDispatchOut(&g_audoutIAudioOut, 10, *count); +} + +Result audoutFlushAudioOutBuffers(bool *flushed) { + if (hosversionBefore(4,0,0)) + return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer); + + u8 out=0; + Result rc = serviceDispatchOut(&g_audoutIAudioOut, 11, out); + if (R_SUCCEEDED(rc) && flushed) *flushed = out & 1; + return rc; +} + +Result audoutSetAudioOutVolume(float volume) { + if (hosversionBefore(6,0,0)) + return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer); + + return serviceDispatchIn(&g_audoutIAudioOut, 12, volume); +} + +Result audoutGetAudioOutVolume(float *volume) { + if (hosversionBefore(6,0,0)) + return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer); + + return serviceDispatchOut(&g_audoutIAudioOut, 13, *volume); +}