Skylicht Engine
Loading...
Searching...
No Matches
CAudioReader.h
1/*
2!@
3MIT License
4
5Copyright (c) 2012 - 2019 Skylicht Technology CO., LTD
6
7Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files
8(the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify,
9merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
10subject to the following conditions:
11
12The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
13
14THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
15INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
16IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
17WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19
20This file is part of the "Skylicht Engine".
21https://github.com/skylicht-lab/skylicht-engine
22!#
23*/
24
25#ifndef _SKYLICHTAUDIO_AUDIOEREADER_
26#define _SKYLICHTAUDIO_AUDIOEREADER_
27
28#include "Driver/ISoundSource.h"
29#include "Driver/ISoundDriver.h"
30#include "Decoder/IAudioDecoder.h"
31#include "Thread/IMutex.h"
32
33using namespace Skylicht::System;
34
35namespace Skylicht
36{
37 namespace Audio
38 {
45 class CAudioReader
46 {
47 protected:
48 bool m_isError;
49 int m_initState;
50
51 IAudioDecoder* m_decoder;
52 ISoundDriver* m_driver;
53
54 IMutex* m_mutex;
55 IStream* m_stream;
56
57 ISoundSource::ESourceState m_state;
58 IAudioDecoder::EDecoderType m_decodeType;
59
60 public:
61 CAudioReader(IStream* stream, IAudioDecoder::EDecoderType type, ISoundDriver* driver);
62
63 CAudioReader(const char* file, ISoundDriver* driver);
64
65 virtual ~CAudioReader();
66
70 void initReader();
71
76 EStatus initDecoder();
77
84 EStatus readAudio(unsigned char* data, int size);
85
90 IAudioDecoder::EDecoderType getDecoderType()
91 {
92 return m_decodeType;
93 }
94
100 {
101 return m_decoder;
102 }
103
109 {
110 return m_stream;
111 }
112
117 ISoundSource::ESourceState getState()
118 {
119 return m_state;
120 }
121 };
122 }
123}
124
125#endif
void initReader()
Initialize the reader and create the appropriate decoder.
ISoundSource::ESourceState getState()
Get the current state of the reader.
Definition CAudioReader.h:117
EStatus readAudio(unsigned char *data, int size)
Read and decode audio data into a buffer as raw PCM samples.
IAudioDecoder::EDecoderType getDecoderType()
Get the decoder type.
Definition CAudioReader.h:90
IAudioDecoder * getDecoder()
Get the underlying decoder.
Definition CAudioReader.h:99
IStream * getStream()
Get the underlying stream.
Definition CAudioReader.h:108
EStatus initDecoder()
Initialize the decoder.
Definition IAudioDecoder.h:46
Definition ISoundDriver.h:36
Interface for an audio data stream (File, Memory, etc.).
Definition IStream.h:107
Definition IMutex.h:34
Handles all core audio functionality.
Definition AudioDebugLog.h:31
The foundation for thread and process handling.
Definition CNullMutex.h:32
Everything in the Skylicht Engine. You can start by looking at the topics.
Definition AudioDebugLog.h:29