music_modplug.h
author Sam Lantinga <slouken@libsdl.org>
Wed, 17 Jun 2015 00:11:41 -0700
changeset 705 fe757163b8f7
parent 695 6a5e6d8d6a35
child 711 f40c5ac95b12
permissions -rw-r--r--
Fixed bug 3018 - Loading MIDI music using FluidSynth leaks memory.

Philipp Wiesemann

There is a memory leak in fluidsynth.c and fluidsynth_loadsong_RW_internal(). The allocated temporary buffer is not deleted if fluid_player_add_mem() returns FLUID_OK.
     1 /*
     2   SDL_mixer:  An audio mixer library based on the SDL library
     3   Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
     4 
     5   This software is provided 'as-is', without any express or implied
     6   warranty.  In no event will the authors be held liable for any damages
     7   arising from the use of this software.
     8 
     9   Permission is granted to anyone to use this software for any purpose,
    10   including commercial applications, and to alter it and redistribute it
    11   freely, subject to the following restrictions:
    12 
    13   1. The origin of this software must not be misrepresented; you must not
    14      claim that you wrote the original software. If you use this software
    15      in a product, an acknowledgment in the product documentation would be
    16      appreciated but is not required.
    17   2. Altered source versions must be plainly marked as such, and must not be
    18      misrepresented as being the original software.
    19   3. This notice may not be removed or altered from any source distribution.
    20 */
    21 
    22 #ifdef MODPLUG_MUSIC
    23 
    24 #ifdef MODPLUG_HEADER
    25 #include MODPLUG_HEADER
    26 #else
    27 #include <libmodplug/modplug.h>
    28 #endif
    29 #include "SDL_rwops.h"
    30 #include "SDL_audio.h"
    31 #include "SDL_mixer.h"
    32 
    33 typedef struct {
    34     ModPlugFile *file;
    35     int playing;
    36 } modplug_data;
    37 
    38 int modplug_init(SDL_AudioSpec *mixer);
    39 
    40 /* Uninitialize the music players */
    41 void modplug_exit(void);
    42 
    43 /* Set the volume for a modplug stream */
    44 void modplug_setvolume(modplug_data *music, int volume);
    45 
    46 /* Load a modplug stream from an SDL_RWops object */
    47 modplug_data *modplug_new_RW(SDL_RWops *rw, int freerw);
    48 
    49 /* Start playback of a given modplug stream */
    50 void modplug_play(modplug_data *music);
    51 
    52 /* Return non-zero if a stream is currently playing */
    53 int modplug_playing(modplug_data *music);
    54 
    55 /* Play some of a stream previously started with modplug_play() */
    56 int modplug_playAudio(modplug_data *music, Uint8 *stream, int len);
    57 
    58 /* Stop playback of a stream previously started with modplug_play() */
    59 void modplug_stop(modplug_data *music);
    60 
    61 /* Close the given modplug stream */
    62 void modplug_delete(modplug_data *music);
    63 
    64 /* Jump (seek) to a given position (time is in seconds) */
    65 void modplug_jump_to_time(modplug_data *music, double time);
    66 
    67 #endif /* MODPLUG_MUSIC */