dynamic_modplug.h
author Sam Lantinga <slouken@libsdl.org>
Sat, 23 Aug 2014 10:57:26 -0700
changeset 696 9599bb0ff844
parent 695 6a5e6d8d6a35
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.
slouken@639
     1
/*
slouken@639
     2
  SDL_mixer:  An audio mixer library based on the SDL library
slouken@639
     3
  Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
slouken@639
     4
slouken@639
     5
  This software is provided 'as-is', without any express or implied
slouken@639
     6
  warranty.  In no event will the authors be held liable for any damages
slouken@639
     7
  arising from the use of this software.
slouken@639
     8
slouken@639
     9
  Permission is granted to anyone to use this software for any purpose,
slouken@639
    10
  including commercial applications, and to alter it and redistribute it
slouken@639
    11
  freely, subject to the following restrictions:
slouken@639
    12
slouken@639
    13
  1. The origin of this software must not be misrepresented; you must not
slouken@639
    14
     claim that you wrote the original software. If you use this software
slouken@639
    15
     in a product, an acknowledgment in the product documentation would be
slouken@639
    16
     appreciated but is not required.
slouken@639
    17
  2. Altered source versions must be plainly marked as such, and must not be
slouken@639
    18
     misrepresented as being the original software.
slouken@639
    19
  3. This notice may not be removed or altered from any source distribution.
slouken@639
    20
*/
slouken@639
    21
slouken@639
    22
#ifdef MODPLUG_MUSIC
slouken@639
    23
slouken@695
    24
#ifdef MODPLUG_HEADER
slouken@695
    25
#include MODPLUG_HEADER
slouken@695
    26
#else
slouken@695
    27
#include <libmodplug/modplug.h>
slouken@695
    28
#endif
slouken@639
    29
slouken@639
    30
typedef struct {
slouken@639
    31
    int loaded;
slouken@639
    32
    void *handle;
slouken@639
    33
slouken@639
    34
    ModPlugFile* (*ModPlug_Load)(const void* data, int size);
slouken@639
    35
    void (*ModPlug_Unload)(ModPlugFile* file);
slouken@639
    36
    int  (*ModPlug_Read)(ModPlugFile* file, void* buffer, int size);
slouken@639
    37
    void (*ModPlug_Seek)(ModPlugFile* file, int millisecond);
slouken@639
    38
    void (*ModPlug_GetSettings)(ModPlug_Settings* settings);
slouken@639
    39
    void (*ModPlug_SetSettings)(const ModPlug_Settings* settings);
slouken@639
    40
    void (*ModPlug_SetMasterVolume)(ModPlugFile* file,unsigned int cvol) ;
slouken@639
    41
} modplug_loader;
slouken@639
    42
slouken@639
    43
extern modplug_loader modplug;
slouken@639
    44
slouken@639
    45
#endif /* MODPLUG_MUSIC */
slouken@639
    46
slouken@639
    47
extern int Mix_InitModPlug();
slouken@639
    48
extern void Mix_QuitModPlug();