Playing, pausing and stopping streams

I' m trying to add looping sound streams to my game, basically one in the game' menu and one

in the game. I use the game state system and I have one state for the menu and one for the

game. So what I actual want to do is play the looping stream when a state is activated and

stop or pause the looping stream of the deactivated state.

Now everything works fine when I play the sound and stop or pause it, but I can not play the sound

again when a state is re-activated.



Do I have re-create a stream after stopping or pausing? Don't I just have to use

SoundSystem.play(streamName) again?



Here is an exception I got after pausing and attempted to play the sound again.


Exception in thread "Thread-7" org.lwjgl.openal.OpenALException: OpenAL error: Invalid Value (40963)
   at org.lwjgl.openal.Util.checkALError(Util.java:56)
   at org.lwjgl.openal.AL10.alBufferData(AL10.java:1044)
   at com.jmex.sound.openAL.objects.util.StreamPlayer$Player.stream(StreamPlayer.java:432)
   at com.jmex.sound.openAL.objects.util.StreamPlayer$Player.play(StreamPlayer.java:458)
   at com.jmex.sound.openAL.objects.util.StreamPlayer$Player.run(StreamPlayer.java:509)
   at java.lang.Thread.run(Thread.java:595)



Can anyone please help me?

I ended up going ahead and re-creating the stream myself because I was having the same problem.



darkfrog

So each time you stop or pause the stream, you destroy and re-create it in order to play it again?

unfortunately, yes. :o



darkfrog

So either there's a bug regarding stop and pause methods or we're doing

something wrong.



Can Arman suggest a better solution or check if there's a bug?

I vote for us doing something wrong.  :roll:



darkfrog

Searching through the methods of SoundSystem there's no method for destroying/cleaning

a stream or all streams. Shouldn't there be methods such as:



   /**
     * Clean all the streams.
     * Note that after this the registered streams will not play again.
     */
     void cleanStreams()
   /**
     * Cleans the stream with the specified <code>streamName</code>.
     *  Note that after this the specified stream will not play again.
     */
     void cleanStream(int streamName)


as well as


   /**
     * Cleans the sample with the specified <code>sampleName</code>.
     *  Note that after this the specified sample will not play again.
     */
    void cleanSample(int sampleName)

   /**
     * Cleans the node with the specified <code>nodeName</code> and
     * and all contained samples of the node.
     *  Note that after this the specified node and contained samples will not play again.
     */
    void cleanNode(int nodeName)

   /**
     * Clean all the nodes and their contained samples.
     * Note that after this the nodes and their registered streams will not play again.
     */
    void cleanNodes()


   /**
     * Clean all the nodes, samples and streams.
     * Note that after this the nodes, registered samples and streams will not play again.
     */
    void cleanAll()

If you don't mind I would like to add another note…



From a best design perpesctive , wouldn't it be better to abstract the common

methods from both SoundSystem classes(fmod and OpenAL) to a single abstract

class called SoundSystem and provide implementation specific details in extending

conrete classes? The same way the DisplaySystem is designed in order to allow for

easily addition of Sound renderers in the future and abstraction from the specifiic

sound renderer implementation. Another benefit is that the user can choose

at runtime which SoundSystem to use with little or less hassle from the programmer's side.



Any thoughts?

the soundsystem needs a good run through…don't seem like it's very much tested(i guess people add sound late in their projects, and most often don't get all the way there) :wink:

Guessing from other posts and source doc, the only active developer for the SoundSystem

is Arman. Right? Anyway, even for one person I don't think it would take more than 2 or

3 hours to add the forementioned methods and improve the design, provided he agrees

with them and has the spare time to do so.

Since I don't see Arman too often, isn't there any of the other developers interested in

designing/implementing these simple modifications/feature requests?

how about you?  }:-@

I would be more than happy to do it , but here are a few reasons why I can't do it right now:


  1. I'm on a REALLY TIGHT schedule. Specifically I have ten days left in order to decide If I will withdraw

        from my Uni. project(a quake2 style 3D FPS game) and still havent' finished AI and many other bits and pieces.
  2. I'm not familiar with Sound programming, afterall this is my first project, hence it would probably take me two

        or three times(to say the least) more than the time it would take for an experienced developer(e.g. Arman)

        and probably have two or three times more bugs.
  3. I'm not a jME developer(This ofcourse deosn't really matter, since I could just post the code and wait for acknowledgement)



    Anyway, I want to help and I personally think that the biggest pro of jME is its community, but the first two reasons

    really halt me from contributing and restrict me to requesting ://. Although I might do so in the future.



    Enough with me! You get the picture…

Hi, I am sorry for the moment I am also on a tight schedule. That means that I can not take time to look at the code.

First I am freelancer, now, and give my time to earn money. And I have something more personal to learn: My private pilot license theory…

If someone could look at these problems I would be great.

See you, I hope, soon.

Arman,



Good luck! I'm a pilot also (although it's been quite a while since I've gotten a chance to fly) and there's just nothing quite like it… :slight_smile:



darkfrog