summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTreeki <treeki@gmail.com>2012-12-06 23:37:19 +0100
committerTreeki <treeki@gmail.com>2012-12-06 23:37:19 +0100
commit23c4e2059649d2a515cde177c8c6bf8eace2cac1 (patch)
treed67623a0b2a4ffdeca85b0511341b99ca1366f73 /src
parentffed316fb7d237065f51265d0be33dd9cee90a9a (diff)
downloadkamek-23c4e2059649d2a515cde177c8c6bf8eace2cac1.tar.gz
kamek-23c4e2059649d2a515cde177c8c6bf8eace2cac1.zip
map music improvements and fixes
Diffstat (limited to '')
-rw-r--r--src/koopatlas/mapmusic.cpp39
1 files changed, 28 insertions, 11 deletions
diff --git a/src/koopatlas/mapmusic.cpp b/src/koopatlas/mapmusic.cpp
index 8fdf264..9998954 100644
--- a/src/koopatlas/mapmusic.cpp
+++ b/src/koopatlas/mapmusic.cpp
@@ -24,15 +24,20 @@ void dKPMusic::play(int id) {
if (s_playing) {
// Switch track
OSReport("Trying to switch to song %d (Current one is %d)...\n", id, s_song);
- if (s_song == id || s_nextSong == id)
- return;
- if (s_countdownToSwitch >= 0 || s_countdownToFadeIn >= 0)
- return;
- OSReport("Will switch; Fading out current track 2 over %d frames\n", FADE_OUT_LEN);
-
- s_handle.SetTrackVolume(1<<1, FADE_OUT_LEN, 0.0f);
- s_nextSong = id;
- s_countdownToSwitch = FADE_OUT_LEN;
+ if (s_song == id || s_nextSong == id) {
+ OSReport("This song is already playing or is scheduled. Not gonna do that.\n");
+ } else if (s_countdownToFadeIn >= 0) {
+ OSReport("There's already a track being faded in (CountdownToFadeIn=%d)\n", s_countdownToFadeIn);
+ } else if (s_countdownToSwitch >= 0) {
+ OSReport("We were already going to switch tracks, but the rstm hasn't been changed yet, so the next song is being changed to this one\n");
+ s_nextSong = id;
+ } else {
+ OSReport("Will switch; Fading out current track 2 over %d frames\n", FADE_OUT_LEN);
+
+ s_handle.SetTrackVolume(1<<1, FADE_OUT_LEN, 0.0f);
+ s_nextSong = id;
+ s_countdownToSwitch = FADE_OUT_LEN;
+ }
} else {
// New track
@@ -66,13 +71,14 @@ void dKPMusic::execute() {
if (!s_playing)
return;
+ if (s_handle.GetSound() == 0)
+ OSReport("SOUND IS NOT PLAYING!\n");
+
if (s_countdownToSwitch >= 0) {
s_countdownToSwitch--;
if (s_countdownToSwitch == 0) {
OSReport("Switching brstm files to song %d.\n", s_nextSong);
- s_countdownToFadeIn = BUFFER_CLEAR_DELAY;
-
char brstmPath[48];
sprintf(brstmPath, "/Sound/new/map%d.er", s_nextSong);
@@ -81,7 +87,18 @@ void dKPMusic::execute() {
u8 **fileStreamPointer = (u8**)(player+0x808);
u8 *fileStream = *fileStreamPointer;
DVDHandle *fileInfo = (DVDHandle*)(fileStream+0x28);
+
+ if (fileInfo->unk4 == 1) {
+ OSReport("Was reading chunk, will try again next frame...\n");
+ s_countdownToSwitch++;
+ return;
+ }
+
+ if (s_nextSong > 0)
+ s_countdownToFadeIn = BUFFER_CLEAR_DELAY;
+
DVDCancel(fileInfo);
+ //OSReport("CANCEL successfully called!\n");
bool result = DVDFastOpen(DVDConvertPathToEntrynum(brstmPath), fileInfo);
OSReport("StrmSound is at %p, StrmPlayer is at %p, FileStream pointer is at %p, FileStream is at %p, FileInfo is at %p\n", sound, player, fileStreamPointer, fileStream, fileInfo);