39 #include "shared/shared.h"
41 #include "client/sound/vorbis.h"
43 #define STB_VORBIS_NO_PUSHDATA_API
44 #include "stb_vorbis.c"
134 const char* potMusicDirs[3] = {0};
135 char gameMusicDir[MAX_QPATH] = {0};
136 cvar_t* gameCvar =
Cvar_Get(
"game",
"", CVAR_LATCH | CVAR_SERVERINFO);
138 potMusicDirs[0] =
"music/";
139 potMusicDirs[1] =
"../music/";
140 potMusicDirs[2] =
"../" BASEGAME
"/music/";
144 if (strcmp(
"xatrix", gameCvar->string) == 0)
148 else if (strcmp(
"rogue", gameCvar->string) == 0)
153 for (
int potMusicDirIdx = 0; potMusicDirIdx <
sizeof(potMusicDirs)/
sizeof(potMusicDirs[0]); ++potMusicDirIdx)
155 const char* musicDir = potMusicDirs[potMusicDirIdx];
157 if (musicDir == NULL)
162 char fullMusicPath[MAX_OSPATH] = {0};
163 snprintf(fullMusicPath, MAX_OSPATH,
"%s/%s",
fs_gamedir, musicDir);
170 char testFileName[MAX_OSPATH];
171 char testFileName2[MAX_OSPATH];
174 snprintf(testFileName, MAX_OSPATH,
"%s02.ogg", fullMusicPath);
182 snprintf(testFileName, MAX_OSPATH,
"%s%02i.ogg", fullMusicPath, i);
197 snprintf(testFileName, MAX_OSPATH,
"%sTrack%02i.ogg", fullMusicPath, gogTrack);
198 snprintf(testFileName2, MAX_OSPATH,
"%strack%02i.ogg", fullMusicPath, gogTrack);
206 snprintf(testFileName, MAX_OSPATH,
"%sTrack%02i.ogg", fullMusicPath, gogTrack);
207 snprintf(testFileName2, MAX_OSPATH,
"%strack%02i.ogg", fullMusicPath, gogTrack);
226 Com_Printf(
"No Ogg Vorbis music tracks have been found, so there will be no music.\n");
242 if (read_samples > 0)
358 while(
ogg_tracks[trackNo] == NULL && retries-- > 0)
372 Com_Printf(
"OGG_PlayTrack: %d out of range.\n", trackNo);
378 Com_Printf(
"OGG_PlayTrack: Don't have a .ogg file for track %d\n", trackNo);
396 Com_Printf(
"OGG_PlayTrack: I don't have a file for track %d!\n", trackNo);
406 Com_Printf(
"OGG_PlayTrack: could not open file %s for track %d: %s.\n",
ogg_tracks[trackNo], trackNo, strerror(errno));
413 ogg_file = stb_vorbis_open_file(f, qtrue, &res, NULL);
417 Com_Printf(
"OGG_PlayTrack: '%s' is not a valid Ogg Vorbis file (error %i).\n",
ogg_tracks[trackNo], res);
440 Com_Printf(
"Tracks:\n");
452 Com_Printf(
" - %02d <none>\n", i);
461 Com_Printf(
"State: Playing file %d (%s) at %i samples.\n",
466 Com_Printf(
"State: Paused file %d (%s) at %i samples.\n",
473 Com_Printf(
"State: Stopped.\n");
537 Com_Printf(
"Unknown sub command %s\n\n",
Cmd_Argv(1));
538 Com_Printf(
"Commands:\n");
539 Com_Printf(
" - info: Print information about playback state and tracks\n");
540 Com_Printf(
" - play <track>: Play track number <track>\n");
541 Com_Printf(
" - stop: Stop playback\n");
542 Com_Printf(
" - toggle: Toggle pause\n");
557 if (Q_stricmp(
Cmd_Argv(1),
"info") == 0)
561 else if (Q_stricmp(
Cmd_Argv(1),
"play") == 0)
565 Com_Printf(
"ogg play <track> : Play <track>");
581 else if (Q_stricmp(
Cmd_Argv(1),
"stop") == 0)
585 else if (Q_stricmp(
Cmd_Argv(1),
"toggle") == 0)