Ejemplo n.º 1
0
void Mix_Quit()
{
#ifdef USE_FLUIDSYNTH_MIDI
	if (initialized & MIX_INIT_FLUIDSYNTH) {
		Mix_QuitFluidSynth();
	}
#endif
#ifdef FLAC_MUSIC
	if (initialized & MIX_INIT_FLAC) {
		Mix_QuitFLAC();
	}
#endif
#ifdef MOD_MUSIC
	if (initialized & MIX_INIT_MOD) {
		Mix_QuitMOD();
	}
#endif
#ifdef MP3_MUSIC
	if (initialized & MIX_INIT_MP3) {
		Mix_QuitMP3();
	}
#endif
#ifdef OGG_MUSIC
	if (initialized & MIX_INIT_OGG) {
		Mix_QuitOgg();
	}
#endif
#ifdef MID_MUSIC
	if (soundfont_paths) {
		SDL_free(soundfont_paths);
	}
#endif
	initialized = 0;
}
Ejemplo n.º 2
0
/* Load an OGG stream from an SDL_RWops object */
OGG_music *OGG_new_RW(SDL_RWops *rw)
{
    OGG_music *music;
    ov_callbacks callbacks;

    callbacks.read_func = sdl_read_func;
    callbacks.seek_func = sdl_seek_func;
    callbacks.close_func = sdl_close_func;
    callbacks.tell_func = sdl_tell_func;

    music = (OGG_music *)malloc(sizeof *music);
    if ( music ) {
        /* Initialize the music structure */
        memset(music, 0, (sizeof *music));
        OGG_stop(music);
        OGG_setvolume(music, MIX_MAX_VOLUME);
        music->section = -1;

        if ( Mix_InitOgg() < 0 ) {
            return(NULL);
        }
        if ( vorbis.ov_open_callbacks(rw, &music->vf, NULL, 0, callbacks) < 0 ) {
            free(music);
            SDL_RWclose(rw);
            Mix_QuitOgg();
            SDL_SetError("Not an Ogg Vorbis audio stream");
            return(NULL);
        }
    } else {
        SDL_OutOfMemory();
    }
    return(music);
}
Ejemplo n.º 3
0
void Mix_Quit()
{
#ifdef OGG_MUSIC
 if (initialized & MIX_INIT_OGG) {
   Mix_QuitOgg();
 }
#endif
 initialized = 0;
}
Ejemplo n.º 4
0
/* Close the given OGG stream */
void OGG_delete(OGG_music *music)
{
    if ( music ) {
        if ( music->cvt.buf ) {
            free(music->cvt.buf);
        }
        vorbis.ov_clear(&music->vf);
        free(music);
        Mix_QuitOgg();
    }
}
Ejemplo n.º 5
0
void Mix_Quit()
{
#ifdef FLAC_MUSIC
	if (initialized & MIX_INIT_FLAC) {
		Mix_QuitFLAC();
	}
#endif
#ifdef MOD_MUSIC
	if (initialized & MIX_INIT_MOD) {
		Mix_QuitMOD();
	}
#endif
#ifdef MP3_MUSIC
	if (initialized & MIX_INIT_MP3) {
		Mix_QuitMP3();
	}
#endif
#ifdef OGG_MUSIC
	if (initialized & MIX_INIT_OGG) {
		Mix_QuitOgg();
	}
#endif
	initialized = 0;
}
Ejemplo n.º 6
0
/* don't call this directly; use Mix_LoadWAV_RW() for now. */
SDL_AudioSpec *Mix_LoadOGG_RW (SDL_RWops *src, int freesrc,
        SDL_AudioSpec *spec, Uint8 **audio_buf, Uint32 *audio_len)
{
    OggVorbis_File vf;
    ov_callbacks callbacks;
    vorbis_info *info;
    Uint8 *buf;
    int bitstream = -1;
    long samplesize;
    long samples;
    int read, to_read;
    int must_close = 1;
    int was_error = 1;
    
    if ( (!src) || (!audio_buf) || (!audio_len) )   /* sanity checks. */
        goto done;

    if ( Mix_InitOgg() < 0 )
        goto done;

    callbacks.read_func = sdl_read_func;
    callbacks.seek_func = sdl_seek_func;
    callbacks.tell_func = sdl_tell_func;
    callbacks.close_func = freesrc ? 
                           sdl_close_func_freesrc : sdl_close_func_nofreesrc;

    if (vorbis.ov_open_callbacks(src, &vf, NULL, 0, callbacks) != 0)
    {
        SDL_SetError("OGG bitstream is not valid Vorbis stream!");
        goto done;
    }

    must_close = 0;
    
    info = vorbis.ov_info(&vf, -1);
    
    *audio_buf = NULL;
    *audio_len = 0;
    memset(spec, '\0', sizeof (SDL_AudioSpec));

    spec->format = AUDIO_S16;
    spec->channels = info->channels;
    spec->freq = info->rate;
    spec->samples = 4096; /* buffer size */
    
    samples = (long)vorbis.ov_pcm_total(&vf, -1);

    *audio_len = spec->size = samples * spec->channels * 2;
    *audio_buf = malloc(*audio_len);
    if (*audio_buf == NULL)
        goto done;

    buf = *audio_buf;
    to_read = *audio_len;
#ifdef OGG_USE_TREMOR
    for (read = vorbis.ov_read(&vf, (char *)buf, to_read, &bitstream);
	 read > 0;
	 read = vorbis.ov_read(&vf, (char *)buf, to_read, &bitstream))
#else
    for (read = vorbis.ov_read(&vf, (char *)buf, to_read, 1/*LE*/, 2/*16bit*/, 1/*signed*/, &bitstream);
         read > 0;
         read = vorbis.ov_read(&vf, (char *)buf, to_read, 1, 2, 1, &bitstream))
#endif	 
    {
        if (read == OV_HOLE || read == OV_EBADLINK)
            break; /* error */
        
        to_read -= read;
        buf += read;
    }

    vorbis.ov_clear(&vf);
    was_error = 0;

    /* Don't return a buffer that isn't a multiple of samplesize */
    samplesize = ((spec->format & 0xFF)/8)*spec->channels;
    *audio_len &= ~(samplesize-1);

done:
    if (src && must_close)
    {
        if (freesrc)
            SDL_RWclose(src);
        else
            SDL_RWseek(src, 0, SEEK_SET);
    }

    if ( was_error )
        spec = NULL;

    Mix_QuitOgg();

    return(spec);
} /* Mix_LoadOGG_RW */