changeset 37:f88d47a4bf87

* Modernize configure.ac * Improve a bit BGM playback
author thib
date Tue, 17 Mar 2009 17:47:26 +0000
parents 6d1a5b7f0838
children 658272d883ed
files configure.ac music2/music.cc
diffstat 2 files changed, 12 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- 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)
--- 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) {