SOUNDCLIP *my_load_static_mp3(const char *filname, int voll, bool loop) { // Load via soundcache. long muslen = 0; char* mp3buffer = get_cached_sound(filname, false, &muslen); if (mp3buffer == NULL) return NULL; // now, create an MP3 structure for it thismp3 = new MYSTATICMP3(); if (thismp3 == NULL) { free(mp3buffer); return NULL; } thismp3->vol = voll; thismp3->mp3buffer = NULL; thismp3->repeat = loop; _mp3_mutex.Lock(); thismp3->tune = almp3_create_mp3(mp3buffer, muslen); _mp3_mutex.Unlock(); thismp3->done = 0; thismp3->ready = true; if (thismp3->tune == NULL) { free(mp3buffer); delete thismp3; return NULL; } thismp3->mp3buffer = mp3buffer; return thismp3; }
SOUNDCLIP *my_load_static_mp3(const char *filname, int voll, bool loop) { // first, read the mp3 into memory PACKFILE *mp3in = pack_fopen(filname, "rb"); if (mp3in == NULL) return NULL; long muslen = mp3in->todo; char *mp3buffer = (char *)malloc(muslen); if (mp3buffer == NULL) return NULL; pack_fread(mp3buffer, muslen, mp3in); pack_fclose(mp3in); // now, create an MP3 structure for it thismp3 = new MYSTATICMP3(); if (thismp3 == NULL) { free(mp3buffer); return NULL; } thismp3->vol = voll; thismp3->mp3buffer = NULL; thismp3->repeat = loop; thismp3->tune = almp3_create_mp3(mp3buffer, muslen); thismp3->done = 0; if (thismp3->tune == NULL) { free(mp3buffer); delete thismp3; return NULL; } thismp3->mp3buffer = mp3buffer; return thismp3; }