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

Author Topic: [SOLVED] Music doesn't Play after the first Stop.  (Read 7168 times)

0 Members and 1 Guest are viewing this topic.

nitram_cero

  • Full Member
  • ***
  • Posts: 166
    • View Profile
[SOLVED] Music doesn't Play after the first Stop.
« on: May 24, 2009, 05:29:25 am »
Well, that.

Press space. It should toggle between music playing and off. But it wont work (Works with Sounds thou).

System: Windows XP SP2.
SFML: SVN trunk

Code: [Select]

#include <SFML/Graphics.hpp>
#include <SFML/Audio.hpp>
#include <algorithm>
#include <sstream>
using namespace sf;
using namespace std;

int main(int argc, char **argv)
{
RenderWindow *theWindow=new RenderWindow(VideoMode(800, 600, 32), "Test");

Music music;
music.OpenFromFile("drumloop1.wav");
music.SetLoop(true);

Event ev;
View view=theWindow->GetView();
while(theWindow->IsOpened()) {
while(theWindow->GetEvent(ev)) {
if(ev.Type==Event::Closed) {
theWindow->Close();
}
else if(ev.Type==Event::KeyPressed && ev.Key.Code==Key::Space) {
if(music.GetStatus()==Music::Stopped)
music.Play();
else
music.Stop();
}
}
theWindow->Clear();
theWindow->Display();
}



return 0;
}

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
[SOLVED] Music doesn't Play after the first Stop.
« Reply #1 on: May 24, 2009, 01:03:12 pm »
Quote
SFML: SVN trunk

I'm surprised because I fixed this bug some time ago. I tested your code to make sure, and it works for me with the latest sources in trunk. Are you sure you're not still using an old version?
Laurent Gomila - SFML developer

nitram_cero

  • Full Member
  • ***
  • Posts: 166
    • View Profile
[SOLVED] Music doesn't Play after the first Stop.
« Reply #2 on: May 24, 2009, 02:00:25 pm »
I'll check, but I'm talking about 1.4 trunk. That branch is now abandoned?

I'm using Revision 1095. I'll try SFML2

Thanks
-Martín

nitram_cero

  • Full Member
  • ***
  • Posts: 166
    • View Profile
[SOLVED] Music doesn't Play after the first Stop.
« Reply #3 on: May 24, 2009, 02:37:48 pm »
It keeps happening in SFML2.

Debug, release, DLL, static. SetLoop(true), SetLoop(false).
Even rebooted (just in case, you know)

Nothing...

I'm using the extlibs from SVN, maybe is that?

I've searched in the audio code but I don't seem to find anything out of normal. Everything seems in place.

This sucks  :(  because I'll never make it to the Mini Ludum Dare #9 this way.
I'll have to try older versions.


EDIT: one thing that seems to "solve" it is destroying the music object and recreating it. So maybe it has to do with an improper un-resettable state?

I mean instead of

Code: [Select]
Music M;
M.OpenFromFile("drumloop1.wav");

M.Play();

M.Stop();


Code: [Select]
Music *M=new Music;   //each play time
M->OpenFromFile("music.wav");   //each play time
M->Play();

M->Stop();
delete M;

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
[SOLVED] Music doesn't Play after the first Stop.
« Reply #4 on: May 24, 2009, 03:04:20 pm »
Quote
I'll check, but I'm talking about 1.4 trunk. That branch is now abandoned?

The trunk is never abandoned, it is the main branch ;)
I was talking about this one too.

You can try debugging SFML and see why the music doesn't restart.
Laurent Gomila - SFML developer

nitram_cero

  • Full Member
  • ***
  • Posts: 166
    • View Profile
[SOLVED] Music doesn't Play after the first Stop.
« Reply #5 on: May 24, 2009, 03:29:13 pm »
Yes I did, but I just can't find the bug.

The thing I found is that if I free/create a Music object it works (edited in my prev. post)

I should check the changes in states.

The music thread is created and loops OK each time (myIsStreaming), the buffers get queued correctly, but the sounds don't seem to play.
I'm thinking this has something to do with the file handling.

EDIT: Only difference so far is mySamples being all zeroed.

nitram_cero

  • Full Member
  • ***
  • Posts: 166
    • View Profile
[SOLVED] Music doesn't Play after the first Stop.
« Reply #6 on: June 05, 2009, 10:09:24 pm »
Any news on this? I worked around this by deleting and recreating my Music object to get by.

I don't seem to find anything that's failing with this.

Is there a way to dump stats on OpenAL? I'm just not that into OpenAL to know... because I think it has something to do with the lib and not SFML.

Something I haven't tried but gives me a hunch is that setting-to-null of the source's buffer (when stopping) maybe is setting the source as single-buffer instead of streaming (due to a bad implementation of OpenAL).

Regards
-Martín

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
[SOLVED] Music doesn't Play after the first Stop.
« Reply #7 on: June 05, 2009, 10:17:40 pm »
No, sorry. It's working for me and I can't see any obvious bug in the code.

Your only solution is to try again to debug the code yourself :(
Laurent Gomila - SFML developer

nitram_cero

  • Full Member
  • ***
  • Posts: 166
    • View Profile
[SOLVED] Music doesn't Play after the first Stop.
« Reply #8 on: June 08, 2009, 06:36:50 pm »
I found the problem. Me :D

I thought that (as everything else) the dlls got loaded from the project directory, not the executable one.
So the DLL loaded was one from my system32 folder, which probably sucks.

Putting the dll in the Debug folder did the trick.


EDIT: I'm using MSVC++ Express 2008, just in case anyone falls into this post with the same problem.

Problem solved, sorry  :oops:

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
[SOLVED] Music doesn't Play after the first Stop.
« Reply #9 on: June 08, 2009, 07:00:39 pm »
:D
Laurent Gomila - SFML developer