Audio services: Difference between revisions
No edit summary |
No edit summary |
||
Line 16: | Line 16: | ||
== ListAudioOuts == | == ListAudioOuts == | ||
Takes a type- | Takes a type-0x6 output buffer. | ||
Populates the output buffer with the available audio output devices' names and returns an u32 with the number of device names written. | Populates the output buffer with the available audio output devices' names and returns an u32 with the number of device names written. | ||
== OpenAudioOut == | == OpenAudioOut == | ||
Takes a type- | Takes a type-0x5 input buffer ('''DeviceNameIn'''), a type-0x6 output buffer ('''DeviceNameOut'''), two u32s '''SampleRate''' (must be 48000) and '''ChannelCount''' (only the higher u16 is used), one [[Applet_Manager_services#AppletResourceUserId|AppletResourceUserId]], a PID and a copy-handle. | ||
Returns an [[#IAudioOut]] object and four u32s: the sample rate, channel count, [[# | Returns an [[#IAudioOut]] object and four u32s: the sample rate, channel count, [[#SampleFormat|SampleFormat]], and the initial AudioOutState. | ||
== ListAudioOutsAuto == | == ListAudioOutsAuto == | ||
Line 58: | Line 38: | ||
| 0 || [[#GetAudioOutState]] | | 0 || [[#GetAudioOutState]] | ||
|- | |- | ||
| 1 || [[# | | 1 || [[#Start]] | ||
|- | |- | ||
| 2 || [[# | | 2 || [[#Stop]] | ||
|- | |- | ||
| 3 || [[#AppendAudioOutBuffer]] | | 3 || [[#AppendAudioOutBuffer]] | ||
Line 66: | Line 46: | ||
| 4 || [[#RegisterBufferEvent]] | | 4 || [[#RegisterBufferEvent]] | ||
|- | |- | ||
| 5 || [[# | | 5 || [[#GetReleasedAudioOutBuffers]] | ||
|- | |- | ||
| 6 || [[#ContainsAudioOutBuffer]] | | 6 || [[#ContainsAudioOutBuffer]] | ||
Line 72: | Line 52: | ||
| 7 || [3.0.0+] [[#AppendAudioOutBufferAuto]] | | 7 || [3.0.0+] [[#AppendAudioOutBufferAuto]] | ||
|- | |- | ||
| 8 || [3.0.0+] [[# | | 8 || [3.0.0+] [[#GetReleasedAudioOutBuffersAuto]] | ||
|- | |- | ||
| 9 || [4.0.0+] [[#GetAudioOutBufferCount]] | | 9 || [4.0.0+] [[#GetAudioOutBufferCount]] | ||
Line 86: | Line 66: | ||
=== GetAudioOutState === | === GetAudioOutState === | ||
Returns an u32 '''AudioOutState''' ( | Returns an u32 '''AudioOutState''' (0=Started, 1=Stopped). | ||
=== | === Start === | ||
Starts audio playback using data from appended buffers. | Starts audio playback using data from appended buffers. | ||
=== | === Stop === | ||
Stops audio playback. This waits for audio playback to finish before returning. | Stops audio playback. This waits for audio playback to finish before returning. | ||
=== AppendAudioOutBuffer === | === AppendAudioOutBuffer === | ||
Takes a type- | Takes a type-0x5 input buffer of [[#AudioOutBuffer|AudioOutBuffer]] and a u64 which acts as a tag for the supplied buffer (official apps use the buffer's address). | ||
=== RegisterBufferEvent === | === RegisterBufferEvent === | ||
Returns an event handle that is signalled when a buffer is released. | Returns an event handle that is signalled when a buffer is released. | ||
=== | === GetReleasedAudioOutBuffers === | ||
Takes a type- | Takes a type-0x6 output buffer which will be filled with the identifiers from [[#AppendAudioOutBuffer]] of audio buffers that have been released. | ||
Returns an u32 '''ReleasedBuffersCount'''. | Returns an u32 '''ReleasedBuffersCount'''. | ||
Line 126: | Line 90: | ||
Same as [[#AppendAudioOutBuffer]] but takes a type-0x21 buffer instead. | Same as [[#AppendAudioOutBuffer]] but takes a type-0x21 buffer instead. | ||
=== | === GetReleasedAudioOutBuffersAuto === | ||
Same as [[#GetReleasedAudioOutBuffer]] but takes a type-0x22 buffer instead. | Same as [[#GetReleasedAudioOutBuffer]] but takes a type-0x22 buffer instead. | ||
Line 173: | Line 137: | ||
| 0 || [[#GetAudioInState]] | | 0 || [[#GetAudioInState]] | ||
|- | |- | ||
| 1 || | | 1 || Start | ||
|- | |- | ||
| 2 || | | 2 || Stop | ||
|- | |- | ||
| 3 || AppendAudioInBuffer | | 3 || AppendAudioInBuffer | ||
Line 181: | Line 145: | ||
| 4 || RegisterBufferEvent | | 4 || RegisterBufferEvent | ||
|- | |- | ||
| 5 || | | 5 || GetReleasedAudioInBuffers | ||
|- | |- | ||
| 6 || ContainsAudioInBuffer | | 6 || ContainsAudioInBuffer | ||
|- | |- | ||
| 7 || [3.0.0+] | | 7 || [3.0.0+] AppendUacInBuffer | ||
|- | |- | ||
| 8 || [3.0.0+] AppendAudioInBufferAuto | | 8 || [3.0.0+] AppendAudioInBufferAuto | ||
|- | |- | ||
| 9 || [3.0.0+] | | 9 || [3.0.0+] GetReleasedAudioInBuffersAuto | ||
|- | |- | ||
| 10 || [3.0.0+] | | 10 || [3.0.0+] AppendUacInBufferAuto | ||
|- | |- | ||
| 11 || [4.0.0+] GetAudioInBufferCount | | 11 || [4.0.0+] GetAudioInBufferCount | ||
|- | |- | ||
| 12 || [4.0.0+] | | 12 || [4.0.0+] SetDeviceGain | ||
|- | |- | ||
| 13 || [4.0.0+] | | 13 || [4.0.0+] GetDeviceGain | ||
|- | |- | ||
| 14 || [6.0.0+] FlushAudioInBuffers | | 14 || [6.0.0+] FlushAudioInBuffers | ||
Line 203: | Line 167: | ||
=== GetAudioInState === | === GetAudioInState === | ||
Returns an u32 '''AudioInState''' ( | Returns an u32 '''AudioInState''' (0=Started, 1=Stopped). | ||
= audrec:u = | = audrec:u = | ||
Line 297: | Line 261: | ||
| 2 || [[#GetMixBufferCount]] | | 2 || [[#GetMixBufferCount]] | ||
|- | |- | ||
| 3 || [[# | | 3 || [[#GetState]] | ||
|- | |- | ||
| 4 || RequestUpdate | | 4 || RequestUpdate | ||
Line 317: | Line 281: | ||
=== GetSampleRate === | === GetSampleRate === | ||
Returns | No input. Returns an u32 '''SampleRate'''. | ||
=== GetSampleCount === | === GetSampleCount === | ||
Returns | No input. Returns an u32 '''SampleCount'''. | ||
=== GetMixBufferCount === | === GetMixBufferCount === | ||
Returns | No input. Returns an u32 '''MixBufferCount'''. | ||
=== | === GetState === | ||
Returns an | No input. Returns an u32 '''State''' (0=Started, 1=Stopped). | ||
=== SetRenderingTimeLimit === | === SetRenderingTimeLimit === | ||
Takes | Takes an u32 '''RenderingTimeLimit'''. No output. | ||
=== GetRenderingTimeLimit === | === GetRenderingTimeLimit === | ||
Returns | No input. Returns an u32 '''RenderingTimeLimit'''. | ||
== IAudioDevice == | == IAudioDevice == | ||
Line 369: | Line 333: | ||
=== ListAudioDeviceName === | === ListAudioDeviceName === | ||
Takes a type-0x6 output buffer containing an array of '''DeviceName''' | Takes a type-0x6 output buffer containing an array of '''DeviceName'''. Returns an output s32 for total number of output entries. | ||
=== SetAudioDeviceOutputVolume === | === SetAudioDeviceOutputVolume === | ||
Line 378: | Line 342: | ||
=== ListAudioDeviceNameAuto === | === ListAudioDeviceNameAuto === | ||
Takes a type-0x22 output buffer containing an array of '''DeviceName''' | Takes a type-0x22 output buffer containing an array of '''DeviceName'''. Returns an output s32 for total number of output entries. | ||
=== SetAudioDeviceOutputVolumeAuto === | === SetAudioDeviceOutputVolumeAuto === | ||
Line 395: | Line 359: | ||
! Cmd || Name | ! Cmd || Name | ||
|- | |- | ||
| 0 || | | 0 || RequestSuspend | ||
|- | |- | ||
| 1 || | | 1 || RequestResume | ||
|- | |- | ||
| 2 || | | 2 || GetProcessMasterVolume | ||
|- | |- | ||
| 3 || | | 3 || SetProcessMasterVolume | ||
|- | |- | ||
| 4 || [4.0.0+] | | 4 || [4.0.0+] GetProcessRecordVolume | ||
|- | |- | ||
| 5 || [4.0.0+] | | 5 || [4.0.0+] SetProcessRecordVolume | ||
|} | |} | ||
[4.0.0+] | [4.0.0+] RequestSuspend/RequestResume no longer returns an output handle. | ||
= audin:a = | = audin:a = | ||
Line 419: | Line 383: | ||
! Cmd || Name | ! Cmd || Name | ||
|- | |- | ||
| 0 || | | 0 || RequestSuspend | ||
|- | |- | ||
| 1 || | | 1 || RequestResume | ||
|- | |- | ||
| 2 || | | 2 || GetProcessMasterVolume | ||
|- | |- | ||
| 3 || | | 3 || SetProcessMasterVolume | ||
|} | |} | ||
[4.0.0+] | [4.0.0+] RequestSuspend/RequestResume no longer returns an output handle. | ||
= audrec:a = | = audrec:a = | ||
Line 437: | Line 401: | ||
! Cmd || Name | ! Cmd || Name | ||
|- | |- | ||
| 0 || | | 0 || RequestSuspend | ||
|- | |- | ||
| 1 || | | 1 || RequestResume | ||
|} | |} | ||
[4.0.0+] | [4.0.0+] RequestSuspend/RequestResume no longer returns an output handle. | ||
= audren:a = | = audren:a = | ||
Line 453: | Line 417: | ||
! Cmd || Name | ! Cmd || Name | ||
|- | |- | ||
| 0 || | | 0 || RequestSuspend | ||
|- | |- | ||
| 1 || | | 1 || RequestResume | ||
|- | |- | ||
| 2 || | | 2 || GetProcessMasterVolume | ||
|- | |- | ||
| 3 || | | 3 || SetProcessMasterVolume | ||
|- | |- | ||
| 4 || RegisterAppletResourceUserId | | 4 || RegisterAppletResourceUserId | ||
Line 465: | Line 429: | ||
| 5 || UnregisterAppletResourceUserId | | 5 || UnregisterAppletResourceUserId | ||
|- | |- | ||
| 6 || [4.0.0+] | | 6 || [4.0.0+] GetProcessRecordVolume | ||
|- | |- | ||
| 7 || [4.0.0+] | | 7 || [4.0.0+] SetProcessRecordVolume | ||
|} | |} | ||
[4.0.0+] | [4.0.0+] RequestSuspend/RequestResume no longer returns an output handle. | ||
= audout:d, audin:d, audrec:d, audren:d = | = audout:d, audin:d, audrec:d, audren:d = | ||
Line 481: | Line 445: | ||
! Cmd || Name | ! Cmd || Name | ||
|- | |- | ||
| 0 || [[# | | 0 || [[#RequestSuspend]] | ||
|- | |- | ||
| 1 || [[# | | 1 || [[#RequestResume]] | ||
|} | |} | ||
== | == RequestSuspend == | ||
Takes an u64 [[AM_services#AppletResourceUserId|AppletResourceUserId]]. | Takes an u64 [[AM_services#AppletResourceUserId|AppletResourceUserId]]. | ||
== | == RequestResume == | ||
Takes an u64 [[AM_services#AppletResourceUserId|AppletResourceUserId]]. | Takes an u64 [[AM_services#AppletResourceUserId|AppletResourceUserId]]. | ||
Line 561: | Line 525: | ||
=== UpdateHeadphoneSettings === | === UpdateHeadphoneSettings === | ||
Takes one input bool. No output. | |||
Takes one input | |||
NS calls this with the result of IParentalControlService::IsRestrictionEnabled[https://switchbrew.org/wiki/Parental_Control_services#IParentalControlService]. | NS calls this with the result of IParentalControlService::IsRestrictionEnabled[https://switchbrew.org/wiki/Parental_Control_services#IParentalControlService]. | ||
Line 574: | Line 537: | ||
! Cmd || Name | ! Cmd || Name | ||
|- | |- | ||
| 0 || [[# | | 0 || [[#Initialize]] | ||
|- | |- | ||
| 1 || [[# | | 1 || [[#Finalize]] | ||
|- | |- | ||
| 2 || [[# | | 2 || [[#Sleep]] | ||
|- | |- | ||
| 3 || [[# | | 3 || [[#Wake]] | ||
|- | |- | ||
| 4 || [[# | | 4 || [[#SetVolume]] | ||
|- | |- | ||
| 5 || [[# | | 5 || [[#GetVolumeMax]] | ||
|- | |- | ||
| 6 || [[# | | 6 || [[#GetVolumeMin]] | ||
|- | |- | ||
| 7 || [[# | | 7 || [[#SetActiveTarget]] | ||
|- | |- | ||
| 8 || [[# | | 8 || [[#GetActiveTarget]] | ||
|- | |- | ||
| 9 || [[# | | 9 || [[#BindHeadphoneMicJackInterrupt]] | ||
|- | |- | ||
| 10 || [[# | | 10 || [[#IsHeadphoneMicJackInserted]] | ||
|- | |- | ||
| 11 || [[# | | 11 || [[#ClearHeadphoneMicJackInterrupt]] | ||
|- | |- | ||
| 12 || [[# | | 12 || [[#IsRequested]] | ||
|} | |} | ||
== | == Initialize == | ||
No input/output. | |||
== | == Finalize == | ||
No input/output. | |||
== | == Sleep == | ||
No input/output. | |||
== | == Wake == | ||
No input/output. | |||
== | == SetVolume == | ||
Takes an u32 '''Volume'''. | Takes an u32 '''Volume'''. No output. | ||
== | == GetVolumeMax == | ||
Returns an u32 '''VolumeMax'''. | No input. Returns an u32 '''VolumeMax'''. | ||
== | == GetVolumeMin == | ||
Returns an u32 '''VolumeMin'''. | No input. Returns an u32 '''VolumeMin'''. | ||
== | == SetActiveTarget == | ||
Takes an u32 '''Target'''. | Takes an u32 '''Target'''. No output. | ||
== | == GetActiveTarget == | ||
Returns an u32 '''Target'''. | No input. Returns an u32 '''Target'''. | ||
== | == BindHeadphoneMicJackInterrupt == | ||
Returns an event handle. | No input. Returns an event handle. | ||
== | == IsHeadphoneMicJackInserted == | ||
Returns a bool. | No input. Returns a bool. | ||
== | == ClearHeadphoneMicJackInterrupt == | ||
No input/output. | |||
== | == IsRequested == | ||
Returns a bool. | No input. Returns a bool. | ||
= hwopus = | = hwopus = | ||
Line 647: | Line 610: | ||
! Cmd || Name | ! Cmd || Name | ||
|- | |- | ||
| 0 || [[# | | 0 || [[#OpenHardwareOpusDecoder]] | ||
|- | |- | ||
| 1 || [[#GetWorkBufferSize]] | | 1 || [[#GetWorkBufferSize]] | ||
Line 658: | Line 621: | ||
Official sw can use either software libopus, or hwopus via "nn::codec::HardwareOpus*" (separate from the former). | Official sw can use either software libopus, or hwopus via "nn::codec::HardwareOpus*" (separate from the former). | ||
== | == OpenHardwareOpusDecoder == | ||
Takes two s32s '''SampleRate''' and '''ChannelCount''' packed as an u64, an u32 '''WorkBufferSize''' and a TransferMemory handle for '''WorkBuffer'''. Returns an [[#IHardwareOpusDecoder]] object. The TransferMemory is created by the user-process with permissions=0. | Takes two s32s '''SampleRate''' and '''ChannelCount''' packed as an u64, an u32 '''WorkBufferSize''' and a TransferMemory handle for '''WorkBuffer'''. Returns an [[#IHardwareOpusDecoder]] object. The TransferMemory is created by the user-process with permissions=0. | ||
== GetWorkBufferSize== | == GetWorkBufferSize == | ||
Takes two s32s '''SampleRate''' and '''ChannelCount''' packed as an u64. Returns the u32 required size for the decoder's work buffer. Official user-processes align the output size to page-alignment. | Takes two s32s '''SampleRate''' and '''ChannelCount''' packed as an u64. Returns the u32 required size for the decoder's work buffer. Official user-processes align the output size to page-alignment. | ||
Line 673: | Line 636: | ||
The input buffer is a [[#MultiStreamParameters]] struct. | The input buffer is a [[#MultiStreamParameters]] struct. | ||
== IHardwareOpusDecoder == | == IHardwareOpusDecoder == | ||
Line 731: | Line 666: | ||
=== DecodeInterleavedOld === | === DecodeInterleavedOld === | ||
Takes a type- | Takes a type-0x5 input buffer ('''OpusDataIn''') and a type-0x6 output buffer ('''PcmDataOut'''). Decodes the Opus source data to PCM and returns output s32 '''DecodedDataSize''' and s32 '''DecodedSampleCount'''. | ||
Calls the same func as [[#DecodeInterleaved]] internally with flag=0 and out_u64_ptr=NULL. | Calls the same func as [[#DecodeInterleaved]] internally with flag=0 and out_u64_ptr=NULL. | ||
=== SetContext === | === SetContext === | ||
Takes a type- | Takes a type-0x5 input buffer ('''DecoderContextIn'''). Sends the unknown context data to the hardware decoder. The input buffer is unused. | ||
=== DecodeInterleavedForMultiStreamOld === | === DecodeInterleavedForMultiStreamOld === | ||
Takes a type- | Takes a type-0x5 input buffer ('''OpusDataIn''') and a type-0x6 output buffer ('''PcmDataOut'''). Decodes the Opus source data to PCM and returns output s32 '''DecodedDataSize''' and s32 '''DecodedSampleCount'''. | ||
Calls the same func as [[#DecodeInterleavedForMultiStream]] internally with flag=0 and out_u64_ptr=NULL. | Calls the same func as [[#DecodeInterleavedForMultiStream]] internally with flag=0 and out_u64_ptr=NULL. | ||
=== SetContextForMultiStream === | === SetContextForMultiStream === | ||
Takes a type- | Takes a type-0x5 input buffer ('''DecoderContextIn'''). Sends the unknown context data to the hardware decoder. | ||
=== DecodeInterleavedWithPerfOld === | === DecodeInterleavedWithPerfOld === | ||
Line 779: | Line 714: | ||
! Cmd || Name | ! Cmd || Name | ||
|- | |- | ||
| 0 || | | 0 || ProfilerStart | ||
|- | |- | ||
| 1 || | | 1 || ProfilerStop | ||
|- | |- | ||
| 2 || | | 2 || CpuProfilerStart | ||
|- | |- | ||
| 3 || | | 3 || CpuProfilerStop | ||
|} | |} | ||
Line 830: | Line 765: | ||
|- | |- | ||
| 1 || RequestResumeAudioForDebug | | 1 || RequestResumeAudioForDebug | ||
|} | |||
= SampleFormat = | |||
This is "nn::audio::SampleFormat". | |||
{| class="wikitable" border="1" | |||
|- | |||
! Value || Name | |||
|- | |||
| 0 || Invalid | |||
|- | |||
| 1 || PcmInt8 | |||
|- | |||
| 2 || PcmInt16 | |||
|- | |||
| 3 || PcmInt24 | |||
|- | |||
| 4 || PcmInt32 | |||
|- | |||
| 5 || PcmFloat | |||
|- | |||
| 6 || Adpcm | |||
|} | |||
= AudioOutBuffer = | |||
This is "nn::audio::AudioOutBuffer". | |||
{| class="wikitable" border="1" | |||
|- | |||
! Offset || Size || Description | |||
|- | |||
| 0x00 || 8 || Pointer to next buffer (unused) | |||
|- | |||
| 0x08 || 8 || Pointer to sample buffer | |||
|- | |||
| 0x10 || 8 || Capacity of sample buffer | |||
|- | |||
| 0x18 || 8 || Size of data in the sample buffer | |||
|- | |||
| 0x20 || 8 || Offset of data in the sample buffer (unused/ignored?) | |||
|} | |||
= MultiStreamParameters = | |||
{| class="wikitable" border="1" | |||
|- | |||
! Offset | |||
! Size | |||
! Description | |||
|- | |||
| 0x0 | |||
| 0x4 | |||
| Sample rate (Hz) | |||
|- | |||
| 0x4 | |||
| 0x4 | |||
| Number of channels | |||
|- | |||
| 0x8 | |||
| 0x4 | |||
| Number of streams | |||
|- | |||
| 0xC | |||
| 0x4 | |||
| Number of stereo streams | |||
|- | |||
| 0x10 | |||
| 0x100 | |||
| u8 array of channel mappings | |||
|} | |} | ||
[[Category:Services]] | [[Category:Services]] |