From cb2905c8ea9f471a9bb6952da76c4f28a6d44471 Mon Sep 17 00:00:00 2001 From: HookedBehemoth Date: Mon, 6 Apr 2020 23:15:51 +0200 Subject: [PATCH] add version checks and annotation --- nx/include/switch/services/audout.h | 6 ++++++ nx/source/services/audout.c | 15 +++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/nx/include/switch/services/audout.h b/nx/include/switch/services/audout.h index 9c82cf44..8a49a9b2 100644 --- a/nx/include/switch/services/audout.h +++ b/nx/include/switch/services/audout.h @@ -50,10 +50,16 @@ 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); /** diff --git a/nx/source/services/audout.c b/nx/source/services/audout.c index 2e61b1a7..0f579120 100644 --- a/nx/source/services/audout.c +++ b/nx/source/services/audout.c @@ -222,14 +222,23 @@ Result audoutContainsAudioOutBuffer(AudioOutBuffer *Buffer, bool *ContainsBuffer } 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; @@ -237,9 +246,15 @@ Result audoutFlushAudioOutBuffers(bool *flushed) { } 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); }