wavestream.h
author Sam Lantinga <slouken@libsdl.org>
Wed, 17 Jun 2015 00:11:41 -0700
changeset 705 fe757163b8f7
parent 625 1d489d8ec2e0
child 709 1ef7c1254ffb
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@0
     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@0
     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@0
     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@0
    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@0
    20
*/
slouken@0
    21
slouken@140
    22
/* $Id$ */
slouken@138
    23
slouken@0
    24
/* This file supports streaming WAV files, without volume adjustment */
slouken@0
    25
slouken@0
    26
#include <stdio.h>
slouken@0
    27
slouken@0
    28
typedef struct {
slouken@625
    29
    SDL_RWops *src;
slouken@625
    30
    SDL_bool freesrc;
slouken@617
    31
    long  start;
slouken@617
    32
    long  stop;
slouken@617
    33
    SDL_AudioCVT cvt;
slouken@0
    34
} WAVStream;
slouken@0
    35
slouken@0
    36
/* Initialize the WAVStream player, with the given mixer settings
slouken@0
    37
   This function returns 0, or -1 if there was an error.
slouken@0
    38
 */
slouken@0
    39
extern int WAVStream_Init(SDL_AudioSpec *mixer);
slouken@0
    40
slouken@0
    41
/* Unimplemented */
slouken@0
    42
extern void WAVStream_SetVolume(int volume);
slouken@0
    43
slouken@381
    44
/* Load a WAV stream from an SDL_RWops object */
slouken@625
    45
extern WAVStream *WAVStream_LoadSong_RW(SDL_RWops *src, int freesrc);
slouken@381
    46
slouken@0
    47
/* Start playback of a given WAV stream */
slouken@0
    48
extern void WAVStream_Start(WAVStream *wave);
slouken@0
    49
slouken@0
    50
/* Play some of a stream previously started with WAVStream_Start() */
slouken@407
    51
extern int WAVStream_PlaySome(Uint8 *stream, int len);
slouken@0
    52
slouken@0
    53
/* Stop playback of a stream previously started with WAVStream_Start() */
slouken@0
    54
extern void WAVStream_Stop(void);
slouken@0
    55
slouken@0
    56
/* Close the given WAV stream */
slouken@0
    57
extern void WAVStream_FreeSong(WAVStream *wave);
slouken@0
    58
slouken@0
    59
/* Return non-zero if a stream is currently playing */
slouken@64
    60
extern int WAVStream_Active(void);