FORUM CLOSED, PLEASE REGISTER AT FORUM.SIO2INTERACTIVE.COM
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Stream sound

4 posters

Go down

Stream sound Empty Stream sound

Post  FlagellumDei Sat Mar 14, 2009 2:20 am

There is a problem with streaming sound (in a separate thread)? If the source is starved of audio data then it stops playing, and then it needs to be restarted.

FlagellumDei

Posts : 5
Join date : 2009-03-14

Back to top Go down

Stream sound Empty Re: Stream sound

Post  sio2interactive Sat Mar 14, 2009 4:52 pm

Can you please be more specific or simply send me a template project by email that reproduce the bug.

Tks!
sio2interactive
sio2interactive

Posts : 1526
Join date : 2008-08-26
Age : 44
Location : Shanghai

http://sio2interactive.com

Back to top Go down

Stream sound Empty Re: Stream sound

Post  FlagellumDei Tue Mar 17, 2009 10:49 am

I want to play a background music in the game which is updated in a separate thread. So I created a thread like this:

_SIO2thread = sio2ThreadInit();
sio2ThreadCreate(_SIO2thread, MusicUpdateThread, ( void * )g_pGame, SIO2_THREAD_PRIORITY_NORMAL);
sio2ThreadPlay(_SIO2thread);

Here's the thread function:

void MusicUpdateThread( void *_ptr )
{
CGame* pGame = (CGame*)_ptr;
SIO2sound* pSound = NULL;

pSound = pGame->GetGameMusic();
if (pSound) sio2SoundUpdateStream(pSound);
}

FlagellumDei

Posts : 5
Join date : 2009-03-14

Back to top Go down

Stream sound Empty Re: Stream sound

Post  FlagellumDei Tue Mar 17, 2009 11:06 am

And if I add this to the "void sio2SoundUpdateStream( SIO2sound *_SIO2sound )" function after the "if( !q )":

else
{
int iState;

// Check the status of the Source. If it is not playing, then playback was completed,
// or the Source was starved of audio data, and needs to be restarted.
alGetSourcei(_SIO2sound->sid, AL_SOURCE_STATE, &iState);
if (iState != AL_PLAYING && iState != AL_PAUSED)
{
// source was starved of audio data
sio2SoundPlay( _SIO2sound );
}
}

the state of the source will be AL_STOPPED. But now the last buffer is played again, before it continues.

FlagellumDei

Posts : 5
Join date : 2009-03-14

Back to top Go down

Stream sound Empty Re: Stream sound

Post  hazeleye Mon Mar 23, 2009 5:41 am

Hi,
I have simple problem when trying play backgrownd music. I use double buffering for sound, but hear only one....
Code:

void LoadSound (void)
{
   {
      SIO2stream *streamSound = NULL;
      streamSound = sio2StreamOpen("mozart_sym40_1.ogg", 1);
      if (streamSound)
      {
         SIO2soundbuffer *soundBuffer = sio2SoundBufferInit("music");
         sio2SoundBufferLoad(soundBuffer, streamSound);
         sio2SoundBufferGenId(soundBuffer, 1);
         
         music = sio2SoundInit("music");
         sio2SoundGenId(music, soundBuffer, SIO2_SOUND_STREAM|SIO2_SOUND_LOOP);
         sio2SoundBufferFree(soundBuffer);
      }
      sio2StreamClose(streamSound);
}
void templateRender( void )
{
...
static bool b = false;
   if (!b)
   {
      sio2SoundPlay(music);
      b = true;
   }
   sio2SoundUpdateState(music);
   if (music->state != SIO2_SOUND_PLAY)
   {
      sio2SoundUpdateStream(music);
   }
}
Can you help me?

hazeleye

Posts : 34
Join date : 2008-09-24

Back to top Go down

Stream sound Empty Re: Stream sound

Post  sio2interactive Mon Mar 23, 2009 5:44 am

sio2ResourceRender( level,
sio2->_SIO2window,
sio2->_SIO2camera,
SIO2_RENDER_SOLID_OBJECT | SIO2_RENDER_ALPHA_OBJECT | SIO2_UPDATE_SOUND_STREAM );
sio2interactive
sio2interactive

Posts : 1526
Join date : 2008-08-26
Age : 44
Location : Shanghai

http://sio2interactive.com

Back to top Go down

Stream sound Empty Re: Stream sound

Post  hazeleye Mon Mar 23, 2009 6:09 am

I change my LoadSound function and all working!
Thanks

hazeleye

Posts : 34
Join date : 2008-09-24

Back to top Go down

Stream sound Empty Re: Stream sound

Post  andreassilva Wed Apr 01, 2009 9:52 am

hazeleye wrote:I change my LoadSound function and all working!
Thanks

I'm using exactly the code you have above, but my sound just plays for a bit and then loops.
The same happens when I load the sound through Blender like on tutorial 15.

Can you or someone tell me what's happening please?

Thanks

andreassilva

Posts : 22
Join date : 2009-02-19

Back to top Go down

Stream sound Empty Re: Stream sound

Post  Sponsored content


Sponsored content


Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum