Leviathan  0.8.0.0
Leviathan game engine
SoundInternalTypes.h
Go to the documentation of this file.
1 // Leviathan Game Engine
2 // Copyright (c) 2012-2018 Henri Hyyryläinen
3 #pragma once
4 #include "Define.h"
5 // ------------------------------------ //
6 #include "ProceduralSound.h"
7 
8 #include "cAudio/IAudioDecoder.h"
9 #include "cAudio/IAudioDecoderFactory.h"
10 #include "cAudio/IDataSourceFactory.h"
11 
12 
13 namespace Leviathan { namespace Sound {
14 
16 class ProceduralSoundStream : public cAudio::IAudioDecoder {
17 public:
18  DLLEXPORT ProceduralSoundStream(ProceduralSoundData::pointer data);
20 
21  // cAudio interface //
22 
23  DLLEXPORT cAudio::AudioFormats getFormat() override;
24 
25  DLLEXPORT int getFrequency() override;
26 
27  DLLEXPORT bool isSeekingSupported() override;
28 
29  DLLEXPORT bool isValid() override;
30 
31  DLLEXPORT int readAudioData(void* output, int amount) override;
32 
33  DLLEXPORT bool setPosition(int position, bool relative) override;
34 
35  DLLEXPORT bool seek(float seconds, bool relative) override;
36 
37  DLLEXPORT float getTotalTime() override;
38 
39  DLLEXPORT int getTotalSize() override;
40 
41  DLLEXPORT int getCompressedSize() override;
42 
43  DLLEXPORT float getCurrentTime() override;
44 
45  DLLEXPORT int getCurrentPosition() override;
46 
48 
49  DLLEXPORT cAudio::cAudioString getType() const override;
50 
51 protected:
53  DLLEXPORT void onStreamEnded();
54 
55 private:
57  ProceduralSoundData::pointer Data;
58 };
59 
60 
61 
62 // //! Factory class for ProceduralSoundSource converting to ProceduralSoundStream
63 // class ProceduralSoundStreamFactory : public cAudio::IAudioDecoderFactory {
64 // public:
65 // //! Called by cAudio when the user of ProceduralSoundData opens the sound stream
66 // returned
67 // //! from SoundDevice
68 // cAudio::IAudioDecoder* CreateAudioDecoder(cAudio::IDataSource* stream) override;
69 // };
70 
71 // class ProceduralSoundSource : public cAudio::IDataSource {
72 // public:
73 // ProceduralSoundSource(ProceduralSoundData::pointer data) : Data(data) {}
74 
75 // DLLEXPORT bool isValid() override
76 // {
77 // return Data != nullptr && Data->IsValid();
78 // }
79 
80 // DLLEXPORT int getCurrentPos() override
81 // {
82 // return 0;
83 // }
84 
85 // DLLEXPORT int getSize() override
86 // {
87 // return 0;
88 // }
89 
90 // DLLEXPORT int read(void* output, int size) override
91 // {
92 // (void)output;
93 // (void)size;
94 // return 0;
95 // }
96 
97 // DLLEXPORT bool seek(int amount, bool relative) override
98 // {
99 // (void)amount;
100 // (void)relative;
101 // return false;
102 // }
103 
104 // ProceduralSoundData::pointer Data;
105 // };
106 
107 // //! Factory class for ProceduralSoundStream
108 // class ProceduralSoundSourceFactory : public cAudio::IDataSourceFactory, public ThreadSafe {
109 // public:
110 // DLLEXPORT ProceduralSoundSourceFactory();
111 // DLLEXPORT ~ProceduralSoundSourceFactory();
112 
113 
114 // DLLEXPORT cAudio::IDataSource* CreateDataSource(
115 // const char* filename, bool streamingRequested) override;
116 
117 // //! \brief Reserves a stream name for ProceduralSoundData instance
118 // DLLEXPORT void ReserveStream(
119 // const std::string& fakefilename, ProceduralSoundData::pointer data);
120 
121 
122 // //! \brief Removes a reserved stream, blocking CreateAudioDecoder from using the
123 // //! same data twice. Called from ProceduralSoundStreamFactory when it creates one to not
124 // //! allow duplicates
125 // //!
126 // //! Can also be called if the sound source needs to be destroyed before the creation is
127 // //! finalized
128 // DLLEXPORT void UnReserveStream(ProceduralSoundData::pointer data);
129 
130 // private:
131 // //! Contains streams that can be returned by CreateAudioDecoder to cAudio
132 // //! \note Must be locked when changing this
133 // std::map<std::string, ProceduralSoundData::pointer> m_OpenStream;
134 // };
135 
136 }} // namespace Leviathan::Sound
Used to feed data retrieved from a callback to cAudio::IAudioSource.
DLLEXPORT bool seek(float seconds, bool relative) override
DLLEXPORT bool isSeekingSupported() override
DLLEXPORT cAudio::cAudioString getType() const override
DLLEXPORT int readAudioData(void *output, int amount) override
DLLEXPORT int getCurrentCompressedPosition() override
DLLEXPORT cAudio::AudioFormats getFormat() override
DLLEXPORT ProceduralSoundStream(ProceduralSoundData::pointer data)
DLLEXPORT bool setPosition(int position, bool relative) override
#define DLLEXPORT
Definition: Include.h:115
The access mask controls which registered functions and classes a script sees.
Definition: GameModule.h:12
DLLEXPORT void onStreamEnded()
Called when the stream should close or if the data source has been closed.