1//************************************ bs::framework - Copyright 2018 Marko Pintera **************************************//
2//*********** Licensed under the MIT license. See LICENSE.md for full terms. This notice is not to be removed. ***********//
3#pragma once
4
5#include "BsOAPrerequisites.h"
6#include "BsAudioDecoder.h"
7#include "vorbis/vorbisfile.h"
8
9namespace bs
10{
11 /** @addtogroup OpenAudio
12 * @{
13 */
14
15 /** Information used by the active decoder. */
16 struct OggDecoderData
17 {
18 OggDecoderData() = default;
19
20 SPtr<DataStream> stream;
21 UINT32 offset = 0;
22 };
23
24 /** Used for reading Ogg Vorbis audio data. */
25 class OggVorbisDecoder : public AudioDecoder
26 {
27 public:
28 OggVorbisDecoder();
29 ~OggVorbisDecoder();
30
31 /** @copydoc AudioDecoder::open */
32 bool open(const SPtr<DataStream>& stream, AudioDataInfo& info, UINT32 offset = 0) override;
33
34 /** @copydoc AudioDecoder::read */
35 UINT32 read(UINT8* samples, UINT32 numSamples) override;
36
37 /** @copydoc AudioDecoder::seek */
38 void seek(UINT32 offset) override;
39
40 /** @copydoc AudioDecoder::isValid */
41 bool isValid(const SPtr<DataStream>& stream, UINT32 offset = 0) override;
42 private:
43 OggDecoderData mDecoderData;
44 OggVorbis_File mOggVorbisFile;
45 UINT32 mChannelCount = 0;
46 };
47
48 /** @} */
49}
50