libnx  v4.2.1
hwopus.h
Go to the documentation of this file.
1 /**
2  * @file hwopus.h
3  * @brief Hardware Opus audio service IPC wrapper.
4  * @author yellows8
5  * @copyright libnx Authors
6  */
7 #pragma once
8 
9 #include "../types.h"
10 #include "../sf/service.h"
11 #include "../kernel/tmem.h"
12 
13 typedef struct {
14  Service s;
15  TransferMemory tmem;
16  bool multistream;
18 
19 /// This structure is the start of opusin for \ref hwopusDecodeInterleaved, with the actual opus packet following this.
20 /// These fields are big-endian.
21 typedef struct {
22  u32 size; ///< Size of the packet following this header.
23  u32 final_range; ///< Indicates the final range of the codec encoder's entropy coder. This can be left at zero.
24 } HwopusHeader;
25 
26 /// Used internally.
27 typedef struct {
28  s32 SampleRate;
29  s32 ChannelCount;
30  s32 TotalStreamCount;
31  s32 StereoStreamCount;
32  u8 channel_mapping[256];
34 
35 Result hwopusDecoderInitialize(HwopusDecoder* decoder, s32 SampleRate, s32 ChannelCount);
36 void hwopusDecoderExit(HwopusDecoder* decoder);
37 
38 /// Only available on [3.0.0+].
39 /// See libopus multistream docs.
40 Result hwopusDecoderMultistreamInitialize(HwopusDecoder* decoder, s32 SampleRate, s32 ChannelCount, s32 TotalStreamCount, s32 StereoStreamCount, u8 *channel_mapping);
41 
42 /// Decodes opus data.
43 Result hwopusDecodeInterleaved(HwopusDecoder* decoder, s32 *DecodedDataSize, s32 *DecodedSampleCount, const void* opusin, size_t opusin_size, s16 *pcmbuf, size_t pcmbuf_size);
44 
HwopusHeader::size
u32 size
Size of the packet following this header.
Definition: hwopus.h:22
u8
uint8_t u8
8-bit unsigned integer.
Definition: types.h:19
s16
int16_t s16
16-bit signed integer.
Definition: types.h:26
hwopusDecodeInterleaved
Result hwopusDecodeInterleaved(HwopusDecoder *decoder, s32 *DecodedDataSize, s32 *DecodedSampleCount, const void *opusin, size_t opusin_size, s16 *pcmbuf, size_t pcmbuf_size)
Decodes opus data.
TransferMemory
Transfer memory information structure.
Definition: tmem.h:13
s32
int32_t s32
32-bit signed integer.
Definition: types.h:27
HwopusHeader
This structure is the start of opusin for hwopusDecodeInterleaved, with the actual opus packet follow...
Definition: hwopus.h:21
HwopusHeader::final_range
u32 final_range
Indicates the final range of the codec encoder's entropy coder. This can be left at zero.
Definition: hwopus.h:23
HwopusDecoder
Definition: hwopus.h:13
u32
uint32_t u32
32-bit unsigned integer.
Definition: types.h:21
HwopusMultistreamState
Used internally.
Definition: hwopus.h:27
Result
u32 Result
Function error code result type.
Definition: types.h:44
hwopusDecoderMultistreamInitialize
Result hwopusDecoderMultistreamInitialize(HwopusDecoder *decoder, s32 SampleRate, s32 ChannelCount, s32 TotalStreamCount, s32 StereoStreamCount, u8 *channel_mapping)
Only available on [3.0.0+].
Service
Service object structure.
Definition: service.h:13