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
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (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, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 *
21 */
22
23 #include "backends/mixer/nullmixer/nullsdl-mixer.h"
24 #include "common/savefile.h"
25
NullSdlMixerManager()26 NullSdlMixerManager::NullSdlMixerManager() : SdlMixerManager() {
27 _outputRate = 22050;
28 _callsCounter = 0;
29 _callbackPeriod = 10;
30 _samples = 8192;
31 while (_samples * 16 > _outputRate * 2)
32 _samples >>= 1;
33 _samplesBuf = new uint8[_samples * 4];
34 }
35
~NullSdlMixerManager()36 NullSdlMixerManager::~NullSdlMixerManager() {
37 delete _samplesBuf;
38 }
39
init()40 void NullSdlMixerManager::init() {
41 _mixer = new Audio::MixerImpl(_outputRate);
42 assert(_mixer);
43 _mixer->setReady(true);
44 }
45
suspendAudio()46 void NullSdlMixerManager::suspendAudio() {
47 _audioSuspended = true;
48 }
49
resumeAudio()50 int NullSdlMixerManager::resumeAudio() {
51 if (!_audioSuspended) {
52 return -2;
53 }
54 _audioSuspended = false;
55 return 0;
56 }
57
58
startAudio()59 void NullSdlMixerManager::startAudio() {
60 }
61
callbackHandler(byte * samples,int len)62 void NullSdlMixerManager::callbackHandler(byte *samples, int len) {
63 assert(_mixer);
64 _mixer->mixCallback(samples, len);
65 }
66
update()67 void NullSdlMixerManager::update() {
68 if (_audioSuspended) {
69 return;
70 }
71 _callsCounter++;
72 if ((_callsCounter % _callbackPeriod) == 0) {
73 callbackHandler(_samplesBuf, _samples);
74 }
75 }
76