/* * @brief Loads the music by the specified name. */ s_music_t *S_LoadMusic(const char *name) { char key[MAX_QPATH]; s_music_t *music; StripExtension(name, key); if (!(music = (s_music_t *) S_FindMedia(key))) { void *buffer; SDL_RWops *rw; Mix_Music *mus; if (S_LoadMusicFile(key, &buffer, &rw, &mus)) { music = (s_music_t *) S_AllocMedia(key, sizeof(s_music_t)); music->media.Retain = S_RetainMusic; music->media.Free = S_FreeMusic; music->buffer = buffer; music->rw = rw; music->music = mus; S_RegisterMedia((s_media_t *) music); } else { Com_Debug("S_LoadMusic: Couldn't load %s\n", key); music = NULL; } } if (music) { s_music_state.playlist = g_list_append(s_music_state.playlist, music); } return music; }
/* * @brief */ s_sample_t *S_LoadSample(const char *name) { char key[MAX_QPATH]; s_sample_t *sample; if (!s_env.initialized) return NULL; if (!name || !name[0]) { Com_Error(ERR_DROP, "NULL name\n"); } StripExtension(name, key); if (!(sample = (s_sample_t *) S_FindMedia(key))) { sample = (s_sample_t *) S_AllocMedia(key, sizeof(s_sample_t)); sample->media.Free = S_FreeSample; S_LoadSampleChunk(sample); S_RegisterMedia((s_media_t *) sample); } return sample; }
/* * @brief Registers and returns a new sample, aliasing the chunk provided by * the specified sample. */ static s_sample_t *S_AliasSample(s_sample_t *sample, const char *alias) { s_sample_t *s = (s_sample_t *) S_AllocMedia(alias, sizeof(s_sample_t)); s->chunk = sample->chunk; S_RegisterMedia((s_media_t *) s); return s; }