Difference between revisions of "Audio services"

From Nintendo Switch Brew
Jump to navigation Jump to search
Line 20: Line 20:
  
 
== OpenAudioOut ==
 
== OpenAudioOut ==
Takes a type-5 input buffer ('''DeviceNameIn'''), a type-6 output buffer ('''DeviceNameOut'''), two u32s '''SampleRate''' (must be 48000) and '''ChannelCount''' (high u16 can't be 0, official apps pass 0xCAFE0000), one u64 '''ClientPID''', a PID and a copy-handle.
+
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|PCM format]], and the initial AudioOutState.
 
Returns an [[#IAudioOut]] object and four u32s: the sample rate, channel count, [[#PCM_format|PCM format]], and the initial AudioOutState.
  
Line 180: Line 180:
  
 
=== GetAudioInState ===
 
=== GetAudioInState ===
 
+
Returns an u32 '''AudioInState''' (0x00=Started, 0x01=Stopped).
Returns an AudioInState, 0x00=Started 0x01=Stopped (u32)
 
  
 
= audrec:u =
 
= audrec:u =
Line 234: Line 233:
 
| 2 || GetAudioRenderersProcessMasterVolume
 
| 2 || GetAudioRenderersProcessMasterVolume
 
|-
 
|-
| 3 || SetAudioRenderersProcessMasterVolume
+
| 3 || [3.0.0+] SetAudioRenderersProcessMasterVolume
 +
|-
 +
| 4 || [4.0.0+]
 
|}
 
|}
  
Line 263: Line 264:
 
|-
 
|-
 
| 9 || [[#GetAudioRendererRenderingTimeLimit]]
 
| 9 || [[#GetAudioRendererRenderingTimeLimit]]
 +
|-
 +
| 10 || [3.0.0+] RequestUpdateAudioRendererEx
 +
|-
 +
| 11 || [3.0.0+]
 
|}
 
|}
  
Line 308: Line 313:
  
 
== RequestSuspendForDebug ==
 
== RequestSuspendForDebug ==
 
+
Takes an u64 [[AM_services#AppletResourceUserId|AppletResourceUserId]].
Takes an [[AM_services#AppletResourceUserId|AppletResourceUserId]]. (u64)
 
  
 
== RequestResumeForDebug ==
 
== RequestResumeForDebug ==
 +
Takes an u64 [[AM_services#AppletResourceUserId|AppletResourceUserId]].
  
Takes an [[AM_services#AppletResourceUserId|AppletResourceUserId]]. (u64)
+
= audctl =
 +
This is "nn::audioctrl::detail::IAudioController".
 +
 
 +
{| class="wikitable" border="1"
 +
|-
 +
! Cmd || Name
 +
|-
 +
| 0 ||
 +
|-
 +
| 1 ||
 +
|-
 +
| 2 ||
 +
|-
 +
| 3 ||
 +
|-
 +
| 4 ||
 +
|-
 +
| 5 ||
 +
|-
 +
| 6 ||
 +
|-
 +
| 7 ||
 +
|-
 +
| 8 ||
 +
|-
 +
| 9 ||
 +
|-
 +
| 10 ||
 +
|-
 +
| 11 ||
 +
|-
 +
| 12 ||
 +
|-
 +
| 13 ||
 +
|-
 +
| 14 ||
 +
|-
 +
| 15 ||
 +
|-
 +
| 16 ||
 +
|-
 +
| 17 || [3.0.0+]
 +
|-
 +
| 18 || [3.0.0+]
 +
|-
 +
| 19 || [3.0.0+]
 +
|-
 +
| 20 || [3.0.0+]
 +
|-
 +
| 21 || [3.0.0+]
 +
|-
 +
| 22 || [3.0.0+]
 +
|-
 +
| 23 || [4.0.0+]
 +
|-
 +
| 24 || [4.0.0+]
 +
|-
 +
| 25 || [4.0.0+]
 +
|-
 +
| 26 || [4.0.0+]
 +
|}
  
 
= codecctl =
 
= codecctl =
Line 389: Line 454:
 
== IsCodecDeviceRequested ==
 
== IsCodecDeviceRequested ==
 
Returns a bool.
 
Returns a bool.
 +
 +
= hwopus =
 +
This is "nn::codec::detail::IHardwareOpusDecoderManager".
 +
 +
{| class="wikitable" border="1"
 +
|-
 +
! Cmd || Name
 +
|-
 +
| 0 || [[#OpenHardwareOpusDecoder]]
 +
|-
 +
| 1 || [[#GetHardwareOpusDecoderWorkBufferSize]]
 +
|-
 +
| 2 || [3.0.0+] OpenHardwareOpusDecoderEx
 +
|-
 +
| 3 || [3.0.0+] GetHardwareOpusDecoderWorkBufferSizeEx
 +
|}
 +
 +
== OpenHardwareOpusDecoder ==
 +
Takes two u32s '''SampleRate''' and '''ChannelCount''' packed as an u64, an u32 '''WorkBufferSize''' and an unknown handle. Returns an [[#IHardwareOpusDecoder]] object.
 +
 +
== GetHardwareOpusDecoderWorkBufferSize ==
 +
Takes two u32s '''SampleRate''' and '''ChannelCount''' packed as an u64. Returns the required size for the decoder's work buffer.
 +
 +
== IHardwareOpusDecoder ==
 +
This is "nn::codec::detail::IHardwareOpusDecoder".
 +
 +
{| class="wikitable" border="1"
 +
|-
 +
! Cmd || Name
 +
|-
 +
| 0 || [[#Decode]]
 +
|-
 +
| 1 || [[#SendDecoderContext]]
 +
|-
 +
| 2 || [3.0.0+] DecodeEx
 +
|-
 +
| 3 || [3.0.0+] SendDecoderContextEx
 +
|-
 +
| 4 || [4.0.0+]
 +
|-
 +
| 5 || [4.0.0+]
 +
|}
 +
 +
=== Decode ===
 +
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'''.
 +
 +
=== SendDecoderContext ===
 +
Takes a type-5 input buffer ('''DecoderContextIn'''). Sends the unknown context data to the hardware decoder.
 +
 +
= auddebug =
 +
This service doesn't exist in retail units.
  
 
[[Category:Services]]
 
[[Category:Services]]

Revision as of 19:34, 25 February 2018

audout:u

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

Cmd Name
0 #ListAudioOuts
1 #OpenAudioOut
2 [3.0.0+] #ListAudioOutsEx
3 [3.0.0+] #OpenAudioOutEx

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

ListAudioOutsEx

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

OpenAudioOutEx

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+] #AppendAudioOutBufferEx
8 [3.0.0+] #GetReleasedAudioOutBufferEx
9 [4.0.0+]
10 [4.0.0+]
11 [4.0.0+]

