music_ogg.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.
     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 /* $Id$ */
    23 
    24 #ifdef OGG_MUSIC
    25 
    26 /* This file supports Ogg Vorbis music streams */
    27 
    28 #if defined(OGG_HEADER)
    29 #include OGG_HEADER
    30 #elif defined(OGG_USE_TREMOR)
    31 #include <tremor/ivorbisfile.h>
    32 #else
    33 #include <vorbis/vorbisfile.h>
    34 #endif
    35 
    36 typedef struct {
    37     SDL_RWops *src;
    38     int freesrc;
    39     int playing;
    40     int volume;
    41     OggVorbis_File vf;
    42     int section;
    43     SDL_AudioCVT cvt;
    44     int len_available;
    45     Uint8 *snd_available;
    46 } OGG_music;
    47 
    48 /* Initialize the Ogg Vorbis player, with the given mixer settings
    49    This function returns 0, or -1 if there was an error.
    50  */
    51 extern int OGG_init(SDL_AudioSpec *mixer);
    52 
    53 /* Set the volume for an OGG stream */
    54 extern void OGG_setvolume(OGG_music *music, int volume);
    55 
    56 /* Load an OGG stream from an SDL_RWops object */
    57 extern OGG_music *OGG_new_RW(SDL_RWops *src, int freesrc);
    58 
    59 /* Start playback of a given OGG stream */
    60 extern void OGG_play(OGG_music *music);
    61 
    62 /* Return non-zero if a stream is currently playing */
    63 extern int OGG_playing(OGG_music *music);
    64 
    65 /* Play some of a stream previously started with OGG_play() */
    66 extern int OGG_playAudio(OGG_music *music, Uint8 *stream, int len);
    67 
    68 /* Stop playback of a stream previously started with OGG_play() */
    69 extern void OGG_stop(OGG_music *music);
    70 
    71 /* Close the given OGG stream */
    72 extern void OGG_delete(OGG_music *music);
    73 
    74 /* Jump (seek) to a given position (time is in seconds) */
    75 extern void OGG_jump_to_time(OGG_music *music, double time);
    76 
    77 #endif /* OGG_MUSIC */