Hirdetés
- Brogyi: CTEK akkumulátor töltő és másolatai
- Sub-ZeRo: Euro Truck Simulator 2 & American Truck Simulator 1 (esetleg 2 majd, ha lesz) :)
- eBay-es kütyük kis pénzért
- lezso6: Nemzetközi újév visszaszámlátor alkoholistáknak
- D1Rect: Nagy "hülyétkapokazapróktól" topik
- Kalandor: „Ha engedtem volna a lelkiismeretemnek, az üzlet kevésbé lett volna jövedelmező”
- vrob: Próbálkozás 386 alaplap újraélesztésre
- Luck Dragon: Asszociációs játék. :)
- sziku69: Szólánc.
- sziku69: Fűzzük össze a szavakat :)
-
LOGOUT

Új hozzászólás Aktív témák
-
emitter
őstag
válasz
emitter
#1599
üzenetére
van ez a fv:
/* Load a music file */
Mix_Music *myMix_LoadMUS(const char *file)
{
FILE *fp;
char *ext;
Uint8 magic[5], moremagic[9];
Mix_Music *music;
/* Figure out what kind of file this is */
fp = fopen(file, ''rb'');
if ( (fp == NULL) || !fread(magic, 4, 1, fp) ) {
if ( fp != NULL ) {
fclose(fp);
}
Mix_SetError(''Couldn't read from '%s''', file);
return(NULL);
}
if (!fread(moremagic, 8, 1, fp)) {
Mix_SetError(''Couldn't read from '%s''', file);
return(NULL);
}
magic[4] = '\0';
moremagic[8] = '\0';
fclose(fp);
/* Figure out the file extension, so we can determine the type */
ext = strrchr(file, '.');
if ( ext ) ++ext; /* skip the dot in the extension */
/* Allocate memory for the music structure */
music = (Mix_Music *)malloc(sizeof(Mix_Music));
if ( music == NULL ) {
Mix_SetError(''Out of memory'');
return(NULL);
}
music->error = 0;
#ifdef CMD_MUSIC
if ( music_cmd ) {
music->type = MUS_CMD;
music->data.cmd = MusicCMD_LoadSong(music_cmd, file);
if ( music->data.cmd == NULL ) {
music->error = 1;
}
} else
#endif
#ifdef WAV_MUSIC
/* WAVE files have the magic four bytes ''RIFF''
AIFF files have the magic 12 bytes ''FORM'' XXXX ''AIFF''
*/
if ( (ext && MIX_string_equals(ext, ''WAV'')) ||
((strcmp((char *)magic, ''RIFF'') == 0) && (strcmp((char *)(moremagic+4), ''WAVE'') == 0)) ||
(strcmp((char *)magic, ''FORM'') == 0) ) {
music->type = MUS_WAV;
music->data.wave = WAVStream_LoadSong(file, (char *)magic);
if ( music->data.wave == NULL ) {
Mix_SetError(''Unable to load WAV file'');
music->error = 1;
}
} else
#endif
#ifdef MID_MUSIC
/* MIDI files have the magic four bytes ''MThd'' */
if ( (ext && MIX_string_equals(ext, ''MID'')) ||
(ext && MIX_string_equals(ext, ''MIDI'')) ||
strcmp((char *)magic, ''MThd'') == 0 ||
( strcmp((char *)magic, ''RIFF'') == 0 &&
strcmp((char *)(moremagic+4), ''RMID'') == 0 ) ) {
music->type = MUS_MID;
#ifdef USE_NATIVE_MIDI
if ( native_midi_ok ) {
music->data.nativemidi = native_midi_loadsong((char *)file);
if ( music->data.nativemidi == NULL ) {
Mix_SetError(''%s'', native_midi_error());
music->error = 1;
}
} MIDI_ELSE
#endif
#ifdef USE_TIMIDITY_MIDI
if ( timidity_ok ) {
music->data.midi = Timidity_LoadSong((char *)file);
if ( music->data.midi == NULL ) {
Mix_SetError(''%s'', Timidity_Error());
music->error = 1;
}
} else {
Mix_SetError(''%s'', Timidity_Error());
music->error = 1;
}
#endif
} else
#endif
#ifdef OGG_MUSIC
/* Ogg Vorbis files have the magic four bytes ''OggS'' */
if ( (ext && MIX_string_equals(ext, ''OGG'')) ||
strcmp((char *)magic, ''OggS'') == 0 ) {
music->type = MUS_OGG;
music->data.ogg = OGG_new(file);
if ( music->data.ogg == NULL ) {
music->error = 1;
}
} else
#endif
#ifdef MP3_MUSIC
if ( (ext && MIX_string_equals(ext, ''MPG'')) ||
(ext && MIX_string_equals(ext, ''MP3'')) ||
(ext && MIX_string_equals(ext, ''MPEG'')) ||
magic[0]==0xFF && (magic[1]&0xF0)==0xF0) {
SMPEG_Info info;
music->type = MUS_MP3;
music->data.mp3 = SMPEG_new(file, &info, 0);
if(!info.has_audio){
Mix_SetError(''MPEG file does not have any audio stream.'');
music->error = 1;
}else{
SMPEG_actualSpec(music->data.mp3, &used_mixer);
}
} else
#endif
#if defined(MOD_MUSIC) || defined(LIBMIKMOD_MUSIC)
if ( 1 ) {
music->type = MUS_MOD;
music->data.module = MikMod_LoadSong((char *)file, 64);
if ( music->data.module == NULL ) {
Mix_SetError(''%s'', MikMod_strerror(MikMod_errno));
music->error = 1;
} else {
/* Stop implicit looping, fade out and other flags. */
music->data.module->extspd = 1;
music->data.module->panflag = 1;
music->data.module->wrap = 0;
music->data.module->loop = 0;
#if 0 /* Don't set fade out by default - unfortunately there's no real way
to query the status of the song or set trigger actions. Hum. */
music->data.module->fadeout = 1;
#endif
}
} else
#endif
{
Mix_SetError(''Unrecognized music format'');
music->error = 1;
}
if ( music->error ) {
free(music);
music = NULL;
}
return(music);
}
---------------
a végén halálozik el:
...
Mix_SetError(''Unrecognized music format'');
music->error = 1;
}
if ( music->error ) {
free(music);
music = NULL;
}
return(music);
}
szóval errort-t 1-re állítja, és ezért NULL-pointerrel tér vissza.. a kérdésem, hogy az #ifdef és #endif tagok mit csinálnak pontosan, kellenek ezek egyáltalán bele?
vagy van olyan elsőre szemet szúró dolog, ami miatt ez történik?
Új hozzászólás Aktív témák
● olvasd el a téma összefoglalót!
- Google Pixel topik
- Automata kávégépek
- Mibe tegyem a megtakarításaimat?
- Kuponkunyeráló
- Audi, Cupra, Seat, Skoda, Volkswagen topik
- Brogyi: CTEK akkumulátor töltő és másolatai
- Intel Core i5 / i7 / i9 "Alder Lake-Raptor Lake/Refresh" (LGA1700)
- Gitáros topic
- Proxmox VE
- Samsung Galaxy S23 és S23+ - ami belül van, az számít igazán
- További aktív témák...
- Lenovo ThinkPad P16V Gen2. Munkaállomás Intel Core Ultra 7-165H/32RAM/1TBSSD/RTX2000Ada 3év gar
- FELÚJÍTOTT Refubished Lenovo Thinkpad T14s G2 Üzleti Golyóálló Laptop -50% Ryzen 5 PRO 5 16/512 FHD
- 2x32gb szerver ram bontatlanok .
- Lenovo ThinkBook 14s Yoga 2-in-1 üzleti laptop tollal i7-1165G7 16gb ram 512ssd FHD IPS Gari
- Nothing Phone 1 (8GB/128GB, dual sim, független) + Nothing tok + Nothing bontatlan fólia
- magyar billentyűzet - 136 - Lenovo Legion Pro 7 (16IRX9H) - i9-14900HX, RTX 4080 - 4 ÉV GARANCIA!
- Akciós kisWorkstation! Dell Precision 3570 i7-1255U 4.7GHz / 16GB / 512GB / Quadro T550 4GB FHD 15"
- Keresek Xbox Series S / Series X / Playstation 5 konzolokat
- REFURBISHED - DELL Performance Dock WD19DCS (210-AZBN)
- Újszerű Dell Latitude 5420 - i7 1185G7 ,16-32GB RAM, 512GB SSD, jó akku, számla, 6 hó gar
Állásajánlatok
Cég: Laptopszaki Kft.
Város: Budapest
Cég: PCMENTOR SZERVIZ KFT.
Város: Budapest


