fluidsynth.h
author Sam Lantinga <slouken@libsdl.org>
Sat, 23 Aug 2014 10:57:26 -0700
changeset 696 9599bb0ff844
parent 617 87116a42526e
child 711 f40c5ac95b12
permissions -rw-r--r--
Fixed bug 2690 - Floating point exception in Mix_Volume()

Francisco de la Peña

This happens rarely under uncertain circunstances, as it doesn't crash always and does it randomly. Fortunately, I've got a backtrace when running a GDB session. Might be a divide by zero issue in SDL or SDL_mixer.

Program received signal SIGFPE, Arithmetic exception.
0x00000038e8c08a7d in mix_channels (udata=<optimized out>, stream=0x24e11b0 "", len=2048) at mixer.c:345
345 Mix_Volume(i, (mix_channel[i].fade_volume * ticks) / mix_channel[i].fade_length );
(gdb) bt f
#0 0x00000038e8c08a7d in mix_channels (udata=<optimized out>, stream=0x24e11b0 "", len=2048) at mixer.c:345
ticks = 0
mix_input = <optimized out>
i = 0
mixable = <optimized out>
volume = <optimized out>
sdl_ticks = 129373

Using SDL 2.0.3 and SDL_Mixer 2.0.0, PulseAudio, Fedora 20 x86_64 but looks like can be reproduced on other platforms.
chewi@506
     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>
chewi@506
     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.
chewi@506
     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:
chewi@506
    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.
chewi@506
    20
slouken@518
    21
  James Le Cuirot
slouken@518
    22
  chewi@aura-online.co.uk
chewi@506
    23
*/
chewi@506
    24
chewi@506
    25
#ifndef _FLUIDSYNTH_H_
chewi@506
    26
#define _FLUIDSYNTH_H_
chewi@506
    27
slouken@532
    28
#ifdef USE_FLUIDSYNTH_MIDI
slouken@532
    29
chewi@506
    30
#include "dynamic_fluidsynth.h"
chewi@506
    31
#include <SDL_rwops.h>
chewi@506
    32
#include <SDL_audio.h>
chewi@506
    33
chewi@506
    34
typedef struct {
slouken@617
    35
    SDL_AudioCVT convert;
slouken@617
    36
    fluid_synth_t *synth;
slouken@617
    37
    fluid_player_t* player;
chewi@506
    38
} FluidSynthMidiSong;
chewi@506
    39
chewi@506
    40
int fluidsynth_init(SDL_AudioSpec *mixer);
slouken@521
    41
FluidSynthMidiSong *fluidsynth_loadsong_RW(SDL_RWops *rw, int freerw);
chewi@506
    42
void fluidsynth_freesong(FluidSynthMidiSong *song);
chewi@506
    43
void fluidsynth_start(FluidSynthMidiSong *song);
chewi@506
    44
void fluidsynth_stop(FluidSynthMidiSong *song);
chewi@506
    45
int fluidsynth_active(FluidSynthMidiSong *song);
chewi@506
    46
void fluidsynth_setvolume(FluidSynthMidiSong *song, int volume);
chewi@506
    47
int fluidsynth_playsome(FluidSynthMidiSong *song, void *stream, int len);
chewi@506
    48
slouken@532
    49
#endif /* USE_FLUIDSYNTH_MIDI */
slouken@532
    50
chewi@506
    51
#endif /* _FLUIDSYNTH_H_ */