Difference between revisions of "Audio services"

From Nintendo Switch Brew
Jump to navigation Jump to search
(Adding names from factory titles and minor corrections)
(42 intermediate revisions by 4 users not shown)
Line 10: Line 10:
 
| 1 || [[#OpenAudioOut]]
 
| 1 || [[#OpenAudioOut]]
 
|-
 
|-
| 2 || [3.0.0+] [[#ListAudioOutsEx]]
+
| 2 || [3.0.0+] [[#ListAudioOutsAuto]]
 
|-
 
|-
| 3 || [3.0.0+] [[#OpenAudioOutEx]]
+
| 3 || [3.0.0+] [[#OpenAudioOutAuto]]
 
|}
 
|}
  
Line 43: Line 43:
 
|}
 
|}
  
== ListAudioOutsEx ==
+
== ListAudioOutsAuto ==
 
Same as [[#ListAudioOuts]], but takes a type-0x22 output buffer instead.
 
Same as [[#ListAudioOuts]], but takes a type-0x22 output buffer instead.
  
== OpenAudioOutEx ==
+
== OpenAudioOutAuto ==
 
Same as [[#OpenAudioOut]], but takes a type-0x21 input buffer instead.
 
Same as [[#OpenAudioOut]], but takes a type-0x21 input buffer instead.
  
Line 70: Line 70:
 
| 6 || [[#ContainsAudioOutBuffer]]
 
| 6 || [[#ContainsAudioOutBuffer]]
 
|-
 
|-
| 7 || [3.0.0+] [[#AppendAudioOutBufferEx]]
+
| 7 || [3.0.0+] [[#AppendAudioOutBufferAuto]]
 
|-
 
|-
| 8 || [3.0.0+] [[#GetReleasedAudioOutBufferEx]]
+
| 8 || [3.0.0+] [[#GetReleasedAudioOutBufferAuto]]
 
|-
 
|-
| 9 || [4.0.0+]
+
| 9 || [4.0.0+] GetAudioOutBufferCount
 
|-
 
|-
| 10 || [4.0.0+]
+
| 10 || [4.0.0+] GetAudioOutPlayedSampleCount
 
|-
 
|-
| 11 || [4.0.0+]
+
| 11 || [4.0.0+] FlushAudioOutBuffers
 +
|-
 +
| 12 || [6.0.0+] SetAudioOutVolume
 +
|-
 +
| 13 || [6.0.0+] GetAudioOutVolume
 
|}
 
|}
  
Line 88: Line 92:
  
 
=== StopAudioOut ===
 
=== StopAudioOut ===
Stops audio playback.
+
Stops audio playback. This waits for audio playback to finish before returning.
  
 
=== AppendAudioOutBuffer ===
 
=== AppendAudioOutBuffer ===
Line 106: Line 110:
 
| 0x18 || 8 || Size of data in the sample buffer
 
| 0x18 || 8 || Size of data in the sample buffer
 
|-
 
|-
| 0x20 || 8 || Offset of data in the sample buffer
+
| 0x20 || 8 || Offset of data in the sample buffer (unused/ignored?)
 
|}
 
|}
  
Line 119: Line 123:
 
Takes an u64 '''tag''' for the desired buffer. Returns 1 if the buffer was appended and not yet released.
 
Takes an u64 '''tag''' for the desired buffer. Returns 1 if the buffer was appended and not yet released.
  
=== AppendAudioOutBufferEx ===
+
=== AppendAudioOutBufferAuto ===
 
Same as [[#AppendAudioOutBuffer]] but takes a type-0x21 buffer instead.
 
Same as [[#AppendAudioOutBuffer]] but takes a type-0x21 buffer instead.
  
=== GetReleasedAudioOutBufferEx ===
+
=== GetReleasedAudioOutBufferAuto ===
 
Same as [[#GetReleasedAudioOutBuffer]] but takes a type-0x22 buffer instead.
 
Same as [[#GetReleasedAudioOutBuffer]] but takes a type-0x22 buffer instead.
  
 
= audin:u =
 
= audin:u =
This is "nn::audio::detail::IAudioInManagerForDebugger".
+
This is "nn::audio::detail::IAudioInManager".
  
 
{| class="wikitable" border="1"
 
{| class="wikitable" border="1"
Line 136: Line 140:
 
| 1 || OpenAudioIn
 
| 1 || OpenAudioIn
 
|-
 
|-
| 2 || [3.0.0+] ListAudioInsEx
+
| 2 || [3.0.0+] ListAudioInsAuto
 +
|-
 +
| 3 || [3.0.0+] OpenAudioInAuto
 
|-
 
|-
| 3 || [3.0.0+] OpenAudioInEx
+
| 4 || [3.0.0+] ListAudioInsAutoFiltered
 
|-
 
|-
| 4 || [3.0.0+] ListAudioInsExAndProbe
+
| 5 || [5.0.0+]
 
|}
 
|}
  
Line 166: Line 172:
 
| 7 || [3.0.0+] AppendAudioInBufferWithUserEvent
 
| 7 || [3.0.0+] AppendAudioInBufferWithUserEvent
 
|-
 
|-
| 8 || [3.0.0+] AppendAudioInBufferEx
+
| 8 || [3.0.0+] AppendAudioInBufferAuto
 +
|-
 +
| 9 || [3.0.0+] GetReleasedAudioInBufferAuto
 
|-
 
|-
| 9 || [3.0.0+] GetReleasedAudioInBufferEx
+
| 10 || [3.0.0+] AppendAudioInBufferWithUserEventAuto
 
|-
 
|-
| 10 || [3.0.0+] AppendAudioInBufferWithUserEventEx
+
| 11 || [4.0.0+] GetAudioInBufferCount
 
|-
 
|-
| 11 || [4.0.0+]
+
| 12 || [4.0.0+] SetAudioInDeviceGain
 
|-
 
|-
| 12 || [4.0.0+]
+
| 13 || [4.0.0+] GetAudioInDeviceGain
 
|-
 
|-
| 13 || [4.0.0+]
+
| 14 || [6.0.0+] FlushAudioInBuffers
 
|}
 
|}
  
Line 213: Line 221:
 
| 6 || ContainsFinalOutputRecorderBuffer
 
| 6 || ContainsFinalOutputRecorderBuffer
 
|-
 
|-
| 7 ||
+
| 7 || GetFinalOutputRecorderBufferEndTime
 +
|-
 +
| 8 || [3.0.0+] AppendFinalOutputRecorderBufferAuto
 +
|-
 +
| 9 || [3.0.0+] GetReleasedFinalOutputRecorderBufferAuto
 +
|-
 +
| 10 || [6.0.0+] FlushFinalOutputRecorderBuffers
 +
|-
 +
| 11 || [9.0.0+]
 +
|}
 +
 
 +
= auddev =
 +
This is "nn::audio::detail::IAudioSnoopManager".
 +
 
 +
This was added with [6.0.0+].
 +
 
 +
{| class="wikitable" border="1"
 +
|-
 +
! Cmd || Name
 +
|-
 +
| 0 ||  
 
|-
 
|-
| 8 || [3.0.0+] AppendFinalOutputRecorderBufferEx
+
| 1 ||  
 
|-
 
|-
| 9 || [3.0.0+] GetReleasedFinalOutputRecorderBufferEx
+
| 6 ||  
 
|}
 
|}
  
Line 229: Line 257:
 
| 0 || OpenAudioRenderer
 
| 0 || OpenAudioRenderer
 
|-
 
|-
| 1 || GetAudioRendererWorkBufferSize
+
| 1 || GetWorkBufferSize
 
|-
 
|-
| 2 || GetAudioRenderersProcessMasterVolume
+
| 2 || [[#GetAudioDeviceService]]
 
|-
 
|-
| 3 || [3.0.0+] SetAudioRenderersProcessMasterVolume
+
| 3 || [3.0.0+] OpenAudioRendererForManualExecution
 
|-
 
|-
| 4 || [4.0.0+]
+
| 4 || [4.0.0+] GetAudioDeviceServiceWithRevisionInfo
 
|}
 
|}
 +
 +
=== GetAudioDeviceService ===
 +
Takes an input u64 [[AM_services#AppletResourceUserId|AppletResourceUserId]], returns an output [[#IAudioDevice]].
  
 
== IAudioRenderer ==
 
== IAudioRenderer ==
Line 245: Line 276:
 
! Cmd || Name
 
! Cmd || Name
 
|-
 
|-
| 0 || [[#GetAudioRendererSampleRate]]
+
| 0 || [[#GetSampleRate]]
 
|-
 
|-
| 1 || [[#GetAudioRendererSampleCount]]
+
| 1 || [[#GetSampleCount]]
 
|-
 
|-
| 2 || [[#GetAudioRendererMixBufferCount]]
+
| 2 || [[#GetMixBufferCount]]
 
|-
 
|-
| 3 || [[#GetAudioRendererState]]
+
| 3 || [[#GetState]]
 
|-
 
|-
| 4 || RequestUpdateAudioRenderer
+
| 4 || RequestUpdate
 
|-
 
|-
| 5 || StartAudioRenderer
+
| 5 || Start
 
|-
 
|-
| 6 || StopAudioRenderer
+
| 6 || Stop
 
|-
 
|-
 
| 7 || QuerySystemEvent
 
| 7 || QuerySystemEvent
 
|-
 
|-
| 8 || [[#SetAudioRendererRenderingTimeLimit]]
+
| 8 || [[#SetRenderingTimeLimit]]
 
|-
 
|-
| 9 || [[#GetAudioRendererRenderingTimeLimit]]
+
| 9 || [[#GetRenderingTimeLimit]]
 
|-
 
|-
| 10 || [3.0.0+] RequestUpdateAudioRendererEx
+
| 10 || [3.0.0+] RequestUpdateAuto
 
|-
 
|-
| 11 || [3.0.0+]
+
| 11 || [3.0.0+] ExecuteAudioRendererRendering
 
|}
 
|}
  
=== GetAudioRendererSampleRate ===
+
=== GetSampleRate ===
 
Returns the Sample Rate. (u32)
 
Returns the Sample Rate. (u32)
  
=== GetAudioRendererSampleCount ===
+
=== GetSampleCount ===
 
Returns the Sample Count. (u32)
 
Returns the Sample Count. (u32)
  
=== GetAudioRendererMixBufferCount ===
+
=== GetMixBufferCount ===
 
Returns the number of Mix Buffers. (u32)
 
Returns the number of Mix Buffers. (u32)
  
Line 282: Line 313:
 
Returns an AudioRenderState, 0x00=Started 0x01=Stopped (u32)
 
Returns an AudioRenderState, 0x00=Started 0x01=Stopped (u32)
  
=== SetAudioRendererRenderingTimeLimit ===
+
=== SetRenderingTimeLimit ===
 
Takes a upper limit of the rendering time in percent. (u32)
 
Takes a upper limit of the rendering time in percent. (u32)
  
=== GetAudioRendererRenderingTimeLimit ===
+
=== GetRenderingTimeLimit ===
 
Returns the upper limit of the rendering time in percent. (u32)
 
Returns the upper limit of the rendering time in percent. (u32)
 +
 +
== IAudioDevice ==
 +
This is "nn::audio::detail::IAudioDevice".
 +
 +
{| class="wikitable" border="1"
 +
|-
 +
! Cmd || Name
 +
|-
 +
| 0 || [[#ListAudioDeviceName]]
 +
|-
 +
| 1 || [[#SetAudioDeviceOutputVolume]]
 +
|-
 +
| 2 || [[#GetAudioDeviceOutputVolume]]
 +
|-
 +
| 3 || GetActiveAudioDeviceName
 +
|-
 +
| 4 || QueryAudioDeviceSystemEvent
 +
|-
 +
| 5 || GetActiveChannelCount
 +
|-
 +
| 6 || [3.0.0+] [[#ListAudioDeviceNameAuto]]
 +
|-
 +
| 7 || [3.0.0+] [[#SetAudioDeviceOutputVolumeAuto]]
 +
|-
 +
| 8 || [3.0.0+] [[#GetAudioDeviceOutputVolumeAuto]]
 +
|-
 +
| 10 || [3.0.0+] GetActiveAudioDeviceNameAuto
 +
|-
 +
| 11 || [3.0.0+] QueryAudioDeviceInputEvent
 +
|-
 +
| 12 || [3.0.0+] QueryAudioDeviceOutputEvent
 +
|-
 +
| 13 || [5.0.0+] GetAudioSystemMasterVolumeSetting
 +
|}
 +
 +
=== ListAudioDeviceName ===
 +
Takes a type-0x6 output buffer containing an array of '''DeviceName''', returns an output s32 for total number of output entries.
 +
 +
=== SetAudioDeviceOutputVolume ===
 +
Takes a type-0x5 input buffer containing the '''DeviceName''' and a float. No output.
 +
 +
=== GetAudioDeviceOutputVolume ===
 +
Takes a type-0x5 input buffer containing the '''DeviceName'''. Returns an output float.
 +
 +
=== ListAudioDeviceNameAuto ===
 +
Takes a type-0x22 output buffer containing an array of '''DeviceName''', returns an output s32 for total number of output entries.
 +
 +
=== SetAudioDeviceOutputVolumeAuto ===
 +
Takes a type-0x21 input buffer containing the '''DeviceName''' and a float. No output.
 +
 +
=== GetAudioDeviceOutputVolumeAuto ===
 +
Takes a type-0x21 input buffer containing the '''DeviceName'''. Returns an output float.
  
 
= audout:a =
 
= audout:a =
Line 302: Line 385:
 
|-
 
|-
 
| 3 || SetAudioOutsProcessMasterVolume
 
| 3 || SetAudioOutsProcessMasterVolume
 +
|-
 +
| 4 || [4.0.0+] GetAudioOutsProcessRecordVolume
 +
|-
 +
| 5 || [4.0.0+] SetAudioOutsProcessRecordVolume
 
|}
 
|}
 +
 +
[4.0.0+] RequestSuspendAudioOuts/RequestResumeAudioOuts no longer returns an output handle.
  
 
= audin:a =
 
= audin:a =
Line 319: Line 408:
 
| 3 || SetAudioInsProcessMasterVolume
 
| 3 || SetAudioInsProcessMasterVolume
 
|}
 
|}
 +
 +
[4.0.0+] RequestSuspendAudioIns/RequestResumeAudioIns no longer returns an output handle.
  
 
= audrec:a =
 
= audrec:a =
Line 331: Line 422:
 
| 1 || RequestResumeFinalOutputRecorders
 
| 1 || RequestResumeFinalOutputRecorders
 
|}
 
|}
 +
 +
[4.0.0+] RequestSuspendFinalOutputRecorders/RequestResumeFinalOutputRecorders no longer returns an output handle.
  
 
= audren:a =
 
= audren:a =
Line 350: Line 443:
 
|-
 
|-
 
| 5 || UnregisterAppletResourceUserId
 
| 5 || UnregisterAppletResourceUserId
 +
|-
 +
| 6 || [4.0.0+] GetAudioRenderersProcessRecordVolume
 +
|-
 +
| 7 || [4.0.0+] SetAudioRenderersProcessRecordVolume
 
|}
 
|}
 +
 +
[4.0.0+] RequestSuspendAudioRenderers/RequestResumeAudioRenderers no longer returns an output handle.
  
 
= audout:d, audin:d, audrec:d, audren:d =
 
= audout:d, audin:d, audrec:d, audren:d =
Line 377: Line 476:
 
! Cmd || Name
 
! Cmd || Name
 
|-
 
|-
| 0 ||
+
| 0 || GetTargetVolume
 
|-
 
|-
| 1 ||
+
| 1 || SetTargetVolume
 
|-
 
|-
| 2 ||
+
| 2 || GetTargetVolumeMin
 
|-
 
|-
| 3 ||
+
| 3 || GetTargetVolumeMax
 
|-
 
|-
| 4 ||
+
| 4 || IsTargetMute
 
|-
 
|-
| 5 ||
+
| 5 || SetTargetMute
 
|-
 
|-
| 6 ||
+
| 6 || IsTargetConnected
 
|-
 
|-
| 7 ||
+
| 7 || SetDefaultTarget
 
|-
 
|-
| 8 ||
+
| 8 || GetDefaultTarget
 
|-
 
|-
| 9 ||
+
| 9 || GetAudioOutputMode
 
|-
 
|-
| 10 ||
+
| 10 || SetAudioOutputMode
 
|-
 
|-
| 11 ||
+
| 11 || SetForceMutePolicy
 
|-
 
|-
| 12 ||
+
| 12 || GetForceMutePolicy
 
|-
 
|-
| 13 ||
+
| 13 || GetOutputModeSetting
 
|-
 
|-
| 14 ||
+
| 14 || SetOutputModeSetting
 
|-
 
|-
| 15 ||
+
| 15 || SetOutputTarget
 
|-
 
|-
| 16 ||
+
| 16 || SetInputTargetForceEnabled
 
|-
 
|-
| 17 || [3.0.0+]
+
| 17 || [3.0.0+] SetHeadphoneOutputLevelMode
 
|-
 
|-
| 18 || [3.0.0+]
+
| 18 || [3.0.0+] GetHeadphoneOutputLevelMode
 
|-
 
|-
| 19 || [3.0.0+]
+
| 19 || [3.0.0+] AcquireAudioVolumeUpdateEventForPlayReport
 
|-
 
|-
| 20 || [3.0.0+]
+
| 20 || [3.0.0+] AcquireAudioOutputDeviceUpdateEventForPlayReport
 
|-
 
|-
| 21 || [3.0.0+]
+
| 21 || [3.0.0+] GetAudioOutputTargetForPlayReport
 
|-
 
|-
| 22 || [3.0.0+]
+
| 22 || [3.0.0+] NotifyHeadphoneVolumeWarningDisplayedEvent
 
|-
 
|-
| 23 || [4.0.0+]
+
| 23 || [4.0.0+] SetSystemOutputMasterVolume
 
|-
 
|-
| 24 || [4.0.0+]
+
| 24 || [4.0.0+] GetSystemOutputMasterVolume
 
|-
 
|-
| 25 || [4.0.0+]
+
| 25 || [4.0.0+] GetAudioVolumeDataForPlayReport
 
|-
 
|-
| 26 || [4.0.0+]
+
| 26 || [4.0.0+] UpdateHeadphoneSettings
 +
|-
 +
| 27 || [7.0.0+]  
 
|}
 
|}
  
Line 518: Line 619:
 
| 1 || [[#GetWorkBufferSize]]
 
| 1 || [[#GetWorkBufferSize]]
 
|-
 
|-
| 2 || [3.0.0+] InitializeEx
+
| 2 || [3.0.0+] [[#OpenHardwareOpusDecoderForMultiStream]]
 
|-
 
|-
| 3 || [3.0.0+] GetWorkBufferSizeEx
+
| 3 || [3.0.0+] [[#GetWorkBufferSizeForMultiStream]]
 
|}
 
|}
 +
 +
Official sw can use either software libopus, or hwopus via "nn::codec::HardwareOpus*" (separate from the former).
  
 
== Initialize ==
 
== Initialize ==
Takes two u32s '''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 u32s '''SampleRate''' and '''ChannelCount''' packed as an u64. Returns the required size for the decoder's work buffer.
+
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.
 +
 
 +
== OpenHardwareOpusDecoderForMultiStream ==
 +
Takes a type-0x19 input buffer, an u32 '''WorkBufferSize''' and a TransferMemory handle for '''WorkBuffer'''. Returns an [[#IHardwareOpusDecoder]] object. The TransferMemory is created by the user-process with permissions=0.
 +
 
 +
The input buffer is a [[#MultiStreamParameters]] struct. The user-process initializes this struct the same way as [[#GetWorkBufferSizeForMultiStream]], except that an u8-array specified by the user is copied to +0x10 with size '''ChannelCount''', when '''ChannelCount''' above 0.
 +
 
 +
== GetWorkBufferSizeForMultiStream ==
 +
Takes a type-0x19 input buffer. Returns the u32 required size for the decoder's work buffer. Official user-processes align the output size to page-alignment.
 +
 
 +
The input buffer is a [[#MultiStreamParameters]] struct.
 +
 
 +
== 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
 +
|}
  
 
== IHardwareOpusDecoder ==
 
== IHardwareOpusDecoder ==
Line 536: Line 677:
 
! Cmd || Name
 
! Cmd || Name
 
|-
 
|-
| 0 || [[#DecodeInterleaved]]
+
| 0 || [4.0.0+] [[#DecodeInterleavedOld]] ([1.0.0-3.0.2] [[#DecodeInterleavedOld|#DecodeInterleaved]])
 
|-
 
|-
 
| 1 || [[#SetContext]]
 
| 1 || [[#SetContext]]
 
|-
 
|-
| 2 || [3.0.0+] DecodeInterleavedEx
+
| 2 || [4.0.0+] [[#DecodeInterleavedForMultiStreamOld]] ([3.0.0-3.0.2] DecodeInterleavedForMultiStream)
 +
|-
 +
| 3 || [3.0.0+] [[#SetContextForMultiStream]]
 +
|-
 +
| 4 || [6.0.0+] [[#DecodeInterleavedWithPerfOld]] ([4.0.0-5.1.0] DecodeInterleavedWithPerf)
 +
|-
 +
| 5 || [6.0.0+] [[#DecodeInterleavedForMultiStreamWithPerfOld]] ([4.0.0-5.1.0] DecodeInterleavedForMultiStreamWithPerf)
 
|-
 
|-
| 3 || [3.0.0+] SetContextEx
+
| 6 || [6.0.0+] [[#DecodeInterleaved]]
 
|-
 
|-
| 4 || [4.0.0+]
+
| 7 || [6.0.0+] [[#DecodeInterleavedForMultiStream]]
 
|-
 
|-
| 5 || [4.0.0+]
+
| 8 || [7.0.0+]
 +
|-
 +
| 9 || [7.0.0+]
 
|}
 
|}
  
=== DecodeInterleaved ===
+
=== DecodeInterleavedOld ===
Takes a type-5 input buffer ('''OpusDataIn''') and a type-6 output buffer ('''PcmDataOut'''). Decodes the Opus source data to PCM and returns two u32s '''DecodedSampleCount''' and '''DecodedDataSize'''.
+
Takes a type-5 input buffer ('''OpusDataIn''') and a type-6 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.
  
 
=== SetContext ===
 
=== SetContext ===
 +
Takes a type-5 input buffer ('''DecoderContextIn'''). Sends the unknown context data to the hardware decoder. The input buffer is unused.
 +
 +
=== DecodeInterleavedForMultiStreamOld ===
 +
Takes a type-5 input buffer ('''OpusDataIn''') and a type-6 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.
 +
 +
=== SetContextForMultiStream ===
 
Takes a type-5 input buffer ('''DecoderContextIn'''). Sends the unknown context data to the hardware decoder.
 
Takes a type-5 input buffer ('''DecoderContextIn'''). Sends the unknown context data to the hardware decoder.
 +
 +
=== DecodeInterleavedWithPerfOld ===
 +
Takes a type-0x5 input buffer ('''OpusDataIn''') and a type-0x46 output buffer ('''PcmDataOut'''). Decodes the Opus source data to PCM and returns output s32 '''DecodedDataSize''', s32 '''DecodedSampleCount''', and an u64.
 +
 +
The output u64 is ignored by official user-processes.
 +
 +
Calls the same func as [[#DecodeInterleaved]] internally with flag=0.
 +
 +
=== DecodeInterleavedForMultiStreamWithPerfOld ===
 +
Takes a type-0x5 input buffer ('''OpusDataIn''') and a type-0x46 output buffer ('''PcmDataOut'''). Decodes the Opus source data to PCM and returns output s32 '''DecodedDataSize''', s32 '''DecodedSampleCount''', and an u64.
 +
 +
The output u64 is ignored by official user-processes.
 +
 +
Calls the same func as [[#DecodeInterleavedForMultiStream]] internally with flag=0.
 +
 +
=== DecodeInterleaved ===
 +
Takes an input u8 bool flag, a type-0x5 input buffer ('''OpusDataIn''') and a type-0x46 output buffer ('''PcmDataOut'''). Decodes the Opus source data to PCM and returns output s32 '''DecodedDataSize''', s32 '''DecodedSampleCount''', and an u64.
 +
 +
The bool flag indicates whether or not a reset of the decoder context is being requested.
 +
 +
=== DecodeInterleavedForMultiStream ===
 +
Takes an input u8 bool flag, a type-0x5 input buffer ('''OpusDataIn''') and a type-0x46 output buffer ('''PcmDataOut'''). Decodes the Opus source data to PCM and returns output s32 '''DecodedDataSize''', s32 '''DecodedSampleCount''', and an u64.
 +
 +
The bool flag indicates whether or not a reset of the decoder context is being requested.
  
 
= auddebug =
 
= auddebug =
Line 564: Line 747:
 
! Cmd || Name
 
! Cmd || Name
 
|-
 
|-
| 0 ||
+
| 0 || StartDspProfiler
 
|-
 
|-
| 1 ||
+
| 1 || StopDspProfiler
 
|-
 
|-
| 2 ||
+
| 2 || StartCpuProfiler
 
|-
 
|-
| 3 ||
+
| 3 || StopCpuProfiler
 
|}
 
|}
  
 
[[Category:Services]]
 
[[Category:Services]]

Revision as of 17:45, 10 September 2019

audout:u

This is "nn::audio::detail::IAudioOutManager".

Cmd Name
0 #ListAudioOuts
1 #OpenAudioOut
2 [3.0.0+] #ListAudioOutsAuto
3 [3.0.0+] #OpenAudioOutAuto

ListAudioOuts

Takes a type-6 output buffer. Populates the output buffer with the available audio output devices' names and returns an u32 with the number of device names written.

OpenAudioOut

Takes a type-5 input buffer (DeviceNameIn), a type-6 output buffer (DeviceNameOut), two u32s SampleRate (must be 48000) and ChannelCount (only the higher u16 is used), one u64 ClientPID, a PID and a copy-handle. Returns an #IAudioOut object and four u32s: the sample rate, channel count, PCM format, and the initial AudioOutState.

PCM format

Value Name
0 Invalid
1 INT8
2 INT16
3 INT24
4 INT32
5 PCM Float
6 ADPCM

ListAudioOutsAuto

Same as #ListAudioOuts, but takes a type-0x22 output buffer instead.

OpenAudioOutAuto

Same as #OpenAudioOut, but takes a type-0x21 input buffer instead.

IAudioOut

This is "nn::audio::detail::IAudioOut".

Cmd Name
0 #GetAudioOutState
1 #StartAudioOut
2 #StopAudioOut
3 #AppendAudioOutBuffer
4 #RegisterBufferEvent
5 #GetReleasedAudioOutBuffer
6 #ContainsAudioOutBuffer
7 [3.0.0+] #AppendAudioOutBufferAuto
8 [3.0.0+] #GetReleasedAudioOutBufferAuto
9 [4.0.0+] GetAudioOutBufferCount
10 [4.0.0+] GetAudioOutPlayedSampleCount
11 [4.0.0+] FlushAudioOutBuffers
12 [6.0.0+] SetAudioOutVolume
13 [6.0.0+] GetAudioOutVolume

GetAudioOutState

Returns an u32 AudioOutState (0x00=Started, 0x01=Stopped).

StartAudioOut

Starts audio playback using data from appended buffers.

StopAudioOut

Stops audio playback. This waits for audio playback to finish before returning.

AppendAudioOutBuffer

Takes a type-5 input buffer for sample data and a u64 which acts as a tag for the supplied buffer (official apps use the buffer's address).

The format of the input buffer is as follows:

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?)

RegisterBufferEvent

Returns an event handle that is signalled when a buffer is released.

GetReleasedAudioOutBuffer

Takes a type-6 output buffer which will be filled with the identifiers from #AppendAudioOutBuffer of audio buffers that have been released. Returns an u32 ReleasedBuffersCount.

ContainsAudioOutBuffer

Takes an u64 tag for the desired buffer. Returns 1 if the buffer was appended and not yet released.

AppendAudioOutBufferAuto

Same as #AppendAudioOutBuffer but takes a type-0x21 buffer instead.

GetReleasedAudioOutBufferAuto

Same as #GetReleasedAudioOutBuffer but takes a type-0x22 buffer instead.

audin:u

This is "nn::audio::detail::IAudioInManager".

Cmd Name
0 ListAudioIns
1 OpenAudioIn
2 [3.0.0+] ListAudioInsAuto
3 [3.0.0+] OpenAudioInAuto
4 [3.0.0+] ListAudioInsAutoFiltered
5 [5.0.0+]

IAudioIn

This is "nn::audio::detail::IAudioIn".

Cmd Name
0 #GetAudioInState
1 StartAudioIn
2 StopAudioIn
3 AppendAudioInBuffer
4 RegisterBufferEvent
5 GetReleasedAudioInBuffer
6 ContainsAudioInBuffer
7 [3.0.0+] AppendAudioInBufferWithUserEvent
8 [3.0.0+] AppendAudioInBufferAuto
9 [3.0.0+] GetReleasedAudioInBufferAuto
10 [3.0.0+] AppendAudioInBufferWithUserEventAuto
11 [4.0.0+] GetAudioInBufferCount
12 [4.0.0+] SetAudioInDeviceGain
13 [4.0.0+] GetAudioInDeviceGain
14 [6.0.0+] FlushAudioInBuffers

GetAudioInState

Returns an u32 AudioInState (0x00=Started, 0x01=Stopped).

audrec:u

This is "nn::audio::detail::IFinalOutputRecorderManager".

Cmd Name
0 OpenFinalOutputRecorder

IFinalOutputRecorder

This is "nn::audio::detail::IFinalOutputRecorder".

Cmd Name
0 GetFinalOutputRecorderState
1 StartFinalOutputRecorder
2 StopFinalOutputRecorder
3 AppendFinalOutputRecorderBuffer
4 RegisterBufferEvent
5 GetReleasedFinalOutputRecorderBuffer
6 ContainsFinalOutputRecorderBuffer
7 GetFinalOutputRecorderBufferEndTime
8 [3.0.0+] AppendFinalOutputRecorderBufferAuto
9 [3.0.0+] GetReleasedFinalOutputRecorderBufferAuto
10 [6.0.0+] FlushFinalOutputRecorderBuffers
11 [9.0.0+]

auddev

This is "nn::audio::detail::IAudioSnoopManager".

This was added with [6.0.0+].

Cmd Name
0
1
6

audren:u

This is "nn::audio::detail::IAudioRendererManager".

Cmd Name
0 OpenAudioRenderer
1 GetWorkBufferSize
2 #GetAudioDeviceService
3 [3.0.0+] OpenAudioRendererForManualExecution
4 [4.0.0+] GetAudioDeviceServiceWithRevisionInfo

GetAudioDeviceService

Takes an input u64 AppletResourceUserId, returns an output #IAudioDevice.

IAudioRenderer

This is "nn::audio::detail::IAudioRenderer".

Cmd Name
0 #GetSampleRate
1 #GetSampleCount
2 #GetMixBufferCount
3 #GetState
4 RequestUpdate
5 Start
6 Stop
7 QuerySystemEvent
8 #SetRenderingTimeLimit
9 #GetRenderingTimeLimit
10 [3.0.0+] RequestUpdateAuto
11 [3.0.0+] ExecuteAudioRendererRendering

GetSampleRate

Returns the Sample Rate. (u32)

GetSampleCount

Returns the Sample Count. (u32)

GetMixBufferCount

Returns the number of Mix Buffers. (u32)

GetAudioRendererState

Returns an AudioRenderState, 0x00=Started 0x01=Stopped (u32)

SetRenderingTimeLimit

Takes a upper limit of the rendering time in percent. (u32)

GetRenderingTimeLimit

Returns the upper limit of the rendering time in percent. (u32)

IAudioDevice

This is "nn::audio::detail::IAudioDevice".

Cmd Name
0 #ListAudioDeviceName
1 #SetAudioDeviceOutputVolume
2 #GetAudioDeviceOutputVolume
3 GetActiveAudioDeviceName
4 QueryAudioDeviceSystemEvent
5 GetActiveChannelCount
6 [3.0.0+] #ListAudioDeviceNameAuto
7 [3.0.0+] #SetAudioDeviceOutputVolumeAuto
8 [3.0.0+] #GetAudioDeviceOutputVolumeAuto
10 [3.0.0+] GetActiveAudioDeviceNameAuto
11 [3.0.0+] QueryAudioDeviceInputEvent
12 [3.0.0+] QueryAudioDeviceOutputEvent
13 [5.0.0+] GetAudioSystemMasterVolumeSetting

ListAudioDeviceName

Takes a type-0x6 output buffer containing an array of DeviceName, returns an output s32 for total number of output entries.

SetAudioDeviceOutputVolume

Takes a type-0x5 input buffer containing the DeviceName and a float. No output.

GetAudioDeviceOutputVolume

Takes a type-0x5 input buffer containing the DeviceName. Returns an output float.

ListAudioDeviceNameAuto

Takes a type-0x22 output buffer containing an array of DeviceName, returns an output s32 for total number of output entries.

SetAudioDeviceOutputVolumeAuto

Takes a type-0x21 input buffer containing the DeviceName and a float. No output.

GetAudioDeviceOutputVolumeAuto

Takes a type-0x21 input buffer containing the DeviceName. Returns an output float.

audout:a

This is "nn::audio::detail::IAudioOutManagerForApplet".

Cmd Name
0 RequestSuspendAudioOuts
1 RequestResumeAudioOuts
2 GetAudioOutsProcessMasterVolume
3 SetAudioOutsProcessMasterVolume
4 [4.0.0+] GetAudioOutsProcessRecordVolume
5 [4.0.0+] SetAudioOutsProcessRecordVolume

[4.0.0+] RequestSuspendAudioOuts/RequestResumeAudioOuts no longer returns an output handle.

audin:a

This is "nn::audio::detail::IAudioInManagerForApplet".

Cmd Name
0 RequestSuspendAudioIns
1 RequestResumeAudioIns
2 GetAudioInsProcessMasterVolume
3 SetAudioInsProcessMasterVolume

[4.0.0+] RequestSuspendAudioIns/RequestResumeAudioIns no longer returns an output handle.

audrec:a

This is "nn::audio::detail::IFinalOutputRecorderManagerForApplet".

Cmd Name
0 RequestSuspendFinalOutputRecorders
1 RequestResumeFinalOutputRecorders

[4.0.0+] RequestSuspendFinalOutputRecorders/RequestResumeFinalOutputRecorders no longer returns an output handle.

audren:a

This is "nn::audio::detail::IAudioRendererManagerForApplet".

Cmd Name
0 RequestSuspendAudioRenderers
1 RequestResumeAudioRenderers
2 GetAudioRenderersProcessMasterVolume
3 SetAudioRenderersProcessMasterVolume
4 RegisterAppletResourceUserId
5 UnregisterAppletResourceUserId
6 [4.0.0+] GetAudioRenderersProcessRecordVolume
7 [4.0.0+] SetAudioRenderersProcessRecordVolume

[4.0.0+] RequestSuspendAudioRenderers/RequestResumeAudioRenderers no longer returns an output handle.

audout:d, audin:d, audrec:d, audren:d

This is "nn::audio::detail::IAudioOutManagerForDebugger", "nn::audio::detail::IAudioInManagerForDebugger", "nn::audio::detail::IFinalOutputRecorderManagerForDebugger", "nn::audio::detail::IAudioRendererManagerForDebugger".

Cmd Name
0 #RequestSuspendForDebug
1 #RequestResumeForDebug

RequestSuspendForDebug

Takes an u64 AppletResourceUserId.

RequestResumeForDebug

Takes an u64 AppletResourceUserId.

audctl

This is "nn::audioctrl::detail::IAudioController".

Cmd Name
0 GetTargetVolume
1 SetTargetVolume
2 GetTargetVolumeMin
3 GetTargetVolumeMax
4 IsTargetMute
5 SetTargetMute
6 IsTargetConnected
7 SetDefaultTarget
8 GetDefaultTarget
9 GetAudioOutputMode
10 SetAudioOutputMode
11 SetForceMutePolicy
12 GetForceMutePolicy
13 GetOutputModeSetting
14 SetOutputModeSetting
15 SetOutputTarget
16 SetInputTargetForceEnabled
17 [3.0.0+] SetHeadphoneOutputLevelMode
18 [3.0.0+] GetHeadphoneOutputLevelMode
19 [3.0.0+] AcquireAudioVolumeUpdateEventForPlayReport
20 [3.0.0+] AcquireAudioOutputDeviceUpdateEventForPlayReport
21 [3.0.0+] GetAudioOutputTargetForPlayReport
22 [3.0.0+] NotifyHeadphoneVolumeWarningDisplayedEvent
23 [4.0.0+] SetSystemOutputMasterVolume
24 [4.0.0+] GetSystemOutputMasterVolume
25 [4.0.0+] GetAudioVolumeDataForPlayReport
26 [4.0.0+] UpdateHeadphoneSettings
27 [7.0.0+]

codecctl

This is "nn::audio::detail::ICodecController".

This service no longer exists in [3.0.0+].

Cmd Name
0 #InitializeCodecController
1 #FinalizeCodecController
2 #SleepCodecController
3 #WakeCodecController
4 #SetCodecVolume
5 #GetCodecVolumeMax
6 #GetCodecVolumeMin
7 #SetCodecActiveTarget
8 #GetCodecActiveTarget
9 #BindCodecHeadphoneMicJackInterrupt
10 #IsCodecHeadphoneMicJackInserted
11 #ClearCodecHeadphoneMicJackInterrupt
12 #IsCodecDeviceRequested

InitializeCodecController

Takes no input.

FinalizeCodecController

Takes no input.

SleepCodecController

Takes no input.

WakeCodecController

Takes no input.

SetCodecVolume

Takes an u32 Volume.

GetCodecVolumeMax

Returns an u32 VolumeMax.

GetCodecVolumeMin

Returns an u32 VolumeMin.

SetCodecActiveTarget

Takes an u32 Target.

GetCodecActiveTarget

Returns an u32 Target.

BindCodecHeadphoneMicJackInterrupt

Returns an event handle.

IsCodecHeadphoneMicJackInserted

Returns a bool.

ClearCodecHeadphoneMicJackInterrupt

Takes no input.

IsCodecDeviceRequested

Returns a bool.

hwopus

This is "nn::codec::detail::IHardwareOpusDecoderManager".

Cmd Name
0 #Initialize
1 #GetWorkBufferSize
2 [3.0.0+] #OpenHardwareOpusDecoderForMultiStream
3 [3.0.0+] #GetWorkBufferSizeForMultiStream

Official sw can use either software libopus, or hwopus via "nn::codec::HardwareOpus*" (separate from the former).

Initialize

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

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.

OpenHardwareOpusDecoderForMultiStream

Takes a type-0x19 input buffer, an u32 WorkBufferSize and a TransferMemory handle for WorkBuffer. Returns an #IHardwareOpusDecoder object. The TransferMemory is created by the user-process with permissions=0.

The input buffer is a #MultiStreamParameters struct. The user-process initializes this struct the same way as #GetWorkBufferSizeForMultiStream, except that an u8-array specified by the user is copied to +0x10 with size ChannelCount, when ChannelCount above 0.

GetWorkBufferSizeForMultiStream

Takes a type-0x19 input buffer. Returns the u32 required size for the decoder's work buffer. Official user-processes align the output size to page-alignment.

The input buffer is a #MultiStreamParameters struct.

MultiStreamParameters

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

IHardwareOpusDecoder

This is "nn::codec::detail::IHardwareOpusDecoder".

Cmd Name
0 [4.0.0+] #DecodeInterleavedOld ([1.0.0-3.0.2] #DecodeInterleaved)
1 #SetContext
2 [4.0.0+] #DecodeInterleavedForMultiStreamOld ([3.0.0-3.0.2] DecodeInterleavedForMultiStream)
3 [3.0.0+] #SetContextForMultiStream
4 [6.0.0+] #DecodeInterleavedWithPerfOld ([4.0.0-5.1.0] DecodeInterleavedWithPerf)
5 [6.0.0+] #DecodeInterleavedForMultiStreamWithPerfOld ([4.0.0-5.1.0] DecodeInterleavedForMultiStreamWithPerf)
6 [6.0.0+] #DecodeInterleaved
7 [6.0.0+] #DecodeInterleavedForMultiStream
8 [7.0.0+]
9 [7.0.0+]

DecodeInterleavedOld

Takes a type-5 input buffer (OpusDataIn) and a type-6 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.

SetContext

Takes a type-5 input buffer (DecoderContextIn). Sends the unknown context data to the hardware decoder. The input buffer is unused.

DecodeInterleavedForMultiStreamOld

Takes a type-5 input buffer (OpusDataIn) and a type-6 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.

SetContextForMultiStream

Takes a type-5 input buffer (DecoderContextIn). Sends the unknown context data to the hardware decoder.

DecodeInterleavedWithPerfOld

Takes a type-0x5 input buffer (OpusDataIn) and a type-0x46 output buffer (PcmDataOut). Decodes the Opus source data to PCM and returns output s32 DecodedDataSize, s32 DecodedSampleCount, and an u64.

The output u64 is ignored by official user-processes.

Calls the same func as #DecodeInterleaved internally with flag=0.

DecodeInterleavedForMultiStreamWithPerfOld

Takes a type-0x5 input buffer (OpusDataIn) and a type-0x46 output buffer (PcmDataOut). Decodes the Opus source data to PCM and returns output s32 DecodedDataSize, s32 DecodedSampleCount, and an u64.

The output u64 is ignored by official user-processes.

Calls the same func as #DecodeInterleavedForMultiStream internally with flag=0.

DecodeInterleaved

Takes an input u8 bool flag, a type-0x5 input buffer (OpusDataIn) and a type-0x46 output buffer (PcmDataOut). Decodes the Opus source data to PCM and returns output s32 DecodedDataSize, s32 DecodedSampleCount, and an u64.

The bool flag indicates whether or not a reset of the decoder context is being requested.

DecodeInterleavedForMultiStream

Takes an input u8 bool flag, a type-0x5 input buffer (OpusDataIn) and a type-0x46 output buffer (PcmDataOut). Decodes the Opus source data to PCM and returns output s32 DecodedDataSize, s32 DecodedSampleCount, and an u64.

The bool flag indicates whether or not a reset of the decoder context is being requested.

auddebug

This is "nn::audio::detail::IAudioDebugManager".

This service doesn't exist in retail units.

Cmd Name
0 StartDspProfiler
1 StopDspProfiler
2 StartCpuProfiler
3 StopCpuProfiler