cleanups
git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@1756 8092fc87-c524-0410-9efc-e669fe64eaf9
This commit is contained in:
+36
-25
@@ -50,27 +50,32 @@ typedef struct {
|
||||
void fill_audio(void *u, Uint8 *stream, int len);
|
||||
|
||||
unsigned long clocks_per_sec = 1000;
|
||||
unsigned long get_clock()
|
||||
|
||||
unsigned long
|
||||
get_clock()
|
||||
{
|
||||
return (SDL_GetTicks());
|
||||
}
|
||||
|
||||
void init_sound ()
|
||||
void
|
||||
init_sound ()
|
||||
{
|
||||
if(SDL_Init(SDL_INIT_AUDIO) < 0) {
|
||||
fprintf(stderr,"could not initialize SDL audio\n");
|
||||
exit(-1);
|
||||
}
|
||||
if (SDL_Init(SDL_INIT_AUDIO) < 0) {
|
||||
fprintf(stderr,"could not initialize SDL audio\n");
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
WAVESTRUCT *play_sound(AUDIOHDR *audiohdr)
|
||||
|
||||
WAVESTRUCT *
|
||||
play_sound(AUDIOHDR *audiohdr)
|
||||
{
|
||||
WAVESTRUCT *WaveData = new WAVESTRUCT;
|
||||
WAVESTRUCT *WaveData = new WAVESTRUCT;
|
||||
/*
|
||||
WaveData->spec.freq = 22050;
|
||||
WaveData->spec.format = AUDIO_S16;
|
||||
WaveData->spec.channels = 2;
|
||||
WaveData->spec.samples = 1024;
|
||||
WaveData->spec.callback = fill_audio;
|
||||
WaveData->spec.freq = 22050;
|
||||
WaveData->spec.format = AUDIO_S16;
|
||||
WaveData->spec.channels = 2;
|
||||
WaveData->spec.samples = 1024;
|
||||
WaveData->spec.callback = fill_audio;
|
||||
*/
|
||||
WaveData->spec.freq = audiohdr->samp_freq;
|
||||
WaveData->spec.format = AUDIO_S16;
|
||||
@@ -81,34 +86,38 @@ WAVESTRUCT *play_sound(AUDIOHDR *audiohdr)
|
||||
WaveData->data = audiohdr->data;
|
||||
WaveData->data_len = audiohdr->data_len;
|
||||
WaveData->data_pos = 0;
|
||||
if(SDL_OpenAudio(&WaveData->spec, NULL) < 0) {
|
||||
fprintf(stderr,"could not open SDL audio\n");
|
||||
exit(-1);
|
||||
}
|
||||
SDL_PauseAudio(0);
|
||||
if(SDL_OpenAudio(&WaveData->spec, NULL) < 0) {
|
||||
fprintf(stderr,"could not open SDL audio\n");
|
||||
exit(-1);
|
||||
}
|
||||
SDL_PauseAudio(0);
|
||||
return (WaveData);
|
||||
}
|
||||
|
||||
void pause_sound(WAVESTRUCT *WaveData)
|
||||
void
|
||||
pause_sound(WAVESTRUCT *WaveData)
|
||||
{
|
||||
if (WaveData)
|
||||
SDL_PauseAudio(1);
|
||||
}
|
||||
|
||||
void unpause_sound (WAVESTRUCT *WaveData)
|
||||
void
|
||||
unpause_sound (WAVESTRUCT *WaveData)
|
||||
{
|
||||
if (WaveData)
|
||||
SDL_PauseAudio(0);
|
||||
}
|
||||
|
||||
void reset_sound (WAVESTRUCT *WaveData)
|
||||
void
|
||||
reset_sound (WAVESTRUCT *WaveData)
|
||||
{
|
||||
if (WaveData) {
|
||||
SDL_CloseAudio();
|
||||
SDL_CloseAudio();
|
||||
delete WaveData->data;
|
||||
delete WaveData;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
void fill_audio (void *u, Uint8 *stream, int len)
|
||||
{
|
||||
@@ -129,10 +138,11 @@ void fill_audio (void *u, Uint8 *stream, int len)
|
||||
}
|
||||
*/
|
||||
|
||||
void fill_audio (void *u, Uint8 *stream, int len)
|
||||
void
|
||||
fill_audio (void *u, Uint8 *stream, int len)
|
||||
{
|
||||
Sint16 *b;
|
||||
int l, i;
|
||||
Sint16 *b;
|
||||
int l, i;
|
||||
long amt_left;
|
||||
WAVESTRUCT *WaveData = (WAVESTRUCT *)u;
|
||||
|
||||
@@ -144,3 +154,4 @@ void fill_audio (void *u, Uint8 *stream, int len)
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user