Debian Codegraph @

AudioEncode/adecode.h

raw symbols SCIP
1 /*
2 * Descent 3
3 * Copyright (C) 2024 Parallax Software
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19 #ifndef AUDIODECODE_H_
20 #define AUDIODECODE_H_
21
22 #include <cstdint>
23
24 namespace AudioDecoder {
25
26 class IAudioDecoder {
27 public:
28 virtual ~IAudioDecoder() {}
29
30 // Read data from the audio decoder.
31 // pBuffer: The buffer to receive the data from
32 // amount: How much data to read
33 // Returns the number of bytes read - zero when we're at the end of the file
34 virtual uint32_t Read(void *pBuffer, uint32_t amount) = 0;
35 };
36
37 // Create an audio decoder
38 // You supply a function for reading bytes from the compressed data via a
39 // void* pData handle, and the handle itself (typically a FILE *).
40 // Create_AudioDecoder returns a new AudioDecoder which can be used to
41 // read uncompressed decoded data from the compressed stream,
42 // and also returns the number of channels (1 or 2), the sample rate
43 // (e.g. 22050), and the number of samples contained in the compressed file
44 // (in case you want to pre-allocate a buffer to load them all into memory).
45 typedef int32_t (*ReadDataFunction)(void *pData, void *pBuffer, uint32_t amount);
46 IAudioDecoder *CreateDecoder(ReadDataFunction reader, void *pData, uint32_t &numChannels, uint32_t &sampleRate,
47 uint32_t &sampleCount);
48
49 } // namespace AudioDecoder
50
51 #endif