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

Author Topic: sf::Music Stop & Play does not play the sound & mem  (Read 6602 times)

0 Members and 1 Guest are viewing this topic.

AdrianM

  • Newbie
  • *
  • Posts: 43
    • View Profile
sf::Music Stop & Play does not play the sound & mem
« on: March 11, 2009, 05:49:04 pm »
I'm using the latest sources from the svn compiled in static libraries. I'm giving a minimal and complete example that causes incorect behaviour on my windows with SP3. I'm just loading a sound, playing it, stopping and then attempting to play it again. The second time it does not start playing which is rather weird. Pause functions as expected.
I searched the forum and there was another post about this issue. The solution there was to expect version 1.3 or get the latest sources from svn. Sadly i did not manage to solve this either way.
Here's the code:

Code: [Select]

////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Audio.hpp>
#include <iostream>

#pragma comment(lib,"sfml-graphics-s.lib")
#pragma comment(lib,"sfml-window-s.lib")
#pragma comment(lib,"sfml-system-s.lib")
#pragma comment(lib,"sfml-audio-s.lib")

int main()
{
    // Load the music from an OggVorbis file
    sf::Music Music;
    if (!Music.OpenFromFile("01.ogg"))
        return EXIT_FAILURE;

    // Play it
    Music.Play();
std::cout<<"Playing the first time" << std::endl;
sf::Sleep(2.0f);
Music.Stop();
std::cout<<"Done & stopped" << std::endl;

Music.Play();
std::cout<<"Playing the second time" << std::endl;
sf::Sleep(2.0f);

std::cout<<"Done" << std::endl;

    std::cout << std::endl;

    // Wait until the user presses 'enter' key
    std::cout << "Press enter to exit..." << std::endl;
    std::cin.ignore(10000, '\n');

    return EXIT_SUCCESS;
}


Also the following code seems to report memory leaks, is it just me or it may be an issue with sfml?

Code: [Select]

////////////////////////////////////////////////////////////
// Headers
////////////////////////////////////////////////////////////
#include <SFML/Audio.hpp>
#include <iostream>

#pragma comment(lib,"sfml-graphics-s-d.lib")
#pragma comment(lib,"sfml-window-s-d.lib")
#pragma comment(lib,"sfml-system-s-d.lib")
#pragma comment(lib,"sfml-audio-s-d.lib")

#include <crtdbg.h>

#ifdef _DEBUG
void* operator new(size_t nSize, const char * lpszFileName, int nLine);
#define DEBUG_NEW new(THIS_FILE, __LINE__)

#define MALLOC_DBG(x) _malloc_dbg(x, 1, THIS_FILE, __LINE__);
#define malloc(x) MALLOC_DBG(x)

#endif // _DEBUG

int main()
{
{
// Load the music from an OggVorbis file
sf::Music Music;
if (!Music.OpenFromFile("01.ogg"))
return EXIT_FAILURE;

// Play it
Music.Play();
std::cout<<"Playing the first time" << std::endl;
sf::Sleep(2.0f);

std::cout<<"Done" << std::endl;
}


#ifdef _DEBUG
_CrtDumpMemoryLeaks();
#endif

    return EXIT_SUCCESS;
}

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
sf::Music Stop & Play does not play the sound & mem
« Reply #1 on: March 12, 2009, 08:21:11 am »
I'll look into it as soon as possible, thanks for your feedback.
Laurent Gomila - SFML developer

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
sf::Music Stop & Play does not play the sound & mem
« Reply #2 on: March 12, 2009, 07:39:47 pm »
Two things:
- Your first code works perfectly for me (Windows XP, latest revision of trunk)
- Apparently the leaks are from the stb_vorbis library, I'm going to contact its author :)
Laurent Gomila - SFML developer

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
sf::Music Stop & Play does not play the sound & mem
« Reply #3 on: March 12, 2009, 08:22:47 pm »
He sent me a fix for stb_vorbis (please note that he did it in 5 minutes :D), the leaks are now gone.
Laurent Gomila - SFML developer

AdrianM

  • Newbie
  • *
  • Posts: 43
    • View Profile
sf::Music Stop & Play does not play the sound & mem
« Reply #4 on: March 14, 2009, 10:07:06 pm »
Quote from: "Laurent"
He sent me a fix for stb_vorbis (please note that he did it in 5 minutes :D), the leaks are now gone.


Cool!

 

anything