music_ogg.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.
slouken@63
     1
/*
slouken@518
     2
  SDL_mixer:  An audio mixer library based on the SDL library
slouken@601
     3
  Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
slouken@63
     4
slouken@518
     5
  This software is provided 'as-is', without any express or implied
slouken@518
     6
  warranty.  In no event will the authors be held liable for any damages
slouken@518
     7
  arising from the use of this software.
slouken@63
     8
slouken@518
     9
  Permission is granted to anyone to use this software for any purpose,
slouken@518
    10
  including commercial applications, and to alter it and redistribute it
slouken@518
    11
  freely, subject to the following restrictions:
slouken@63
    12
slouken@518
    13
  1. The origin of this software must not be misrepresented; you must not
slouken@518
    14
     claim that you wrote the original software. If you use this software
slouken@518
    15
     in a product, an acknowledgment in the product documentation would be
slouken@518
    16
     appreciated but is not required.
slouken@518
    17
  2. Altered source versions must be plainly marked as such, and must not be
slouken@518
    18
     misrepresented as being the original software.
slouken@518
    19
  3. This notice may not be removed or altered from any source distribution.
slouken@63
    20
*/
slouken@63
    21
slouken@140
    22
/* $Id$ */
slouken@138
    23
slouken@63
    24
#ifdef OGG_MUSIC
slouken@63
    25
slouken@63
    26
/* This file supports Ogg Vorbis music streams */
slouken@63
    27
slouken@695
    28
#if defined(OGG_HEADER)
slouken@695
    29
#include OGG_HEADER
slouken@695
    30
#elif defined(OGG_USE_TREMOR)
slouken@695
    31
#include <tremor/ivorbisfile.h>
slouken@353
    32
#else
slouken@63
    33
#include <vorbis/vorbisfile.h>
slouken@353
    34
#endif
slouken@63
    35
slouken@63
    36
typedef struct {
slouken@625
    37
    SDL_RWops *src;
slouken@625
    38
    int freesrc;
slouken@617
    39
    int playing;
slouken@617
    40
    int volume;
slouken@617
    41
    OggVorbis_File vf;
slouken@617
    42
    int section;
slouken@617
    43
    SDL_AudioCVT cvt;
slouken@617
    44
    int len_available;
slouken@617
    45
    Uint8 *snd_available;
slouken@63
    46
} OGG_music;
slouken@63
    47
slouken@63
    48
/* Initialize the Ogg Vorbis player, with the given mixer settings
slouken@63
    49
   This function returns 0, or -1 if there was an error.
slouken@63
    50
 */
slouken@63
    51
extern int OGG_init(SDL_AudioSpec *mixer);
slouken@63
    52
slouken@63
    53
/* Set the volume for an OGG stream */
slouken@63
    54
extern void OGG_setvolume(OGG_music *music, int volume);
slouken@63
    55
slouken@246
    56
/* Load an OGG stream from an SDL_RWops object */
slouken@625
    57
extern OGG_music *OGG_new_RW(SDL_RWops *src, int freesrc);
slouken@246
    58
slouken@63
    59
/* Start playback of a given OGG stream */
slouken@63
    60
extern void OGG_play(OGG_music *music);
slouken@63
    61
slouken@63
    62
/* Return non-zero if a stream is currently playing */
slouken@63
    63
extern int OGG_playing(OGG_music *music);
slouken@63
    64
slouken@63
    65
/* Play some of a stream previously started with OGG_play() */
icculus@281
    66
extern int OGG_playAudio(OGG_music *music, Uint8 *stream, int len);
slouken@63
    67
slouken@63
    68
/* Stop playback of a stream previously started with OGG_play() */
slouken@63
    69
extern void OGG_stop(OGG_music *music);
slouken@63
    70
slouken@63
    71
/* Close the given OGG stream */
slouken@63
    72
extern void OGG_delete(OGG_music *music);
slouken@63
    73
slouken@155
    74
/* Jump (seek) to a given position (time is in seconds) */
slouken@155
    75
extern void OGG_jump_to_time(OGG_music *music, double time);
slouken@155
    76
slouken@63
    77
#endif /* OGG_MUSIC */