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  virtual bool isReady() const { Common::StackLock lock(_mutex); return _mixerReady; }
89 
90  virtual Common::Mutex &mutex() { return _mutex; }
91 
92  virtual 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);
100 
101  virtual void stopAll();
102  virtual void stopID(int id);
103  virtual void stopHandle(SoundHandle handle);
104 
105  virtual void pauseAll(bool paused);
106  virtual void pauseID(int id, bool paused);
107  virtual void pauseHandle(SoundHandle handle, bool paused);
108 
109  virtual bool isSoundIDActive(int id);
110  virtual int getSoundID(SoundHandle handle);
111 
112  virtual bool isSoundHandleActive(SoundHandle handle);
113 
114  virtual void muteSoundType(SoundType type, bool mute);
115  virtual bool isSoundTypeMuted(SoundType type) const;
116 
117  virtual void setChannelVolume(SoundHandle handle, byte volume);
118  virtual byte getChannelVolume(SoundHandle handle);
119  virtual void setChannelBalance(SoundHandle handle, int8 balance);
120  virtual int8 getChannelBalance(SoundHandle handle);
121  virtual void setChannelRate(SoundHandle handle, uint32 rate);
122  virtual uint32 getChannelRate(SoundHandle handle);
123  virtual void resetChannelRate(SoundHandle handle);
124 
125  virtual uint32 getSoundElapsedTime(SoundHandle handle);
126  virtual Timestamp getElapsedTime(SoundHandle handle);
127 
128  virtual void loopChannel(SoundHandle handle);
129 
130  virtual bool hasActiveChannelOfType(SoundType type);
131 
132  virtual void setVolumeForSoundType(SoundType type, int volume);
133  virtual int getVolumeForSoundType(SoundType type) const;
134 
135  virtual uint getOutputRate() const;
136  virtual bool getOutputStereo() const;
137  virtual uint getOutputBufSize() const;
138 
139 protected:
140  void insertChannel(SoundHandle *handle, Channel *chan);
141 
142 public:
152  int mixCallback(byte *samples, uint len);
153 
159  void setReady(bool ready);
160 };
161 
163 } // End of namespace Audio
164 
165 #endif
Definition: mixer.h:72
virtual void muteSoundType(SoundType type, bool mute)
virtual void pauseHandle(SoundHandle handle, bool paused)
virtual uint32 getSoundElapsedTime(SoundHandle handle)
virtual Timestamp getElapsedTime(SoundHandle handle)
virtual bool getOutputStereo() const
virtual Common::Mutex & mutex()
Definition: mixer_intern.h:90
virtual uint getOutputBufSize() const
virtual void stopHandle(SoundHandle handle)
int mixCallback(byte *samples, uint len)
Definition: mutex.h:51
virtual void pauseID(int id, bool paused)
virtual bool hasActiveChannelOfType(SoundType type)
Definition: timestamp.h:83
virtual void setChannelBalance(SoundHandle handle, int8 balance)
virtual void stopAll()
virtual uint32 getChannelRate(SoundHandle handle)
virtual void setChannelVolume(SoundHandle handle, byte volume)
virtual bool isReady() const
Definition: mixer_intern.h:88
Definition: mixer_intern.h:58
Definition: mixer.h:49
virtual void stopID(int id)
virtual void setChannelRate(SoundHandle handle, uint32 rate)
SoundType
Definition: mixer.h:62
Definition: mixer.h:59
virtual byte getChannelVolume(SoundHandle handle)
Definition: mutex.h:67
virtual void loopChannel(SoundHandle handle)
virtual void playStream(SoundType type, SoundHandle *handle, AudioStream *input, int id, byte volume, int8 balance, DisposeAfterUse::Flag autofreeStream, bool permanent, bool reverseStereo)
Definition: audiostream.h:50
virtual void resetChannelRate(SoundHandle handle)
virtual int getVolumeForSoundType(SoundType type) const
virtual void pauseAll(bool paused)
virtual bool isSoundIDActive(int id)
virtual int getSoundID(SoundHandle handle)
virtual void setVolumeForSoundType(SoundType type, int volume)
virtual int8 getChannelBalance(SoundHandle handle)
void setReady(bool ready)
Definition: system.h:37
virtual bool isSoundTypeMuted(SoundType type) const
virtual uint getOutputRate() const
virtual bool isSoundHandleActive(SoundHandle handle)