GetAudioOutState

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

StartAudioOut

Starts audio playback using data from appended buffers.

StopAudioOut

Stops audio playback.

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

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.

AppendAudioOutBufferEx

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

GetReleasedAudioOutBufferEx

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

audin:u

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

Cmd Name
0 ListAudioIns
1 OpenAudioIn
2 [3.0.0+] ListAudioInsEx
3 [3.0.0+] OpenAudioInEx
4 [3.0.0+] ListAudioInsExAndProbe

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+] AppendAudioInBufferEx
9 [3.0.0+] GetReleasedAudioInBufferEx
10 [3.0.0+] AppendAudioInBufferWithUserEventEx
11 [4.0.0+]
12 [4.0.0+]
13 [4.0.0+]

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
8 [3.0.0+] AppendFinalOutputRecorderBufferEx
9 [3.0.0+] GetReleasedFinalOutputRecorderBufferEx

audren:u

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

Cmd Name
0 OpenAudioRenderer
1 GetAudioRendererWorkBufferSize
2 GetAudioRenderersProcessMasterVolume
3 [3.0.0+] SetAudioRenderersProcessMasterVolume
4 [4.0.0+]

IAudioRenderer

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

Cmd Name
0 #GetAudioRendererSampleRate
1 #GetAudioRendererSampleCount
2 #GetAudioRendererMixBufferCount
3 #GetAudioRendererState
4 RequestUpdateAudioRenderer
5 StartAudioRenderer
6 StopAudioRenderer
7 QuerySystemEvent
8 #SetAudioRendererRenderingTimeLimit
9 #GetAudioRendererRenderingTimeLimit
10 [3.0.0+] RequestUpdateAudioRendererEx
11 [3.0.0+]

GetAudioRendererSampleRate

Returns the Sample Rate. (u32)

GetAudioRendererSampleCount

Returns the Sample Count. (u32)

GetAudioRendererMixBufferCount

Returns the number of Mix Buffers. (u32)

GetAudioRendererState

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

SetAudioRendererRenderingTimeLimit

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

GetAudioRendererRenderingTimeLimit

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

audout:a, audin:a, audrec:a, audren:a

This is "nn::audio::detail::IAudioOutManagerForApplet", "nn::audio::detail::IAudioInManagerForApplet", "nn::audio::detail::IFinalOutputRecorderManagerForApplet", "nn::audio::detail::IAudioRendererManagerForApplet".

Cmd Name
0 RequestSuspend
1 RequestResume

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
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 [3.0.0+]
18 [3.0.0+]
19 [3.0.0+]
20 [3.0.0+]
21 [3.0.0+]
22 [3.0.0+]
23 [4.0.0+]
24 [4.0.0+]
25 [4.0.0+]
26 [4.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 #OpenHardwareOpusDecoder
1 #GetHardwareOpusDecoderWorkBufferSize
2 [3.0.0+] OpenHardwareOpusDecoderEx
3 [3.0.0+] GetHardwareOpusDecoderWorkBufferSizeEx

OpenHardwareOpusDecoder

Takes two u32s SampleRate and ChannelCount packed as an u64, an u32 WorkBufferSize and an unknown handle. Returns an #IHardwareOpusDecoder object.

GetHardwareOpusDecoderWorkBufferSize

Takes two u32s SampleRate and ChannelCount packed as an u64. Returns the required size for the decoder's work buffer.

IHardwareOpusDecoder

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

Cmd Name
0 #Decode
1 #SendDecoderContext
2 [3.0.0+] DecodeEx
3 [3.0.0+] SendDecoderContextEx
4 [4.0.0+]
5 [4.0.0+]

Decode

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.

SendDecoderContext

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

auddebug

This service doesn't exist in retail units.