OpenCore  1.0.4
OpenCore Bootloader
Loading...
Searching...
No Matches
AudioDecode.c
Go to the documentation of this file.
1/*
2 * File: AudioDxe.c
3 *
4 * Copyright (c) 2021 vit9696
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in all
14 * copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 */
24
25#include "AudioDxe.h"
26#include <Library/OcMp3Lib.h>
27#include <Library/OcWaveLib.h>
28
48STATIC
49EFI_STATUS
50EFIAPI
53 IN CONST VOID *InBuffer,
54 IN UINT32 InBufferSize,
55 OUT VOID **OutBuffer,
56 OUT UINT32 *OutBufferSize,
57 OUT EFI_AUDIO_IO_PROTOCOL_FREQ *Frequency,
59 OUT UINT8 *Channels,
60 IN BOOLEAN InPlace
61 )
62{
63 EFI_STATUS Status;
64
65 Status = OcDecodeWave (
66 (UINT8 *)InBuffer,
67 InBufferSize,
68 (UINT8 **)OutBuffer,
69 OutBufferSize,
70 Frequency,
71 Bits,
72 Channels
73 );
74 if (EFI_ERROR (Status)) {
75 return Status;
76 }
77
78 if (!InPlace) {
79 *OutBuffer = AllocateCopyPool (*OutBufferSize, *OutBuffer);
80 if (*OutBuffer == NULL) {
81 return EFI_OUT_OF_RESOURCES;
82 }
83 }
84
85 return EFI_SUCCESS;
86}
87
105STATIC
106EFI_STATUS
107EFIAPI
110 IN CONST VOID *InBuffer,
111 IN UINT32 InBufferSize,
112 OUT VOID **OutBuffer,
113 OUT UINT32 *OutBufferSize,
114 OUT EFI_AUDIO_IO_PROTOCOL_FREQ *Frequency,
116 OUT UINT8 *Channels
117 )
118{
119 EFI_STATUS Status;
120
121 Status = OcDecodeMp3 (
122 InBuffer,
123 InBufferSize,
124 OutBuffer,
125 OutBufferSize,
126 Frequency,
127 Bits,
128 Channels
129 );
130
131 return Status;
132}
133
151STATIC
152EFI_STATUS
153EFIAPI
156 IN CONST VOID *InBuffer,
157 IN UINT32 InBufferSize,
158 OUT VOID **OutBuffer,
159 OUT UINT32 *OutBufferSize,
160 OUT EFI_AUDIO_IO_PROTOCOL_FREQ *Frequency,
162 OUT UINT8 *Channels
163 )
164{
165 EFI_STATUS Status;
166
167 Status = AudioDecodeMp3 (
168 This,
169 InBuffer,
170 InBufferSize,
171 OutBuffer,
172 OutBufferSize,
173 Frequency,
174 Bits,
175 Channels
176 );
177 if (EFI_ERROR (Status)) {
178 Status = AudioDecodeWave (
179 This,
180 InBuffer,
181 InBufferSize,
182 OutBuffer,
183 OutBufferSize,
184 Frequency,
185 Bits,
186 Channels,
187 FALSE
188 );
189 }
190
191 return Status;
192}
193
199 .DecodeAny = AudioDecodeAny,
200 .DecodeWave = AudioDecodeWave,
201 .DecodeMp3 = AudioDecodeMp3
202};
EFI_AUDIO_DECODE_PROTOCOL gEfiAudioDecodeProtocol
STATIC EFI_STATUS EFIAPI AudioDecodeMp3(IN EFI_AUDIO_DECODE_PROTOCOL *This, IN CONST VOID *InBuffer, IN UINT32 InBufferSize, OUT VOID **OutBuffer, OUT UINT32 *OutBufferSize, OUT EFI_AUDIO_IO_PROTOCOL_FREQ *Frequency, OUT EFI_AUDIO_IO_PROTOCOL_BITS *Bits, OUT UINT8 *Channels)
STATIC EFI_STATUS EFIAPI AudioDecodeAny(IN EFI_AUDIO_DECODE_PROTOCOL *This, IN CONST VOID *InBuffer, IN UINT32 InBufferSize, OUT VOID **OutBuffer, OUT UINT32 *OutBufferSize, OUT EFI_AUDIO_IO_PROTOCOL_FREQ *Frequency, OUT EFI_AUDIO_IO_PROTOCOL_BITS *Bits, OUT UINT8 *Channels)
STATIC EFI_STATUS EFIAPI AudioDecodeWave(IN EFI_AUDIO_DECODE_PROTOCOL *This, IN CONST VOID *InBuffer, IN UINT32 InBufferSize, OUT VOID **OutBuffer, OUT UINT32 *OutBufferSize, OUT EFI_AUDIO_IO_PROTOCOL_FREQ *Frequency, OUT EFI_AUDIO_IO_PROTOCOL_BITS *Bits, OUT UINT8 *Channels, IN BOOLEAN InPlace)
Definition AudioDecode.c:51
EFI_AUDIO_IO_PROTOCOL_FREQ
Definition AudioIo.h:104
EFI_AUDIO_IO_PROTOCOL_BITS
Definition AudioIo.h:93
EFI_STATUS OcDecodeMp3(IN CONST VOID *InBuffer, IN UINT32 InBufferSize, OUT VOID **OutBuffer, OUT UINT32 *OutBufferSize, OUT EFI_AUDIO_IO_PROTOCOL_FREQ *Frequency, OUT EFI_AUDIO_IO_PROTOCOL_BITS *Bits, OUT UINT8 *Channels)
Definition OcMp3Lib.c:89
EFI_STATUS OcDecodeWave(IN UINT8 *Buffer, IN UINTN BufferSize, OUT UINT8 **RawBuffer, OUT UINT32 *RawBufferSize, OUT EFI_AUDIO_IO_PROTOCOL_FREQ *Frequency, OUT EFI_AUDIO_IO_PROTOCOL_BITS *Bits, OUT UINT8 *Channels)
Definition OcWaveLib.c:28