mirror of
https://github.com/Shpoike/Quakespasm.git
synced 2024-11-10 07:21:58 +00:00
Sync music stuff with uHexen2: Removed S_FileExtension, replaced its use
by COM_FileGetExtension. Adjusted all users because COM_FileGetExtension doesn't include the leading dot for the extension, nor does it ever return NULL. git-svn-id: svn://svn.code.sf.net/p/quakespasm/code/trunk/quakespasm@455 af15c1b1-3010-417e-b628-4374ebc0bcbd
This commit is contained in:
parent
45498a99a4
commit
8a1b526e5d
8 changed files with 20 additions and 46 deletions
|
@ -53,11 +53,11 @@ typedef struct music_handler_s
|
|||
|
||||
static music_handler_t wanted_handlers[] =
|
||||
{
|
||||
{ CODECTYPE_OGG, BGM_STREAMER, -1, ".ogg", MUSIC_DIRNAME, NULL },
|
||||
{ CODECTYPE_MP3, BGM_STREAMER, -1, ".mp3", MUSIC_DIRNAME, NULL },
|
||||
{ CODECTYPE_FLAC, BGM_STREAMER, -1, ".flac", MUSIC_DIRNAME, NULL },
|
||||
{ CODECTYPE_WAV, BGM_STREAMER, -1, ".wav", MUSIC_DIRNAME, NULL },
|
||||
{ CODECTYPE_NONE, BGM_NONE, -1, NULL, NULL, NULL }
|
||||
{ CODECTYPE_OGG, BGM_STREAMER, -1, "ogg", MUSIC_DIRNAME, NULL },
|
||||
{ CODECTYPE_MP3, BGM_STREAMER, -1, "mp3", MUSIC_DIRNAME, NULL },
|
||||
{ CODECTYPE_FLAC, BGM_STREAMER, -1, "flac", MUSIC_DIRNAME, NULL },
|
||||
{ CODECTYPE_WAV, BGM_STREAMER, -1, "wav", MUSIC_DIRNAME, NULL },
|
||||
{ CODECTYPE_NONE, BGM_NONE, -1, NULL, NULL, NULL }
|
||||
};
|
||||
|
||||
static music_handler_t *music_handlers = NULL;
|
||||
|
@ -192,7 +192,7 @@ static void BGM_Play_noext (const char *filename, unsigned int allowed_types)
|
|||
handler = handler->next;
|
||||
continue;
|
||||
}
|
||||
q_snprintf(tmp, sizeof(tmp), "%s/%s%s",
|
||||
q_snprintf(tmp, sizeof(tmp), "%s/%s.%s",
|
||||
handler->dir, filename, handler->ext);
|
||||
switch (handler->player)
|
||||
{
|
||||
|
@ -231,8 +231,8 @@ void BGM_Play (const char *filename)
|
|||
return;
|
||||
}
|
||||
|
||||
ext = S_FileExtension(filename);
|
||||
if (!ext) /* try all things */
|
||||
ext = COM_FileGetExtension(filename);
|
||||
if (! *ext) /* try all things */
|
||||
{
|
||||
BGM_Play_noext(filename, ANY_CODECTYPE);
|
||||
return;
|
||||
|
@ -304,7 +304,7 @@ void BGM_PlayCDtrack (byte track, qboolean looping)
|
|||
goto _next;
|
||||
if (! CDRIPTYPE(handler->type))
|
||||
goto _next;
|
||||
q_snprintf(tmp, sizeof(tmp), "%s/track%02d%s",
|
||||
q_snprintf(tmp, sizeof(tmp), "%s/track%02d.%s",
|
||||
MUSIC_DIRNAME, (int)track, handler->ext);
|
||||
if (! COM_FileExists(tmp, &path_id))
|
||||
goto _next;
|
||||
|
@ -321,7 +321,7 @@ void BGM_PlayCDtrack (byte track, qboolean looping)
|
|||
Con_Printf("Couldn't find a cdrip for track %d\n", (int)track);
|
||||
else
|
||||
{
|
||||
q_snprintf(tmp, sizeof(tmp), "%s/track%02d%s",
|
||||
q_snprintf(tmp, sizeof(tmp), "%s/track%02d.%s",
|
||||
MUSIC_DIRNAME, (int)track, ext);
|
||||
bgmstream = S_CodecOpenStreamType(tmp, type);
|
||||
if (! bgmstream)
|
||||
|
|
|
@ -118,9 +118,6 @@ void SND_Spatialize (channel_t *ch);
|
|||
/* music stream support */
|
||||
void S_RawSamples(int samples, int rate, int width, int channels, byte * data, float volume);
|
||||
|
||||
/* returns file's extension including the dot, or NULL */
|
||||
const char *S_FileExtension (const char *name);
|
||||
|
||||
/* initializes cycling through a DMA buffer and returns information on it */
|
||||
qboolean SNDDMA_Init(dma_t *dma);
|
||||
|
||||
|
|
|
@ -132,8 +132,8 @@ snd_stream_t *S_CodecOpenStreamExt (const char *filename)
|
|||
snd_stream_t *stream;
|
||||
const char *ext;
|
||||
|
||||
ext = S_FileExtension(filename);
|
||||
if (!ext)
|
||||
ext = COM_FileGetExtension(filename);
|
||||
if (! *ext)
|
||||
{
|
||||
Con_Printf("No extension for %s\n", filename);
|
||||
return NULL;
|
||||
|
@ -163,15 +163,15 @@ snd_stream_t *S_CodecOpenStreamAny (const char *filename)
|
|||
snd_stream_t *stream;
|
||||
const char *ext;
|
||||
|
||||
ext = S_FileExtension(filename);
|
||||
if (!ext) /* try all available */
|
||||
ext = COM_FileGetExtension(filename);
|
||||
if (! *ext) /* try all available */
|
||||
{
|
||||
char tmp[MAX_QPATH];
|
||||
|
||||
codec = codecs;
|
||||
while (codec)
|
||||
{
|
||||
q_snprintf(tmp, sizeof(tmp), "%s%s", filename, codec->ext);
|
||||
q_snprintf(tmp, sizeof(tmp), "%s.%s", filename, codec->ext);
|
||||
stream = codec->codec_open(tmp);
|
||||
if (stream)
|
||||
{
|
||||
|
|
|
@ -264,29 +264,6 @@ static sfx_t *S_FindName (const char *name)
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
=================
|
||||
S_FileExtension
|
||||
|
||||
return file's extension including the dot, or NULL
|
||||
=================
|
||||
*/
|
||||
const char *S_FileExtension (const char *name)
|
||||
{
|
||||
const char *ptr = name + strlen(name) - 1;
|
||||
|
||||
while (ptr > name &&
|
||||
(*ptr != '/' && *ptr != '\\'))
|
||||
{
|
||||
if (*ptr == '.')
|
||||
return ptr;
|
||||
ptr--;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
==================
|
||||
S_TouchSound
|
||||
|
|
|
@ -546,7 +546,7 @@ snd_codec_t mp3_codec =
|
|||
{
|
||||
CODECTYPE_MP3,
|
||||
true, /* always available. */
|
||||
".mp3",
|
||||
"mp3",
|
||||
S_MP3_CodecInitialize,
|
||||
S_MP3_CodecShutdown,
|
||||
S_MP3_CodecOpenStream,
|
||||
|
|
|
@ -214,7 +214,7 @@ snd_codec_t mp3_codec =
|
|||
{
|
||||
CODECTYPE_MP3,
|
||||
false,
|
||||
".mp3",
|
||||
"mp3",
|
||||
S_MP3_CodecInitialize,
|
||||
S_MP3_CodecShutdown,
|
||||
S_MP3_CodecOpenStream,
|
||||
|
|
|
@ -120,7 +120,7 @@ static snd_stream_t *S_OGG_CodecOpenStream (const char *filename)
|
|||
|
||||
static int S_OGG_CodecReadStream (snd_stream_t *stream, int bytes, void *buffer)
|
||||
{
|
||||
int section; /* FIXME: handle section changes */
|
||||
int section; /* FIXME: handle section changes! */
|
||||
int cnt, res, rem;
|
||||
char * ptr;
|
||||
|
||||
|
@ -157,7 +157,7 @@ snd_codec_t ogg_codec =
|
|||
{
|
||||
CODECTYPE_OGG,
|
||||
false,
|
||||
".ogg",
|
||||
"ogg",
|
||||
S_OGG_CodecInitialize,
|
||||
S_OGG_CodecShutdown,
|
||||
S_OGG_CodecOpenStream,
|
||||
|
|
|
@ -268,7 +268,7 @@ snd_codec_t wav_codec =
|
|||
{
|
||||
CODECTYPE_WAVE,
|
||||
true, /* always available. */
|
||||
".wav",
|
||||
"wav",
|
||||
S_WAV_CodecInitialize,
|
||||
S_WAV_CodecShutdown,
|
||||
S_WAV_CodecOpenStream,
|
||||
|
|
Loading…
Reference in a new issue