aboutsummaryrefslogtreecommitdiff
path: root/engines/tsage/sound.cpp
diff options
context:
space:
mode:
authorPaul Gilbert2011-07-27 22:20:29 +1000
committerPaul Gilbert2011-07-28 07:30:42 +1000
commit0034257976dc2ad5c91cb3825021681c4919811f (patch)
tree7b5289c997469e41531ee13e382fc3e08f15f16f /engines/tsage/sound.cpp
parent034bbde2046ec2db0fdd746e032ca7f19f00f4fe (diff)
downloadscummvm-rg350-0034257976dc2ad5c91cb3825021681c4919811f.tar.gz
scummvm-rg350-0034257976dc2ad5c91cb3825021681c4919811f.tar.bz2
scummvm-rg350-0034257976dc2ad5c91cb3825021681c4919811f.zip
TSAGE: Sound Fx is now playing
Diffstat (limited to 'engines/tsage/sound.cpp')
-rw-r--r--engines/tsage/sound.cpp65
1 files changed, 20 insertions, 45 deletions
diff --git a/engines/tsage/sound.cpp b/engines/tsage/sound.cpp
index 87c31c3433..0e763cd0c3 100644
--- a/engines/tsage/sound.cpp
+++ b/engines/tsage/sound.cpp
@@ -20,6 +20,7 @@
*
*/
+#include "audio/decoders/raw.h"
#include "common/config-manager.h"
#include "tsage/core.h"
#include "tsage/globals.h"
@@ -158,9 +159,7 @@ Common::List<SoundDriverEntry> &SoundManager::buildDriverList(bool detectFlag) {
void SoundManager::installConfigDrivers() {
installDriver(ADLIB_DRIVER_NUM);
-#ifdef DEBUG
installDriver(SBLASTER_DRIVER_NUM);
-#endif
}
Common::List<SoundDriverEntry> &SoundManager::getDriverList(bool detectFlag) {
@@ -2801,6 +2800,7 @@ AdlibFxSoundDriver::AdlibFxSoundDriver(): SoundDriver() {
_mixer = _vm->_mixer;
_sampleRate = _mixer->getOutputRate();
+ _audioStream = NULL;
// _mixer->playStream(Audio::Mixer::kPlainSoundType, &_soundHandle, this, -1, Audio::Mixer::kMaxChannelVolume, 0, DisposeAfterUse::NO, true);
/*
Common::set_to(_channelVoiced, _channelVoiced + ADLIB_CHANNEL_COUNT, false);
@@ -2818,7 +2818,7 @@ AdlibFxSoundDriver::AdlibFxSoundDriver(): SoundDriver() {
}
AdlibFxSoundDriver::~AdlibFxSoundDriver() {
-// _mixer->stopHandle(_soundHandle);
+ _mixer->stopHandle(_soundHandle);
}
bool AdlibFxSoundDriver::open() {
@@ -2878,14 +2878,28 @@ void AdlibFxSoundDriver::proc32(const byte *channelData, int dataOffset, int pro
_channelData = channelData + dataOffset;
_soundData = _channelData + 18;
+ // Make a copy of the buffer
+ int dataSize = _vm->_memoryManager.getSize(channelData);
+ byte *soundData = (byte *)malloc(dataSize - dataOffset);
+ Common::copy(_channelData, _channelData + (dataSize - dataOffset), soundData);
+
+ _audioStream = Audio::makeQueuingAudioStream(11025, false);
+ _audioStream->queueBuffer(soundData, dataSize - dataOffset, DisposeAfterUse::YES, Audio::FLAG_UNSIGNED);
+
// Start the new sound
- debug("Start sound");
+ if (!_mixer->isSoundHandleActive(_soundHandle))
+ _mixer->playStream(Audio::Mixer::kSFXSoundType, &_soundHandle, _audioStream);
}
void AdlibFxSoundDriver::updateVoice(int channel) {
if (_channelData) {
write(208);
-
+/*
+ if (_audioStream && _audioStream->numQueuedStreams() != 0) {
+ _mixer->stopAll();
+ _audioStream = NULL;
+ }
+*/
_channelData = NULL;
_v45062 = 0;
_v45066 = 0;
@@ -2911,46 +2925,7 @@ void AdlibFxSoundDriver::proc42(int channel, int cmd, int value, int *v1, int *v
}
void AdlibFxSoundDriver::write(int v) {
- /*
- port[adlib_port + 12] = v;
- for (int i = 0; i < 100; ++i) {
- if (!port[adlib_port + 12] & 0x80)
- break;
- }
- */
-}
-
-void AdlibFxSoundDriver::flush() {
- Common::StackLock slock(SoundManager::sfManager()._serverDisabledMutex);
-
- // No data output yet
-}
-
-
-
-int AdlibFxSoundDriver::readBuffer(int16 *buffer, const int numSamples) {
- update(buffer, numSamples);
- return numSamples;
-}
-
-void AdlibFxSoundDriver::update(int16 *buf, int len) {
-/*
- static int samplesLeft = 0;
- while (len != 0) {
- int count = samplesLeft;
- if (count > len) {
- count = len;
- }
- samplesLeft -= count;
- len -= count;
- YM3812UpdateOne(_opl, buf, count);
- if (samplesLeft == 0) {
- flush();
- samplesLeft = _sampleRate / 50;
- }
- buf += count;
- }
-*/
+ // No implementation
}
void AdlibFxSoundDriver::write209() {