AprilAndFriends / theoraplayer

A multi-threaded C++ library that plays video files supporting multiple codecs across platforms. Easy to use, fast, responsive, abstract interface and minimal dependencies, you'll soon be wondering how you lived without it! ;) Audio and Video interfaces are completely abstracted so the library can be used anywhere, regardless of what you use to display video frames and play audio samples (eg. OpenGL / OpenAL, Direct3D / DirectSound?, SDL / SDL_mixer, X11 / alsa ...) The library can pre-cache video frames and decoded audio samples for maximum efficiency and smooth playback, even on single-cpu systems. Currently, the library supports Theora on Windows, Mac, iOS, Linux, Android, WinRT and Windows Phone. H.264 is supported on Mac and iOS.
BSD 3-Clause "New" or "Revised" License
84 stars 43 forks source link

Crash if audio gain < 1.0f #3

Closed d1ke closed 9 years ago

d1ke commented 9 years ago

First of all thank your for great library!

When i set audio gain, my application crashes inside your library. Seems that problem is here:

void TheoraAudioPacketQueue::addAudioPacket(float** buffer, int numSamples, float gain)
{
    ...
    if (gain < 1.0f)
    {
        ...
        *dataptr = buffer[i][j] * gain;
    }
    else
    {
        ...
        *dataptr = buffer[j][i];
    }
}

Note different order of i and j.
Also i think it would be safer to compare gain with 1.0f - FLT_EPSILON or 1.0f - std::numeric_limits::epsilon().

kspes commented 9 years ago

Thanks, glad you like the lib :)

Loool what a stupid bug, the i and j are inverted if gain is applied. Fixed!