1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
#include "sci/include/sfx_time.h"
#include "sci/include/sfx_pcm.h"
#include "engines/engine.h"
#include "sound/audiostream.h"
#include "sound/mixer.h"
static int pcmout_scummvm_framesize;
static Audio::AppendableAudioStream * pcmout_scummvm_audiostream;
static Audio::SoundHandle pcmout_scummvm_sound_handle;
static int pcmout_scummvm_init(sfx_pcm_device_t *self) {
int pcmout_scummvm_audiostream_flags = Audio::Mixer::FLAG_16BITS | Audio::Mixer::FLAG_STEREO;
#ifdef SCUMM_LITTLE_ENDIAN
pcmout_scummvm_audiostream_flags |= Audio::Mixer::FLAG_LITTLE_ENDIAN;
#endif
self->buf_size = 2048 << 1;
self->conf.rate = g_engine->_mixer->getOutputRate();
self->conf.stereo = SFX_PCM_STEREO_LR;
self->conf.format = SFX_PCM_FORMAT_S16_NATIVE;
pcmout_scummvm_framesize = SFX_PCM_FRAME_SIZE(self->conf);
pcmout_scummvm_audiostream = Audio::makeAppendableAudioStream(self->conf.rate, pcmout_scummvm_audiostream_flags);
::g_engine->_mixer->playInputStream(Audio::Mixer::kSFXSoundType, &pcmout_scummvm_sound_handle, pcmout_scummvm_audiostream);
return SFX_OK;
}
static void pcmout_scummvm_exit(sfx_pcm_device_t *self) {
}
static int pcmout_scummvm_output(sfx_pcm_device_t *self, byte *buf, int count,
sfx_timestamp_t *timestamp) {
byte *__buf = new byte[count * pcmout_scummvm_framesize];
memcpy(__buf, buf, count * pcmout_scummvm_framesize);
pcmout_scummvm_audiostream->queueBuffer(__buf, count * pcmout_scummvm_framesize);
return SFX_OK;
}
sfx_pcm_device_t sfx_pcm_driver_scummvm = {
"ScummVM",
"0.1",
&pcmout_scummvm_init,
&pcmout_scummvm_exit,
NULL,
&pcmout_scummvm_output,
NULL,
{0, 0, 0},
0,
NULL,
NULL
};
|