From 628eea3de4a7f87cd2d14faeb579b306c39e892a Mon Sep 17 00:00:00 2001 From: James Brown Date: Sun, 20 Oct 2002 13:17:43 +0000 Subject: [PATCH] Patch 625904: CD Looping svn-id: r5199 --- backends/sdl/sdl-common.cpp | 12 +++++++++--- scumm/sound.cpp | 17 +++++++++++++++-- scumm/sound.h | 4 ++++ 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/backends/sdl/sdl-common.cpp b/backends/sdl/sdl-common.cpp index 17d2dc8885f..f2e91b5a050 100644 --- a/backends/sdl/sdl-common.cpp +++ b/backends/sdl/sdl-common.cpp @@ -825,8 +825,11 @@ void OSystem_SDL_Common::play_cdrom(int track, int num_loops, int start_frame, i cd_num_loops = num_loops; cd_start_frame = start_frame; - SDL_CDStatus(_cdrom); - SDL_CDPlayTracks(_cdrom, track, start_frame, 0, end_frame); + SDL_CDStatus(_cdrom); + if (start_frame == 0 && end_frame == 0) + SDL_CDPlayTracks(_cdrom, track, 0, 1, 0); + else + SDL_CDPlayTracks(_cdrom, track, start_frame, 0, end_frame); cd_end_frame = end_frame; cd_stop_time = 0; cd_end_time = SDL_GetTicks() + _cdrom->track[track].length * 1000 / CD_FPS; @@ -863,7 +866,10 @@ void OSystem_SDL_Common::update_cdrom() { cd_num_loops--; if (cd_num_loops != 0) { - SDL_CDPlayTracks(_cdrom, cd_track, cd_start_frame, 0, cd_end_frame); + if (cd_start_frame == 0 && cd_end_frame == 0) + SDL_CDPlayTracks(_cdrom, cd_track, 0, 1, 0); + else + SDL_CDPlayTracks(_cdrom, cd_track, cd_start_frame, 0, cd_end_frame); cd_end_time = SDL_GetTicks() + _cdrom->track[cd_track].length * 1000 / CD_FPS; } } diff --git a/scumm/sound.cpp b/scumm/sound.cpp index d5fd792e987..fc5fcca1685 100644 --- a/scumm/sound.cpp +++ b/scumm/sound.cpp @@ -1349,6 +1349,10 @@ int Sound::playMP3CDTrack(int track, int num_loops, int start, int delay) { _scumm->_mixer->stop(_mp3_index); _mp3_index = _scumm->_mixer->playMP3CDTrack(NULL, _mp3_tracks[index], duration); _mp3_cd_playing = true; + _mp3_cd_track = track; + _mp3_cd_num_loops = num_loops; + _mp3_cd_start = start; + _mp3_cd_delay = delay; return 0; } @@ -1356,6 +1360,10 @@ int Sound::stopMP3CD() { if (_mp3_cd_playing == true) { _scumm->_mixer->stop(_mp3_index); _mp3_cd_playing = false; + _mp3_cd_track = 0; + _mp3_cd_num_loops = 0; + _mp3_cd_start = 0; + _mp3_cd_delay = 0; return 0; } return -1; @@ -1376,8 +1384,13 @@ int Sound::updateMP3CD() { return -1; } - if (_scumm->_mixer->_channels[_mp3_index]->soundFinished()) - stopMP3CD(); + if (_scumm->_mixer->_channels[_mp3_index]->soundFinished()) { + if (_mp3_cd_num_loops == -1 || --_mp3_cd_num_loops > 0) + playMP3CDTrack(_mp3_cd_track, _mp3_cd_num_loops, _mp3_cd_start, _mp3_cd_delay); + else + stopMP3CD(); + } + return 0; } #endif diff --git a/scumm/sound.h b/scumm/sound.h index faa7c5e9473..2f4ddec5c8c 100644 --- a/scumm/sound.h +++ b/scumm/sound.h @@ -78,6 +78,10 @@ enum { long _mp3_size[CACHE_TRACKS]; File *_mp3_tracks[CACHE_TRACKS]; int _mp3_index; + int _mp3_cd_track; + int _mp3_cd_start; + int _mp3_cd_delay; + int _mp3_cd_num_loops; bool _mp3_cd_playing; #endif