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:
////////////////////////////////////////////////////////////
// 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?
////////////////////////////////////////////////////////////
// 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;
}