Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Crash when calling GetPlayingOffset with an uninitialized sf::Music  (Read 3770 times)

0 Members and 1 Guest are viewing this topic.

4ian

  • Hero Member
  • *****
  • Posts: 680
    • View Profile
    • Game Develop website
Hi,

It seems that calling GetPlayingOffset on a uninitialized sf::Music lead to division by zero:

#include <SFML/Graphics.hpp>
#include <SFML/Audio.hpp>

int main()
{
    sf::Music music;
    music.GetPlayingOffset(); //I'm using a revision of SFML2 before the changes in naming conventions.

    return EXIT_SUCCESS;

}

Here is the backtrace:
#0 627A06C1     __udivmoddi4(n=0, d=0) (../../../../src/gcc-4.5.2/libgcc/../gcc/libgcc2.c:895)
#1 ??   __udivdi3 (n=0, d=0) (../../../../src/gcc-4.5.2/libgcc/../gcc/libgcc2.c:1140)
#2 627898D3     sf::SoundStream::GetPlayingOffset(this=0x28feb8) (D:\Florian\Programmation\GameDevelop2\ExtLibs\SFML\src\SFML\Audio\SoundStream.cpp:174)
#3 004013B1     main() (D:\Florian\Programmation\SFML_test\main.cpp:7)

Looking at SoundStream::GetPlayingOffset, the line where the crash comes from is this one ( Maybe add a check to be sure that mySampleRate and myChannelsCount are not equal to 0) :
return seconds(secs + static_cast<float>(m_samplesProcessed) / m_sampleRate / m_channelCount);

( I'm not using the latest revision of SFML2, but this line is the same in the current revision as in the revision i'm using, so I believe the bug is still here. )

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Crash when calling GetPlayingOffset with an uninitialized sf::Music
« Reply #1 on: August 13, 2012, 11:10:31 pm »
I fixed it, thanks :)
Laurent Gomila - SFML developer

 

anything