From bfd8c21110f7c1f1abfdb69a6c405f46e0bd0285 Mon Sep 17 00:00:00 2001 From: gewlitys Date: Mon, 7 Apr 2003 00:11:28 +0000 Subject: [PATCH] Pressing pause key now stops dialog correctly (bug #167), from chmmravatar git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@906 8092fc87-c524-0410-9efc-e669fe64eaf9 --- sc2/ChangeLog | 1 + sc2/src/sc2code/libs/sound/sound.h | 2 ++ sc2/src/sc2code/libs/sound/trackplayer.c | 3 +++ sc2/src/sc2code/utils.c | 4 ++-- 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/sc2/ChangeLog b/sc2/ChangeLog index f704bae90..500f5ddab 100644 --- a/sc2/ChangeLog +++ b/sc2/ChangeLog @@ -1,4 +1,5 @@ Changes towards version 0.3: +- Pressing pause key now stops dialog correctly (bug #167), from chmmravatar - Fix some glitches in load/save screen (bug #163), from chmmravatar - Utwig shield now pulsates properly (bug #269), from Nic - Fix for memory leak in TFB_DrawCanvas_ExtractPalette (bug #277), diff --git a/sc2/src/sc2code/libs/sound/sound.h b/sc2/src/sc2code/libs/sound/sound.h index 44ab8df5c..9759b4580 100644 --- a/sc2/src/sc2code/libs/sound/sound.h +++ b/sc2/src/sc2code/libs/sound/sound.h @@ -84,6 +84,8 @@ typedef struct tfb_soundsource uint32 sbuf_size; uint32 sbuf_offset; uint32 sbuf_lasttime; + // keep track for paused tracks + uint32 pause_time; } TFB_SoundSource; diff --git a/sc2/src/sc2code/libs/sound/trackplayer.c b/sc2/src/sc2code/libs/sound/trackplayer.c index b3c3964b2..a9b4688db 100644 --- a/sc2/src/sc2code/libs/sound/trackplayer.c +++ b/sc2/src/sc2code/libs/sound/trackplayer.c @@ -99,6 +99,8 @@ ResumeTrack () playing = PlayingStream (SPEECH_SOURCE); if (!track_pos_changed && !playing && state == TFBSOUND_PAUSED) { + /*adjust start time so the slider doesn't go crazy*/ + soundSource[SPEECH_SOURCE].start_time += GetTimeCounter () - soundSource[SPEECH_SOURCE].pause_time; ResumeStream (SPEECH_SOURCE); UnlockMutex (soundSource[SPEECH_SOURCE].stream_mutex); } @@ -532,6 +534,7 @@ PauseTrack () { LockMutex (soundSource[SPEECH_SOURCE].stream_mutex); PauseStream (SPEECH_SOURCE); + soundSource[SPEECH_SOURCE].pause_time = GetTimeCounter (); UnlockMutex (soundSource[SPEECH_SOURCE].stream_mutex); } } diff --git a/sc2/src/sc2code/utils.c b/sc2/src/sc2code/utils.c index d749070b9..159ff4fd7 100644 --- a/sc2/src/sc2code/utils.c +++ b/sc2/src/sc2code/utils.c @@ -154,7 +154,7 @@ PauseGame (void) if (LOBYTE (GLOBAL (CurrentActivity)) != SUPER_MELEE) SuspendGameClock (); - else if (CommData.ConversationPhrases && PlayingTrack ()) + if (CommData.ConversationPhrases && PlayingTrack ()) PauseTrack (); SetSemaphore (GraphicsSem); @@ -198,7 +198,7 @@ PauseGame (void) if (LOBYTE (GLOBAL (CurrentActivity)) != SUPER_MELEE) ResumeGameClock (); - else if (CommData.ConversationPhrases && PlayingTrack ()) + if (CommData.ConversationPhrases && PlayingTrack ()) ResumeTrack (); TaskSwitch ();