ScummVM API documentation
audio_player.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 MTROPOLIS_AUDIO_PLAYER_H
23#define MTROPOLIS_AUDIO_PLAYER_H
24
25#include "common/mutex.h"
26
27#include "audio/audiostream.h"
28#include "audio/mixer.h"
29
30namespace MTropolis {
31
32struct AudioMetadata;
33class CachedAudio;
34
35// Audio player, this does not support requeueing. If the sound exhausts, then you must create a
36// new audio player. In particular, since time is being tracked separately, if the loop status
37// changes when the timer thinks the sound should still be playing, but the sound has actually
38// exhausted, then the sound needs to be requeued.
40public:
41 AudioPlayer(Audio::Mixer *mixer, byte volume, int8 balance, const Common::SharedPtr<AudioMetadata> &metadata, const Common::SharedPtr<CachedAudio> &audio, bool isLooping, size_t currentPos, size_t startPos, size_t endPos);
43
44 int readBuffer(int16 *buffer, const int numSamples) override;
45 bool isStereo() const override;
46 int getRate() const override;
47 bool endOfData() const override;
48
49 void sendToMixer(Audio::Mixer *mixer, byte volume, int8 balance);
50 void stop();
51
52private:
53 Common::Mutex _mutex;
54
57 Audio::SoundHandle _handle;
58 bool _isLooping;
59 bool _exhausted;
60 size_t _currentPos;
61 size_t _startPos;
62 size_t _endPos;
63 Audio::Mixer *_mixer;
64};
65
66} // End of namespace MTropolis
67
68#endif
Definition: audiostream.h:50
Definition: mixer.h:70
Definition: mixer.h:49
Definition: mutex.h:67
Definition: ptr.h:159
Definition: audio_player.h:39
int readBuffer(int16 *buffer, const int numSamples) override
bool endOfData() const override
bool isStereo() const override
int getRate() const override
Definition: actions.h:25