aboutsummaryrefslogtreecommitdiff
path: root/sound
diff options
context:
space:
mode:
authorLionel Ulmer2002-04-28 14:01:40 +0000
committerLionel Ulmer2002-04-28 14:01:40 +0000
commitc134803976bcaccd9fe76da14b81962ebc531e81 (patch)
tree58f7c61c478392e4577be8bee86d05779bd17f89 /sound
parent9d55ab4061725b50b1549f0872d144a5f4cd2819 (diff)
downloadscummvm-rg350-c134803976bcaccd9fe76da14b81962ebc531e81.tar.gz
scummvm-rg350-c134803976bcaccd9fe76da14b81962ebc531e81.tar.bz2
scummvm-rg350-c134803976bcaccd9fe76da14b81962ebc531e81.zip
MI1 CD audio should work better now. Still a bit flaky but should be
better than before :-) svn-id: r4128
Diffstat (limited to 'sound')
-rw-r--r--sound/mixer.cpp17
-rw-r--r--sound/mixer.h6
2 files changed, 16 insertions, 7 deletions
diff --git a/sound/mixer.cpp b/sound/mixer.cpp
index ccbe3e354c..76394c6fd6 100644
--- a/sound/mixer.cpp
+++ b/sound/mixer.cpp
@@ -64,9 +64,8 @@ int SoundMixer::play_raw(PlayingSoundHandle *handle, void *sound, uint32 size, u
int SoundMixer::play_mp3(PlayingSoundHandle *handle, void *sound, uint32 size, byte flags) {
return insert(handle, new Channel_MP3(this, sound, size, flags));
}
-int SoundMixer::play_mp3_cdtrack(PlayingSoundHandle *handle, int index, FILE* file, mad_timer_t duration) {
+int SoundMixer::play_mp3_cdtrack(PlayingSoundHandle *handle, FILE* file, mad_timer_t duration) {
/* Stop the previously playing CD track (if any) */
- stop(index);
return insert(handle, new Channel_MP3_CDMUSIC(this, file, duration));
}
#endif
@@ -135,6 +134,12 @@ void SoundMixer::set_volume(int volume) {
_volume_table[i] =((int8)i) * volume;
}
+#ifdef COMPRESSED_SOUND_FILE
+bool SoundMixer::Channel::sound_finished() {
+ warning("Should never be called on a non-MP3 mixer ");
+ return false;
+}
+#endif
/* RAW mixer */
SoundMixer::Channel_RAW::Channel_RAW(SoundMixer *mixer, void *sound, uint32 size, uint rate, byte flags) {
@@ -418,10 +423,6 @@ void SoundMixer::Channel_MP3_CDMUSIC::mix(int16 *data, uint len) {
frame_duration = _frame.header.duration;
mad_timer_negate(&frame_duration);
mad_timer_add(&_duration, frame_duration);
- if (mad_timer_compare(_duration, mad_timer_zero) < 0) {
- real_destroy();
- return;
- }
if (mad_frame_decode(&_frame, &_stream) == -1) {
if (_stream.error == MAD_ERROR_BUFLEN) {
int not_decoded;
@@ -450,6 +451,10 @@ void SoundMixer::Channel_MP3_CDMUSIC::mix(int16 *data, uint len) {
}
}
+bool SoundMixer::Channel_MP3_CDMUSIC::sound_finished() {
+ return mad_timer_compare(_duration, mad_timer_zero) <= 0;
+}
+
void SoundMixer::Channel_MP3_CDMUSIC::real_destroy() {
free(_ptr);
_mixer->uninsert(this);
diff --git a/sound/mixer.h b/sound/mixer.h
index 7986f384a6..4334dc6ea4 100644
--- a/sound/mixer.h
+++ b/sound/mixer.h
@@ -36,6 +36,9 @@ private:
virtual void mix(int16 *data, uint len) = 0;
void destroy() { _to_be_destroyed = true; }
virtual void real_destroy() = 0;
+#ifdef COMPRESSED_SOUND_FILE
+ virtual bool sound_finished();
+#endif
};
class Channel_RAW : public Channel {
@@ -91,6 +94,7 @@ private:
void mix(int16 *data, uint len);
Channel_MP3_CDMUSIC(SoundMixer *mixer, FILE* file, mad_timer_t duration);
void real_destroy();
+ bool sound_finished();
};
#endif
@@ -126,7 +130,7 @@ public:
int play_raw(PlayingSoundHandle *handle, void *sound, uint32 size, uint rate, byte flags);
#ifdef COMPRESSED_SOUND_FILE
int play_mp3(PlayingSoundHandle *handle, void *sound, uint32 size, byte flags);
- int play_mp3_cdtrack(PlayingSoundHandle *handle, int index, FILE* file, mad_timer_t duration);
+ int play_mp3_cdtrack(PlayingSoundHandle *handle, FILE* file, mad_timer_t duration);
#endif
/* Premix procedure, useful when using fmopl adlib */