Whitespace and coding style.

This commit is contained in:
Jeff Teunissen 2004-02-06 15:16:50 +00:00
parent 950a5b34c4
commit cad6fedad8

View file

@ -4,7 +4,9 @@
ogg music support ogg music support
Copyright (C) 1996-1997 Id Software, Inc. Copyright (C) 1996-1997 Id Software, Inc.
Modified Andrew Pilley, 2004 Copyright (C) 2004 Andrew Pilley
Copyright (C) 2004 Bill Currie <taniwha@quakeforge.net>
Copyright (C) 2004 Jeff Teunissen <deek@quakeforge.net>
This program is free software; you can redistribute it and/or This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License modify it under the terms of the GNU General Public License
@ -127,19 +129,16 @@ I_OGGMus_Stop (void)
{ {
Sys_DPrintf ("Entering I_OGGMus_Stop\n"); Sys_DPrintf ("Entering I_OGGMus_Stop\n");
if (tracklist == NULL || !mus_enabled) if (!tracklist || !mus_enabled || !playing)
return; return;
if (!playing) current_track = -1;
return;
current_track=-1;
playing = false; playing = false;
wasPlaying=false; wasPlaying = false;
if (cd_sfx) { if (cd_sfx) {
cd_sfx->close (cd_sfx); cd_sfx->close (cd_sfx);
cd_channel->sfx=NULL; cd_channel->sfx = NULL;
} }
} }
@ -148,7 +147,7 @@ I_OGGMus_Shutdown (void)
{ {
Sys_DPrintf ("Entering I_OGGMus_Shutdown\n"); Sys_DPrintf ("Entering I_OGGMus_Shutdown\n");
if (tracklist != NULL) { if (tracklist) {
I_OGGMus_Stop (); I_OGGMus_Stop ();
PL_Free (tracklist); PL_Free (tracklist);
tracklist = NULL; tracklist = NULL;
@ -161,16 +160,16 @@ I_OGGMus_Shutdown (void)
static int static int
Load_Tracklist (void) Load_Tracklist (void)
{ {
int size = -1;
char *buffile = NULL;
static QFile *oggfile = NULL; static QFile *oggfile = NULL;
char *buffile = NULL;
int size = -1;
Sys_DPrintf ("Entering Load_Tracklist\n"); Sys_DPrintf ("Entering Load_Tracklist\n");
/* kill off the old tracklist, and make sure we're not playing anything */ /* kill off the old tracklist, and make sure we're not playing anything */
I_OGGMus_Shutdown (); I_OGGMus_Shutdown ();
ogglistvalid=false; ogglistvalid = false;
mus_enabled = false; mus_enabled = false;
if (!mus_ogglist || strequal (mus_ogglist->string, "none")) { if (!mus_ogglist || strequal (mus_ogglist->string, "none")) {
@ -179,21 +178,22 @@ Load_Tracklist (void)
} }
size = QFS_FOpenFile (mus_ogglist->string, &oggfile); size = QFS_FOpenFile (mus_ogglist->string, &oggfile);
if (size == -1) { if (size < 0) {
Sys_Printf ("Mus_OggInit: open of file \"%s\" failed\n", Sys_Printf ("Mus_OggInit: open of file \"%s\" failed\n",
mus_ogglist->string); mus_ogglist->string);
return -1; return -1;
} }
if (oggfile==NULL) { if (!oggfile) {
return -1; return -1;
} }
/* rewind the stream */ /* rewind the stream */
Qseek (oggfile, 0, SEEK_SET); Qseek (oggfile, 0, SEEK_SET);
size= Qfilesize (oggfile); size = Qfilesize (oggfile);
buffile = calloc (size+10, sizeof (char)); buffile = calloc (size+10, sizeof (char));
Qread (oggfile, buffile, size); Qread (oggfile, buffile, size);
tracklist = PL_GetPropertyList (buffile); tracklist = PL_GetPropertyList (buffile);
if (!tracklist || tracklist->type != QFDictionary) { if (!tracklist || tracklist->type != QFDictionary) {
Sys_Printf ("Malformed or empty tracklist file. check mus_ogglist\n"); Sys_Printf ("Malformed or empty tracklist file. check mus_ogglist\n");
@ -203,8 +203,8 @@ Load_Tracklist (void)
free (buffile); free (buffile);
Qclose (oggfile); Qclose (oggfile);
ogglistvalid=true; ogglistvalid = true;
mus_enabled=true; mus_enabled = true;
return 0; return 0;
} }
@ -215,15 +215,12 @@ I_OGGMus_Pause (void)
Sys_DPrintf("I_OGGMus: Pausing on track: %d.\n",current_track); Sys_DPrintf("I_OGGMus: Pausing on track: %d.\n",current_track);
/* pause the ogg playback. */ /* pause the ogg playback. */
/* just kinda cheat and stop it for the time being */ /* just kinda cheat and stop it for the time being */
if (tracklist == NULL || !mus_enabled) if (!tracklist || !mus_enabled || !playing)
return;
if (!playing)
return; return;
if (cd_sfx) { if (cd_sfx) {
cd_sfx->close (cd_sfx); cd_sfx->close (cd_sfx);
cd_channel->sfx=NULL; cd_channel->sfx = NULL;
} }
wasPlaying = playing; wasPlaying = playing;
@ -249,16 +246,17 @@ I_OGGMus_Play (int track, qboolean looping)
mus_enabled = false; mus_enabled = false;
} }
if (tracklist == NULL || !mus_enabled) { if (!tracklist || !mus_enabled) {
free (trackstring); free (trackstring);
return; return;
} }
dsprintf (trackstring, "%i", track); dsprintf (trackstring, "%i", track);
trackmap = PL_ObjectForKey (tracklist, trackstring->str); trackmap = PL_ObjectForKey (tracklist, trackstring->str);
if (trackmap == NULL || trackmap->type != QFString) {
Sys_Printf ("No Track for track number %s.\n", trackstring->str);
free (trackstring); free (trackstring);
if (!trackmap || trackmap->type != QFString) {
Sys_Printf ("No Track entry for track #%s.\n", trackstring->str);
return; return;
} }
@ -268,39 +266,33 @@ I_OGGMus_Play (int track, qboolean looping)
memset (cd_channel, 0, sizeof (*cd_channel)); memset (cd_channel, 0, sizeof (*cd_channel));
} }
cd_sfx = S_LoadSound ((char *) trackmap->data); if (!(cd_sfx = S_LoadSound ((char *) trackmap->data)))
if (cd_sfx) { return;
if (cd_sfx->wavinfo) if (cd_sfx->wavinfo)
info = cd_sfx->wavinfo (cd_sfx); info = cd_sfx->wavinfo (cd_sfx);
if (info) if (info) {
{
if (looping == true) if (looping == true)
info->loopstart = 0; info->loopstart = 0;
else else
info->loopstart =-1; info->loopstart = -1;
} }
cd_channel->sfx = cd_sfx->open (cd_sfx); cd_channel->sfx = cd_sfx->open (cd_sfx);
set_volume (); set_volume ();
}
free (trackstring);
playing = true; playing = true;
current_track=track; current_track = track;
} }
/* unpause. might just cheat and restart playing */ /* unpause. might just cheat and restart playing */
static void static void
I_OGGMus_Resume (void) I_OGGMus_Resume (void)
{ {
if (!tracklist || !mus_enabled || !wasPlaying)
if (tracklist == NULL || !mus_enabled)
return; return;
if (!wasPlaying) Sys_DPrintf ("I_OGGMus: resuming track: %d.\n", current_track);
return; I_OGGMus_Play (current_track, true);
Sys_DPrintf("I_OGGMus: resuming track: %d.\n",current_track);
I_OGGMus_Play(current_track,true);
playing = true; playing = true;
} }
@ -315,11 +307,14 @@ I_OGGMus_Info (void)
int iter = 0; int iter = 0;
Sys_DPrintf ("Entering I_OGGMus_Info\n"); Sys_DPrintf ("Entering I_OGGMus_Info\n");
if (tracklist != NULL) {
keylist = PL_D_AllKeys (tracklist); if (!tracklist) {
if (keylist == NULL) { Sys_Printf ("\n" "No Tracklist\n" "------------\n");
Sys_DPrintf ("OGGMus: Didn't get valid plist_t array yet have " return;
}
if (!(keylist = PL_D_AllKeys (tracklist))) {
Sys_DPrintf ("OGGMus: Didn't get valid plist_t array, yet have "
"valid tracklist?\n"); "valid tracklist?\n");
return; return;
} }
@ -329,30 +324,22 @@ I_OGGMus_Info (void)
"---------------------------\n", mus_ogglist->string); "---------------------------\n", mus_ogglist->string);
/* loop through the list with PL_ObjectAtIndex () */ /* loop through the list with PL_ObjectAtIndex () */
for (iter = 0; iter < ((plarray_t *) (keylist->data))->numvals; iter++) {
for (iter = 0; if (!(currentmap = PL_ObjectAtIndex (keylist, iter))) {
iter < ((plarray_t *) (keylist->data))->numvals; iter++) {
currentmap = PL_ObjectAtIndex (keylist, iter);
if (currentmap == NULL) {
Sys_DPrintf ("OGGMus: No track for track number %i.\n", iter); Sys_DPrintf ("OGGMus: No track for track number %i.\n", iter);
continue; continue;
} }
if (currentmap->type != QFString) { if (currentmap->type != QFString) {
Sys_DPrintf ("OGGMus: Track fetched isn't a QFString for: %i\n", Sys_DPrintf ("OGGMus: Track data isn't a string for: %i\n", iter);
iter);
continue; continue;
} }
currenttrack = PL_ObjectForKey (tracklist,
(char *) currentmap->data); currenttrack = PL_ObjectForKey (tracklist, (char *) currentmap->data);
Sys_Printf (" %s - %s\n", (char *) currentmap->data, Sys_Printf (" %s - %s\n", (char *) currentmap->data,
(char *) currenttrack->data); (char *) currenttrack->data);
} }
PL_Free (keylist); PL_Free (keylist);
} else {
Sys_Printf ("\n" "No Tracklist\n" "------------\n");
}
} }
static void static void
@ -445,7 +432,7 @@ I_OGG_f (void)
} }
} }
/* stubb out, since we don't need */ /* stub out, since we don't need */
static void static void
I_OGGMus_Update (void) I_OGGMus_Update (void)
{ {
@ -455,7 +442,7 @@ I_OGGMus_Update (void)
static void static void
Mus_OggChange (cvar_t *ogglist) Mus_OggChange (cvar_t *ogglist)
{ {
mus_ogglist=ogglist; mus_ogglist = ogglist;
Load_Tracklist (); Load_Tracklist ();
} }
@ -479,7 +466,6 @@ I_OGGMus_Init (void)
Sys_DPrintf ("Entering I_OGGMus_Init\n"); Sys_DPrintf ("Entering I_OGGMus_Init\n");
cd_channel = S_AllocChannel (); cd_channel = S_AllocChannel ();
if (!cd_channel) // We can't fail to load yet... so just disable everything if (!cd_channel) // We can't fail to load yet... so just disable everything
Sys_Printf ("OGGMus: Failed to allocate sound channel.\n"); Sys_Printf ("OGGMus: Failed to allocate sound channel.\n");
@ -531,8 +517,9 @@ static plugin_t plugin_info = {
QFPLUGIN_VERSION, QFPLUGIN_VERSION,
"0.1", "0.1",
"OGG Music output\n", "OGG Music output\n",
"Copyright (C) 2001 contributors of the QuakeForge project\n" "Copyright (C) 2004 Andrew Pilley\n"
"Please see the file \"AUTHORS\" for a list of contributors\n", "Copyright (C) 2004 Members of the QuakeForge Project\n"
"See the file \"AUTHORS\" for more information.\n",
&plugin_info_funcs, &plugin_info_funcs,
&plugin_info_data, &plugin_info_data,
}; };