Slider and ff/frew should now behave well when track ends

git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@704 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
ghaushe
2003-02-06 18:38:07 +00:00
parent aaef620504
commit 9622db8e44
4 changed files with 46 additions and 19 deletions
+1
View File
@@ -1,4 +1,5 @@
Changes towards version 0.2: Changes towards version 0.2:
- Slider should now work correctly everywhere -PhracturedBlue
- Added 'nosound' driver and --sound=openal|mixsdl|none - Added 'nosound' driver and --sound=openal|mixsdl|none
option; -a option has been removed -fOSSiL option; -a option has been removed -fOSSiL
- Fix ZFP stuttering and some other random sound issues -PBlue - Fix ZFP stuttering and some other random sound issues -PBlue
+5 -7
View File
@@ -1164,6 +1164,7 @@ SpewPhrases (COUNT wait_track)
COUNT which_track; COUNT which_track;
INPUT_STATE InputState, LastInputState = (INPUT_STATE)~0; INPUT_STATE InputState, LastInputState = (INPUT_STATE)~0;
FRAME F; FRAME F;
BOOLEAN passed = TRUE;
TimeIn = GetTimeCounter (); TimeIn = GetTimeCounter ();
@@ -1252,11 +1253,9 @@ Rewind:
} }
else else
{ {
CommData.AlienFrame = F; ContinuityBreak = FALSE;
if (! which_track) passed = (which_track != 0);
return (FALSE); break;
else
return (TRUE);
} }
ContinuityBreak = FALSE; ContinuityBreak = FALSE;
} }
@@ -1272,8 +1271,7 @@ Rewind:
if (wait_track == (COUNT)~0) if (wait_track == (COUNT)~0)
SetSliderImage (SetAbsFrameIndex (ActivityFrame, 8)); SetSliderImage (SetAbsFrameIndex (ActivityFrame, 8));
return (passed);
return (TRUE);
} }
void void
+36 -11
View File
@@ -36,6 +36,8 @@ static TFB_SoundChain *first_chain = NULL; //first decoder in linked list
static TFB_SoundChain *last_chain = NULL; //last decoder in linked list static TFB_SoundChain *last_chain = NULL; //last decoder in linked list
static UNICODE *TrackTextArray[MAX_CLIPS]; //storage for subtitlle text static UNICODE *TrackTextArray[MAX_CLIPS]; //storage for subtitlle text
static Mutex track_mutex; //protects tcur and tct static Mutex track_mutex; //protects tcur and tct
void recompute_track_pos (TFB_SoundSample *sample,
TFB_SoundChain *first_chain, sint32 offset);
//JumpTrack currently aborts the current track. However, it doesn't clear the //JumpTrack currently aborts the current track. However, it doesn't clear the
//data-structures as StopTrack does. this allows for rewind even after the //data-structures as StopTrack does. this allows for rewind even after the
@@ -46,14 +48,20 @@ JumpTrack (int abort)
{ {
if (sound_sample) if (sound_sample)
{ {
uint32 cur_time;
sint32 total_length = (sint32)((last_chain->start_time +
last_chain->decoder->length) * (float)ONE_SECOND);
LockMutex (soundSource[SPEECH_SOURCE].stream_mutex); LockMutex (soundSource[SPEECH_SOURCE].stream_mutex);
StopStream (SPEECH_SOURCE); PauseStream (SPEECH_SOURCE);
if (abort) cur_time = GetTimeCounter();
{ soundSource[SPEECH_SOURCE].start_time =
sound_sample->read_chain_ptr = NULL; (sint32)cur_time - total_length;;
sound_sample->decoder = NULL; track_pos_changed = 1;
} sound_sample->play_chain_ptr = last_chain;
recompute_track_pos(sound_sample, first_chain, total_length);
UnlockMutex (soundSource[SPEECH_SOURCE].stream_mutex); UnlockMutex (soundSource[SPEECH_SOURCE].stream_mutex);
PlayingTrack();
return;
} }
no_voice = 1; no_voice = 1;
@@ -124,6 +132,8 @@ PlayingTrack ()
{ {
// this is not a great way to detect whether the track is playing, // this is not a great way to detect whether the track is playing,
// but as it should work during fast-forward/rewind, 'PlayingStream' can't be used // but as it should work during fast-forward/rewind, 'PlayingStream' can't be used
// if (tct == 0)
// return ((COUNT)~0);
if (sound_sample && is_sample_playing (sound_sample)) if (sound_sample && is_sample_playing (sound_sample))
{ {
int last_track, last_page; int last_track, last_page;
@@ -461,18 +471,26 @@ FastReverse_Smooth ()
if (sound_sample) if (sound_sample)
{ {
sint32 offset; sint32 offset;
uint32 cur_time;
sint32 total_length = (sint32)((last_chain->start_time +
last_chain->decoder->length) * (float)ONE_SECOND);
LockMutex (soundSource[SPEECH_SOURCE].stream_mutex); LockMutex (soundSource[SPEECH_SOURCE].stream_mutex);
PauseStream (SPEECH_SOURCE); PauseStream (SPEECH_SOURCE);
cur_time = GetTimeCounter();
track_pos_changed = 1; track_pos_changed = 1;
if ((sint32)cur_time - soundSource[SPEECH_SOURCE].start_time > total_length)
soundSource[SPEECH_SOURCE].start_time =
(sint32)cur_time - total_length;
soundSource[SPEECH_SOURCE].start_time += ACCEL_SCROLL_SPEED; soundSource[SPEECH_SOURCE].start_time += ACCEL_SCROLL_SPEED;
if (soundSource[SPEECH_SOURCE].start_time > (sint32)GetTimeCounter()) if (soundSource[SPEECH_SOURCE].start_time > (sint32)cur_time)
{ {
soundSource[SPEECH_SOURCE].start_time = GetTimeCounter(); soundSource[SPEECH_SOURCE].start_time = cur_time;
offset = 0; offset = 0;
} }
else else
offset = GetTimeCounter() - soundSource[SPEECH_SOURCE].start_time; offset = cur_time - soundSource[SPEECH_SOURCE].start_time;
recompute_track_pos(soundSource[SPEECH_SOURCE].sample, first_chain, offset); recompute_track_pos(sound_sample, first_chain, offset);
UnlockMutex (soundSource[SPEECH_SOURCE].stream_mutex); UnlockMutex (soundSource[SPEECH_SOURCE].stream_mutex);
PlayingTrack(); PlayingTrack();
@@ -504,10 +522,17 @@ FastForward_Smooth ()
if (sound_sample) if (sound_sample)
{ {
sint32 offset; sint32 offset;
uint32 cur_time;
sint32 total_length = (sint32)((last_chain->start_time +
last_chain->decoder->length) * (float)ONE_SECOND);
LockMutex (soundSource[SPEECH_SOURCE].stream_mutex); LockMutex (soundSource[SPEECH_SOURCE].stream_mutex);
PauseStream (SPEECH_SOURCE); PauseStream (SPEECH_SOURCE);
cur_time = GetTimeCounter();
soundSource[SPEECH_SOURCE].start_time -= ACCEL_SCROLL_SPEED; soundSource[SPEECH_SOURCE].start_time -= ACCEL_SCROLL_SPEED;
offset = GetTimeCounter() - soundSource[SPEECH_SOURCE].start_time; if ((sint32)cur_time - soundSource[SPEECH_SOURCE].start_time > total_length)
soundSource[SPEECH_SOURCE].start_time =
(sint32)cur_time - total_length;
offset = cur_time - soundSource[SPEECH_SOURCE].start_time;
track_pos_changed = 1; track_pos_changed = 1;
recompute_track_pos(sound_sample, first_chain, offset); recompute_track_pos(sound_sample, first_chain, offset);
UnlockMutex (soundSource[SPEECH_SOURCE].stream_mutex); UnlockMutex (soundSource[SPEECH_SOURCE].stream_mutex);
+4 -1
View File
@@ -21,6 +21,7 @@
static STAMP sliderStamp; static STAMP sliderStamp;
static STAMP buttonStamp; static STAMP buttonStamp;
static BOOLEAN sliderChanged = FALSE;
int sliderSpace; // slider width - button width int sliderSpace; // slider width - button width
@@ -50,6 +51,7 @@ InitSlider (int x, int y, int width, int height,
void void
SetSliderImage (FRAME f) SetSliderImage (FRAME f)
{ {
sliderChanged = TRUE;
buttonStamp.frame = f; buttonStamp.frame = f;
} }
@@ -59,8 +61,9 @@ Slider (void)
int offs; int offs;
static int last_offs = -1; static int last_offs = -1;
if ((offs = GetSoundInfo (sliderSpace)) != last_offs) if ((offs = GetSoundInfo (sliderSpace)) != last_offs ||sliderChanged)
{ {
sliderChanged = FALSE;
last_offs = offs; last_offs = offs;
buttonStamp.origin.x = sliderStamp.origin.x + offs; buttonStamp.origin.x = sliderStamp.origin.x + offs;
BatchGraphics (); BatchGraphics ();