ScummVM API documentation
mixer_intern.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef AUDIO_MIXER_INTERN_H
23 #define AUDIO_MIXER_INTERN_H
24 
25 #include "common/scummsys.h"
26 #include "common/mutex.h"
27 #include "audio/mixer.h"
28 
29 namespace Audio {
30 
58 class MixerImpl : public Mixer {
59 private:
60  enum {
61  NUM_CHANNELS = 32
62  };
63 
64  Common::Mutex _mutex;
65 
66  const uint _sampleRate;
67  const bool _stereo;
68  const uint _outBufSize;
69  bool _mixerReady;
70  uint32 _handleSeed;
71 
72  struct SoundTypeSettings {
73  SoundTypeSettings() : mute(false), volume(kMaxMixerVolume) {}
74 
75  bool mute;
76  int volume;
77  };
78 
79  SoundTypeSettings _soundTypeSettings[4];
80  Channel *_channels[NUM_CHANNELS];
81 
82 
83 public:
84 
85  MixerImpl(uint sampleRate, bool stereo = true, uint outBufSize = 0);
86  ~MixerImpl();
87 
88  bool isReady() const override { Common::StackLock lock(_mutex); return _mixerReady; }
89 
90  Common::Mutex &mutex() override { return _mutex; }
91 
92  void playStream(
93  SoundType type,
94  SoundHandle *handle,
95  AudioStream *input,
96  int id, byte volume, int8 balance,
97  DisposeAfterUse::Flag autofreeStream,
98  bool permanent,
99  bool reverseStereo) override;
100 
101  void stopAll() override;
102  void stopID(int id) override;
103  void stopHandle(SoundHandle handle) override;
104 
105  void pauseAll(bool paused) override;
106  void pauseID(int id, bool paused) override;
107  void pauseHandle(SoundHandle handle, bool paused) override;
108 
109  bool isSoundIDActive(int id) override;
110  int getSoundID(SoundHandle handle) override;
111 
112  bool isSoundHandleActive(SoundHandle handle) override;
113 
114  void muteSoundType(SoundType type, bool mute) override;
115  bool isSoundTypeMuted(SoundType type) const override;
116 
117  void setChannelVolume(SoundHandle handle, byte volume) override;
118  byte getChannelVolume(SoundHandle handle) override;
119  void setChannelBalance(SoundHandle handle, int8 balance) override;
120  int8 getChannelBalance(SoundHandle handle) override;
121  void setChannelFaderL(SoundHandle handle, uint8 scaleL) override;
122  uint8 getChannelFaderL(SoundHandle handle) override;
123  void setChannelFaderR(SoundHandle handle, uint8 scaleR) override;
124  uint8 getChannelFaderR(SoundHandle handle) override;
125  void setChannelRate(SoundHandle handle, uint32 rate) override;
126  uint32 getChannelRate(SoundHandle handle) override;
127  void resetChannelRate(SoundHandle handle) override;
128 
129  uint32 getSoundElapsedTime(SoundHandle handle) override;
130  Timestamp getElapsedTime(SoundHandle handle) override;
131 
132  void loopChannel(SoundHandle handle) override;
133 
134  bool hasActiveChannelOfType(SoundType type) override;
135 
136  void setVolumeForSoundType(SoundType type, int volume) override;
137  int getVolumeForSoundType(SoundType type) const override;
138 
139  uint getOutputRate() const override;
140  bool getOutputStereo() const override;
141  uint getOutputBufSize() const override;
142 
143 protected:
144  void insertChannel(SoundHandle *handle, Channel *chan);
145 
146 public:
156  int mixCallback(byte *samples, uint len);
157 
163  void setReady(bool ready);
164 };
165 
167 } // End of namespace Audio
168 
169 #endif
Definition: mixer.h:83
uint32 getChannelRate(SoundHandle handle) override
void resetChannelRate(SoundHandle handle) override
void loopChannel(SoundHandle handle) override
uint8 getChannelFaderR(SoundHandle handle) override
uint getOutputBufSize() const override
void setVolumeForSoundType(SoundType type, int volume) override
bool getOutputStereo() const override
uint getOutputRate() const override
int mixCallback(byte *samples, uint len)
Definition: mutex.h:51
Timestamp getElapsedTime(SoundHandle handle) override
bool isSoundHandleActive(SoundHandle handle) override
Definition: timestamp.h:83
void stopAll() override
bool isReady() const override
Definition: mixer_intern.h:88
void setChannelRate(SoundHandle handle, uint32 rate) override
void pauseHandle(SoundHandle handle, bool paused) override
byte getChannelVolume(SoundHandle handle) override
Definition: mixer_intern.h:58
Definition: mixer.h:49
bool isSoundIDActive(int id) override
SoundType
Definition: mixer.h:73
Definition: mixer.h:70
void setChannelVolume(SoundHandle handle, byte volume) override
bool isSoundTypeMuted(SoundType type) const override
uint32 getSoundElapsedTime(SoundHandle handle) override
void pauseID(int id, bool paused) override
void playStream(SoundType type, SoundHandle *handle, AudioStream *input, int id, byte volume, int8 balance, DisposeAfterUse::Flag autofreeStream, bool permanent, bool reverseStereo) override
void pauseAll(bool paused) override
void muteSoundType(SoundType type, bool mute) override
Definition: mutex.h:67
Definition: audiostream.h:50
void setChannelFaderR(SoundHandle handle, uint8 scaleR) override
bool hasActiveChannelOfType(SoundType type) override
uint8 getChannelFaderL(SoundHandle handle) override
void stopHandle(SoundHandle handle) override
void setChannelFaderL(SoundHandle handle, uint8 scaleL) override
void stopID(int id) override
int8 getChannelBalance(SoundHandle handle) override
Common::Mutex & mutex() override
Definition: mixer_intern.h:90
void setReady(bool ready)
int getSoundID(SoundHandle handle) override
void setChannelBalance(SoundHandle handle, int8 balance) override
Definition: system.h:38
int getVolumeForSoundType(SoundType type) const override