-
Notifications
You must be signed in to change notification settings - Fork 173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add audout:a audout:d aud:a aud:d #636
Open
ITotalJustice
wants to merge
2
commits into
switchbrew:master
Choose a base branch
from
ITotalJustice:audouta_and_friends
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/** | ||
* @file aud.h | ||
* @brief Only available on [11.0.0+]. | ||
* @note Only one session may be open at once. | ||
* @author TotalJustice | ||
* @copyright libnx Authors | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "../types.h" | ||
#include "../sf/service.h" | ||
|
||
#define AUD_MAX_DELAY (1000000000ULL) | ||
|
||
/// Initialize aud:a. Only available on [11.0.0+]. | ||
Result audaInitialize(void); | ||
|
||
/// Exit aud:a. | ||
void audaExit(void); | ||
|
||
/// Initialize aud:d. Only available on [11.0.0+]. | ||
Result auddInitialize(void); | ||
|
||
/// Exit aud:d. | ||
void auddExit(void); | ||
|
||
/// Gets the Service for aud:a. | ||
Service* audaGetServiceSession(void); | ||
|
||
/// Gets the Service for aud:d. | ||
Service* auddGetServiceSession(void); | ||
|
||
Result audaRequestSuspendAudio(u64 pid, u64 delay); | ||
Result audaRequestResumeAudio(u64 pid, u64 delay); | ||
Result audaGetAudioOutputProcessMasterVolume(u64 pid, float* volume_out); | ||
|
||
Result audaSetAudioOutputProcessMasterVolume(u64 pid, u64 delay, float volume); | ||
Result audaGetAudioInputProcessMasterVolume(u64 pid, float* volume_out); | ||
|
||
// Sets both Output and Input volume | ||
Result audaSetAudioInputProcessMasterVolume(u64 pid, u64 delay, float volume); | ||
Result audaGetAudioOutputProcessRecordVolume(u64 pid, float* volume_out); | ||
Result audaSetAudioOutputProcessRecordVolume(u64 pid, u64 delay, float volume); | ||
|
||
Result auddRequestSuspendAudioForDebug(u64 pid, u64 delay); | ||
Result auddRequestResumeAudioForDebug(u64 pid, u64 delay); |
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,115 @@ | ||
#define NX_SERVICE_ASSUME_NON_DOMAIN | ||
#include "service_guard.h" | ||
#include "services/aud.h" | ||
#include "runtime/hosversion.h" | ||
|
||
static Service g_audaSrv; | ||
static Service g_auddSrv; | ||
|
||
NX_GENERATE_SERVICE_GUARD(auda); | ||
NX_GENERATE_SERVICE_GUARD(audd); | ||
|
||
Result _audaInitialize(void) { | ||
if (hosversionBefore(11,0,0)) | ||
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer); | ||
|
||
return smGetService(&g_audaSrv, "aud:a"); | ||
} | ||
|
||
void _audaCleanup(void) { | ||
serviceClose(&g_audaSrv); | ||
} | ||
|
||
Result _auddInitialize(void) { | ||
return smGetService(&g_auddSrv, "aud:d"); | ||
} | ||
|
||
void _auddCleanup(void) { | ||
serviceClose(&g_auddSrv); | ||
} | ||
|
||
Service* audaGetServiceSession(void) { | ||
return &g_audaSrv; | ||
} | ||
|
||
Service* auddGetServiceSession(void) { | ||
return &g_auddSrv; | ||
} | ||
|
||
Result audaRequestSuspendAudio(u64 pid, u64 delay) { | ||
const struct { | ||
u64 pid; | ||
u64 delay; | ||
} in = { pid, delay }; | ||
|
||
return serviceDispatchIn(&g_audaSrv, 2, in); | ||
} | ||
|
||
Result audaRequestResumeAudio(u64 pid, u64 delay) { | ||
const struct { | ||
u64 pid; | ||
u64 delay; | ||
} in = { pid, delay }; | ||
|
||
return serviceDispatchIn(&g_audaSrv, 3, in); | ||
} | ||
|
||
Result audaGetAudioOutputProcessMasterVolume(u64 pid, float* volume_out) { | ||
return serviceDispatchInOut(&g_audaSrv, 4, pid, *volume_out); | ||
} | ||
|
||
Result audaSetAudioOutputProcessMasterVolume(u64 pid, u64 delay, float volume) { | ||
const struct { | ||
float volume; | ||
u64 pid; | ||
u64 delay; | ||
} in = { volume, pid, delay }; | ||
|
||
return serviceDispatchIn(&g_audaSrv, 5, in); | ||
} | ||
|
||
Result audaGetAudioInputProcessMasterVolume(u64 pid, float* volume_out) { | ||
return serviceDispatchInOut(&g_audaSrv, 6, pid, *volume_out); | ||
} | ||
|
||
Result audaSetAudioInputProcessMasterVolume(u64 pid, u64 delay, float volume) { | ||
const struct { | ||
float volume; | ||
u64 pid; | ||
u64 delay; | ||
} in = { volume, pid, delay }; | ||
|
||
return serviceDispatchIn(&g_audaSrv, 7, in); | ||
} | ||
|
||
Result audaGetAudioOutputProcessRecordVolume(u64 pid, float* volume_out) { | ||
return serviceDispatchInOut(&g_audaSrv, 8, pid, *volume_out); | ||
} | ||
|
||
Result audaSetAudioOutputProcessRecordVolume(u64 pid, u64 delay, float volume) { | ||
const struct { | ||
float volume; | ||
u64 pid; | ||
u64 delay; | ||
} in = { volume, pid, delay }; | ||
|
||
return serviceDispatchIn(&g_audaSrv, 9, in); | ||
} | ||
|
||
Result auddRequestSuspendAudioForDebug(u64 pid, u64 delay) { | ||
const struct { | ||
u64 pid; | ||
u64 delay; | ||
} in = { pid, delay }; | ||
|
||
return serviceDispatchIn(&g_auddSrv, 0, in); | ||
} | ||
|
||
Result auddRequestResumeAudioForDebug(u64 pid, u64 delay) { | ||
const struct { | ||
u64 pid; | ||
u64 delay; | ||
} in = { pid, delay }; | ||
|
||
return serviceDispatchIn(&g_auddSrv, 1, in); | ||
} |
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 |
---|---|---|
|
@@ -11,6 +11,8 @@ | |
|
||
static Service g_audoutSrv; | ||
static Service g_audoutIAudioOut; | ||
static Service g_audoutaSrv; | ||
static Service g_audoutdSrv; | ||
|
||
static Event g_audoutBufferEvent; | ||
|
||
|
@@ -22,6 +24,8 @@ static AudioOutState g_deviceState = AudioOutState_Stopped; | |
static Result _audoutRegisterBufferEvent(Event *BufferEvent); | ||
|
||
NX_GENERATE_SERVICE_GUARD(audout); | ||
NX_GENERATE_SERVICE_GUARD(audouta); | ||
NX_GENERATE_SERVICE_GUARD(audoutd); | ||
|
||
Result _audoutInitialize(void) { | ||
Result rc = 0; | ||
|
@@ -56,6 +60,28 @@ void _audoutCleanup(void) { | |
serviceClose(&g_audoutSrv); | ||
} | ||
|
||
Result _audoutaInitialize(void) { | ||
if (hosversionAtLeast(11,0,0)) | ||
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer); | ||
|
||
return smGetService(&g_audoutaSrv, "audout:a"); | ||
} | ||
|
||
void _audoutaCleanup(void) { | ||
serviceClose(&g_audoutaSrv); | ||
} | ||
|
||
Result _audoutdInitialize(void) { | ||
if (hosversionAtLeast(11,0,0)) | ||
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer); | ||
|
||
return smGetService(&g_audoutdSrv, "audout:d"); | ||
} | ||
|
||
void _audoutdCleanup(void) { | ||
serviceClose(&g_audoutdSrv); | ||
} | ||
|
||
Service* audoutGetServiceSession(void) { | ||
return &g_audoutSrv; | ||
} | ||
|
@@ -64,6 +90,14 @@ Service* audoutGetServiceSession_AudioOut(void) { | |
return &g_audoutIAudioOut; | ||
} | ||
|
||
Service* audoutaGetServiceSession(void) { | ||
return &g_audoutaSrv; | ||
} | ||
|
||
Service* audoutdGetServiceSession(void) { | ||
return &g_audoutdSrv; | ||
} | ||
|
||
u32 audoutGetSampleRate(void) { | ||
return g_sampleRate; | ||
} | ||
|
@@ -259,3 +293,103 @@ Result audoutGetAudioOutVolume(float *volume) { | |
|
||
return serviceDispatchOut(&g_audoutIAudioOut, 13, *volume); | ||
} | ||
|
||
Result audoutaRequestSuspendOld(u64 pid, u64 delay, Handle* handle_out) { | ||
if (hosversionAtLeast(4,0,0)) | ||
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer); | ||
|
||
const struct { | ||
u64 pid; | ||
u64 delay; | ||
} in = { pid, delay }; | ||
|
||
return serviceDispatchInOut(&g_audoutaSrv, 0, in, *handle_out); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This isn't correct for output-handle, see elsewhere. |
||
} | ||
|
||
Result audoutaRequestResumeOld(u64 pid, u64 delay, Handle* handle_out) { | ||
if (hosversionAtLeast(4,0,0)) | ||
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer); | ||
|
||
const struct { | ||
u64 pid; | ||
u64 delay; | ||
} in = { pid, delay }; | ||
|
||
return serviceDispatchInOut(&g_audoutaSrv, 1, in, *handle_out); | ||
} | ||
|
||
Result audoutaRequestSuspend(u64 pid, u64 delay) { | ||
if (hosversionBefore(4,0,0)) | ||
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer); | ||
|
||
const struct { | ||
u64 pid; | ||
u64 delay; | ||
} in = { pid, delay }; | ||
|
||
return serviceDispatchIn(&g_audoutaSrv, 0, in); | ||
} | ||
|
||
Result audoutaRequestResume(u64 pid, u64 delay) { | ||
if (hosversionBefore(4,0,0)) | ||
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer); | ||
|
||
const struct { | ||
u64 pid; | ||
u64 delay; | ||
} in = { pid, delay }; | ||
|
||
return serviceDispatchIn(&g_audoutaSrv, 1, in); | ||
} | ||
|
||
Result audoutaGetProcessMasterVolume(u64 pid, float* volume_out) { | ||
return serviceDispatchInOut(&g_audoutaSrv, 2, pid, *volume_out); | ||
} | ||
|
||
Result audoutaSetProcessMasterVolume(u64 pid, u64 delay, float volume) { | ||
const struct { | ||
float volume; | ||
u64 pid; | ||
u64 delay; | ||
} in = { volume, pid, delay }; | ||
|
||
return serviceDispatchIn(&g_audoutaSrv, 3, in); | ||
} | ||
|
||
Result audoutaGetProcessRecordVolume(u64 pid, float* volume_out) { | ||
if (hosversionBefore(4,0,0)) | ||
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer); | ||
|
||
return serviceDispatchInOut(&g_audoutaSrv, 4, pid, *volume_out); | ||
} | ||
|
||
Result audoutaSetProcessRecordVolume(u64 pid, u64 delay, float volume) { | ||
if (hosversionBefore(4,0,0)) | ||
return MAKERESULT(Module_Libnx, LibnxError_IncompatSysVer); | ||
|
||
const struct { | ||
float volume; | ||
u64 pid; | ||
u64 delay; | ||
} in = { volume, pid, delay }; | ||
|
||
return serviceDispatchIn(&g_audoutaSrv, 5, in); | ||
} | ||
|
||
Result audoutdRequestSuspendForDebug(u64 pid, u64 delay) { | ||
const struct { | ||
u64 pid; | ||
u64 delay; | ||
} in = { pid, delay }; | ||
|
||
return serviceDispatchIn(&g_audoutdSrv, 0, in); | ||
} | ||
|
||
Result audoutdRequestResumeForDebug(u64 pid, u64 delay) { | ||
const struct { | ||
u64 pid; | ||
u64 delay; | ||
} in = { pid, delay }; | ||
|
||
return serviceDispatchIn(&g_audoutdSrv, 1, in); | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- [3.0.2]