Slider now moves in communications (OpenAL)

git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@354 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
gewlitys
2002-12-06 02:37:01 +00:00
parent 74e6e16900
commit 7addbdef8f
6 changed files with 25 additions and 7 deletions
@@ -145,6 +145,7 @@ TFB_SoundDecoder* SoundDecoder_Load (char *filename, ALuint buffer_size)
decoder->frequency = 0;
decoder->looping = AL_FALSE;
decoder->error = SOUNDDECODER_OK;
decoder->length = 0; // FIXME should be calculated
decoder->decoder_info = decoder_info_wav;
decoder->type = SOUNDDECODER_WAV;
decoder->filename = (char *) malloc (strlen (filename) + 1);
@@ -178,6 +179,7 @@ TFB_SoundDecoder* SoundDecoder_Load (char *filename, ALuint buffer_size)
decoder->frequency = md_mixfreq;
decoder->looping = AL_FALSE;
decoder->error = SOUNDDECODER_OK;
decoder->length = 0; // FIXME way to obtain this from mikmod?
decoder->decoder_info = decoder_info_mod;
decoder->type = SOUNDDECODER_MOD;
decoder->filename = (char *) malloc (strlen (filename) + 1);
@@ -243,6 +245,7 @@ TFB_SoundDecoder* SoundDecoder_Load (char *filename, ALuint buffer_size)
decoder->frequency = vinfo->rate;
decoder->looping = AL_FALSE;
decoder->error = SOUNDDECODER_OK;
decoder->length = (float) ov_time_total (vf, -1);
decoder->decoder_info = decoder_info_ogg;
decoder->type = SOUNDDECODER_OGG;
decoder->filename = (char *) malloc (strlen (filename) + 1);
@@ -38,6 +38,7 @@ typedef struct tfb_sounddecoder
ALuint frequency;
ALboolean looping;
ALint error;
float length; // total length in seconds
char *decoder_info;
// semi-private
@@ -55,6 +55,7 @@ typedef struct tfb_soundsource
ALuint handle;
BOOLEAN stream_should_be_playing;
Mutex stream_mutex;
ALuint start_time;
} TFB_SoundSource;
@@ -79,6 +79,7 @@ PlayStream (TFB_SoundSample *sample, ALuint source, ALboolean looping)
break;
}
soundSource[source].start_time = GetTimeCounter ();
soundSource[source].stream_should_be_playing = TRUE;
alSourcePlay (soundSource[source].handle);
}
@@ -108,6 +109,7 @@ StopStream (ALuint source)
void
PauseStream (ALuint source)
{
soundSource[source].start_time = GetTimeCounter () - soundSource[source].start_time;
soundSource[source].stream_should_be_playing = FALSE;
alSourcePause (soundSource[source].handle);
}
@@ -115,6 +117,7 @@ PauseStream (ALuint source)
void
ResumeStream (ALuint source)
{
soundSource[source].start_time = GetTimeCounter () - soundSource[source].start_time;
soundSource[source].stream_should_be_playing = TRUE;
alSourcePlay (soundSource[source].handle);
}
@@ -260,15 +260,22 @@ GetSoundData (char* data)
return 0;
}
// Status: Unimplemented
int
GetSoundInfo (int *length, int *offset)
// Umm... How does it know which sound?
// Answer: only used in oscill.c slider so sound must be current speech
{
//fprintf (stderr, "Unimplemented function activated: GetSoundInfo()\n");
LockMutex (soundSource[SPEECH_SOURCE].stream_mutex);
if (soundSource[SPEECH_SOURCE].sample && soundSource[SPEECH_SOURCE].sample->decoder)
{
*length = (int) (soundSource[SPEECH_SOURCE].sample->decoder->length * (float)ONE_SECOND);
*offset = (int) (GetTimeCounter () - soundSource[SPEECH_SOURCE].start_time);
}
else
{
*length = 1;
*offset = 0;
}
UnlockMutex (soundSource[SPEECH_SOURCE].stream_mutex);
return 1;
}
+3
View File
@@ -17,6 +17,7 @@
*/
#include "libs/graphics/gfx_common.h"
#include "libs/sound/trackplayer.h"
//Added by Chris
//Modified by Mika (removed use of SDL datatypes)
@@ -206,6 +207,8 @@ Slider (void)
{
if (offs > len)
offs = len;
if (len == 0)
len = 1;
buttonStamp.origin.x = sliderStamp.origin.x + sliderSpace * offs / len;
BatchGraphics ();
DrawStamp (&sliderStamp);