# HG changeset patch # User thib # Date 1237312046 0 # Node ID f88d47a4bf87eb4108105475672624de38b54475 # Parent 6d1a5b7f0838000668bf4bb6a1c131842504a139 * Modernize configure.ac * Improve a bit BGM playback diff --git a/configure.ac b/configure.ac --- a/configure.ac +++ b/configure.ac @@ -1,13 +1,13 @@ dnl >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> dnl dnl First definition -AC_INIT(scn2k) +AC_INIT(xclannad, 0.07hb) dnl Software version -PACKAGE=xclannad -VERSION=0.07hb +PACKAGE=$AC_PACKAGE_NAME +VERSION=$AC_PACKAGE_VERSION -AM_INIT_AUTOMAKE($PACKAGE, $VERSION) +AM_INIT_AUTOMAKE dnl Specify a configuretion file AC_CONFIG_HEADER(config.h) diff --git a/music2/music.cc b/music2/music.cc --- a/music2/music.cc +++ b/music2/music.cc @@ -188,16 +188,18 @@ void WavChunk::callback(void *userdata, memset(stream, 0, len); return; } - count = chunk->wav->Read( (char*)stream, 4, len/4); + + char* stream_dup = new char[len]; + count = chunk->wav->Read( (char*)stream_dup, 4, len/4); if (count != len/4) { - memset(stream+count*4, 0, len-count*4); // 最後まで再生した if (chunk->loop_pt == -1) { // 終了 chunk->loop_pt = -2; + memset(stream_dup+count*4, 0, len-count*4); } else { chunk->wav->Seek(chunk->loop_pt); - chunk->wav->Read( (char*)(stream+count*4), 4, len/4-count); + chunk->wav->Read( (char*)(stream_dup+count*4), 4, len/4-count); } } @@ -209,19 +211,16 @@ void WavChunk::callback(void *userdata, if (fadecount > count_total || fadetime_total == 1) { // 音楽停止 chunk->loop_pt = -2; memset(stream, 0, len); + delete[] stream_dup; return; } - // int cur_vol = 256*(count_total-fadecount)/count_total; cur_vol = cur_vol*(count_total-fadecount)/count_total; fadecount += len/4; } - - char* stream_dup = new char[len]; - memcpy(stream_dup, stream, len); - memset(stream, 0, len); + SDL_MixAudio(stream, (Uint8*)stream_dup, len, cur_vol); delete[] stream_dup; - + return; } void bgm_fadeout(int time) {