void BGM_Play (const char *filename) { char tmp[MAX_QPATH]; const char *ext; music_handler_t *handler; BGM_Stop(); if (music_handlers == NULL) return; if (!filename || !*filename) { Con_DPrintf("null music file name\n"); return; } ext = COM_FileGetExtension(filename); if (! *ext) /* try all things */ { BGM_Play_noext(filename, ANY_CODECTYPE); return; } handler = music_handlers; while (handler) { if (handler->is_available && !q_strcasecmp(ext, handler->ext)) break; handler = handler->next; } if (!handler) { Con_Printf("Unhandled extension for %s\n", filename); return; } q_snprintf(tmp, sizeof(tmp), "%s/%s", handler->dir, filename); switch (handler->player) { case BGM_MIDIDRV: /* not supported in quake */ break; case BGM_STREAMER: bgmstream = S_CodecOpenStreamType(tmp, handler->type); if (bgmstream) return; /* success */ break; case BGM_NONE: default: break; } Con_Printf("Couldn't handle music file %s\n", filename); }
void BGM_Play (const char *filename) { char tmp[MAX_QPATH]; const char *ext; music_handler_t *handler; BGM_Stop(); if (music_handlers == NULL) return; if (!filename || !*filename) { Con_DPrintf("null music file name\n"); return; } ext = COM_FileGetExtension(filename); if (! *ext) /* try all things */ { BGM_Play_noext(filename, ANY_CODECTYPE); return; } /* use the filename as is */ handler = music_handlers; while (handler) { if (handler->is_available && !q_strcasecmp(ext, handler->ext)) break; handler = handler->next; } if (!handler) { Con_Printf("Unhandled extension for %s\n", filename); return; } q_snprintf(tmp, sizeof(tmp), "%s/%s", handler->dir, filename); switch (handler->player) { case BGM_MIDIDRV: if (BGM_Play_mididrv(tmp) == 0) return; /* success */ /* BGM_MIDIDRV is followed by CODECTYPE_MID streamer. * Even if the midi driver failed, we may still have * a chance with the streamer if it's available... */ if (! (handler->next && handler->next->is_available)) break; handler = handler->next; case BGM_STREAMER: bgmstream = S_CodecOpenStreamType(tmp, handler->type); if (bgmstream) return; /* success */ break; case BGM_NONE: default: break; } Con_Printf("Couldn't handle music file %s\n", filename); }