diff options
author | Lionel Ulmer | 2002-04-27 07:42:14 +0000 |
---|---|---|
committer | Lionel Ulmer | 2002-04-27 07:42:14 +0000 |
commit | 35d305ce64a702d1d34fd5a5c0a5ddb7c1cf40c2 (patch) | |
tree | a1bb2d2c5f73c56ecbe150ccf0caae38d43ff38b /sound/mixer.cpp | |
parent | 6ac9551e815b7566ff13d02d1800286290109074 (diff) | |
download | scummvm-rg350-35d305ce64a702d1d34fd5a5c0a5ddb7c1cf40c2.tar.gz scummvm-rg350-35d305ce64a702d1d34fd5a5c0a5ddb7c1cf40c2.tar.bz2 scummvm-rg350-35d305ce64a702d1d34fd5a5c0a5ddb7c1cf40c2.zip |
MP3 CD tracks should now be working properly.
Ludde, maybe you should check if Simon is still working OK as now the
change of the sound playing handle is 'asynchronous' (ie if you call
'stop' on a sound, the handle will NOT be put to NULL right away, but
at the next 'mix' thread call). Maybe we should completely remove this
handle stuff and always use instead the index returned by the
'play_XXX' functions.
svn-id: r4101
Diffstat (limited to 'sound/mixer.cpp')
-rw-r--r-- | sound/mixer.cpp | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/sound/mixer.cpp b/sound/mixer.cpp index d73ad86958..ccbe3e354c 100644 --- a/sound/mixer.cpp +++ b/sound/mixer.cpp @@ -64,10 +64,10 @@ 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)); } -void SoundMixer::play_mp3_cdtrack(PlayingSoundHandle *handle, FILE* file, void *buffer, uint32 buffer_size, mad_timer_t duration) { - if (*handle) - stop(*handle); - insert(handle, new Channel_MP3_CDMUSIC(this, file, buffer, buffer_size, duration)); +int SoundMixer::play_mp3_cdtrack(PlayingSoundHandle *handle, int index, 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 @@ -113,6 +113,10 @@ void SoundMixer::stop(PlayingSoundHandle psh) { _channels[psh-1]->destroy(); } +void SoundMixer::stop(int index) { + if (_channels[index]) + _channels[index]->destroy(); +} bool SoundMixer::has_active_channel() { for(int i=0; i!=NUM_CHANNELS; i++) @@ -327,15 +331,15 @@ void SoundMixer::Channel_MP3::real_destroy() { } /* MP3 CD music */ +#define MP3CD_BUFFERING_SIZE 131072 -SoundMixer::Channel_MP3_CDMUSIC::Channel_MP3_CDMUSIC(SoundMixer *mixer, FILE* file, void *buffer, uint32 buffer_size, mad_timer_t duration) { +SoundMixer::Channel_MP3_CDMUSIC::Channel_MP3_CDMUSIC(SoundMixer *mixer, FILE* file, mad_timer_t duration) { _mixer = mixer; _file = file; _duration = duration; _initialized = false; - _buffer_size = buffer_size; - _ptr = buffer; - _flags = 0; + _buffer_size = MP3CD_BUFFERING_SIZE; + _ptr = malloc(MP3CD_BUFFERING_SIZE); _to_be_destroyed = false; mad_stream_init(&_stream); @@ -345,8 +349,6 @@ SoundMixer::Channel_MP3_CDMUSIC::Channel_MP3_CDMUSIC(SoundMixer *mixer, FILE* fi #endif mad_frame_init(&_frame); mad_synth_init(&_synth); - - //debug(1, "CRE %d", getpid()); } void SoundMixer::Channel_MP3_CDMUSIC::mix(int16 *data, uint len) { @@ -358,8 +360,6 @@ void SoundMixer::Channel_MP3_CDMUSIC::mix(int16 *data, uint len) { return; } - //debug(1, "MIX %d", getpid()); - if (!_initialized) { int skip_loop; // just skipped @@ -451,15 +451,12 @@ void SoundMixer::Channel_MP3_CDMUSIC::mix(int16 *data, uint len) { } void SoundMixer::Channel_MP3_CDMUSIC::real_destroy() { - if (_flags & FLAG_AUTOFREE) - free(_ptr); + free(_ptr); _mixer->uninsert(this); mad_synth_finish(&_synth); mad_frame_finish(&_frame); mad_stream_finish(&_stream); - //debug(1, "DES %d", getpid()); - delete this; } |