[Openal-devel] Trouble on AL_PAUSED souces (Win32HW)

dpeacock at creativelabs.com dpeacock at creativelabs.com
Mon Nov 28 12:18:44 PST 2005




Hi,

I just checked some code into CVS that contains a possible fix for this
issue.   The code that handles queuing buffers on a Source was only
checking for a current status of 'Playing' rather than 'Playing' or
'Paused'.   I couldn't reproduce the problem here with my own test
application - but I think the bug is more likely to show up when smaller
buffers are being queued.

Dan

Notice
The information in this message is confidential and may be legally
privileged.  It is intended solely for the addressee.  Access to this
message by anyone else is unauthorized.  If you are not the intended
recipient,  any disclosure,  copying or distribution of the message,  or
any action taken by you in reliance on it,  is prohibited and may be
unlawful.  If you have received this message in error,  please delete it
and contact the sender immediately.  Thank you.



                                                                           
             rage2050                                                      
             <rage2050 at mail.go                                             
             o.ne.jp>                                                   To 
             Sent by:                  openal-devel at opensource.creative.co 
             openal-devel-admi         m                                   
             n at opensource.crea                                          cc 
             tive.com                                                      
                                                                   Subject 
                                       [Openal-devel] Trouble on AL_PAUSED 
             11/23/2005 12:40          souces (Win32HW)                    
             AM                                                            
                                                                           
                                                                           
                                                                           
                                                                           
                                                                           




I'm using OpenAL32 Wiwdows "Generic Hardware" implementation.
I found something strange about AL_PAUSED sources.

- alSourceQueueBuffers() should be legal on a source in any state,
  including AL_PAUSED.
  I queued some buffers to a AL_PAUSED source, it didn't work.
- AL_LOOPING can be changed on a source in any state,
  including AL_PAUSED.
  I played and paused a source, then set AL_LOOPING to AL_TRUE,
  and again alSourcePlayed. I found the source was not looping.

I've tried adding (ALSource->state == AL_PAUSED) to
ALc.c/UpdateSource(), but it didn't work.




//---------------------------------------------------------------------------

#include <stdio.h>
#include <windows.h>
#pragma hdrstop

#include <AL/al.h>
#include <AL/alc.h>
#include <AL/alut.h>

// static link with OpenAL32.c
BOOL APIENTRY DllMain(HANDLE hModule,DWORD ul_reason_for_call,LPVOID
lpReserved);

ALuint source;
ALuint buf1, buf2, buf3;

static void IntroLoopRelease();
static void ClearQue(ALuint source);


//---------------------------------------------------------------------------

#pragma argsused
int main(int argc, char* argv[])
{
  // if you are DLLing with openal32.dll, remove this line
  DllMain( NULL, DLL_PROCESS_ATTACH, 0 );

  alutInit(&argc, argv);
  alGenSources( 1, &source );
  buf1 = alutCreateBufferWaveform(ALUT_WAVEFORM_SINE, 262, 0, 0.2f);
  buf2 = alutCreateBufferWaveform(ALUT_WAVEFORM_SINE, 330, 0, 0.4f);
  buf3 = alutCreateBufferWaveform(ALUT_WAVEFORM_SINE, 392, 0, 0.2f);


  //---------------------------------------------
  // queing to PLAYING source works fine
  //---------------------------------------------
  printf("alSourceQueueBuffers to PLAYING source\n");
  alSourceQueueBuffers( source, 1, &buf1 );
  alSourcePlay( source );
  alutMicroSleep(100*1000);
  alSourceQueueBuffers( source, 1, &buf2 );
  alSourceQueueBuffers( source, 1, &buf3 );
  alutMicroSleep(1000*1000);
  alSourceStop(source);
  ClearQue(source);

  //---------------------------------------------
  // queing to PAUSED source has trouble
  //---------------------------------------------
  printf("alSourceQueueBuffers to PAUSED source\n");
  alSourceQueueBuffers( source, 1, &buf1 );
  alSourcePlay( source );
  alutMicroSleep(100*1000);

  alSourcePause( source );
  printf("pause\n");
  alutMicroSleep(100*1000);

  alSourceQueueBuffers( source, 1, &buf2 );
  alSourceQueueBuffers( source, 1, &buf3 );
  printf("play\n");
  alSourcePlay( source );
  alutMicroSleep(1000*1000);

  alSourceStop(source);
  ClearQue(source);

  alutMicroSleep(500*1000);

  //---------------------------------------------
  // LOOP=ON to PLAYING source works fine
  //---------------------------------------------
  printf("LOOP to PLAYING source\n");
  alSourceQueueBuffers( source, 1, &buf1 );
  alSourcePlay( source );
  alutMicroSleep(100*1000);
  alSourcei( source, AL_LOOPING, AL_TRUE );
  alutMicroSleep(1000*1000);
  alSourceStop( source );
  alSourcei( source, AL_LOOPING, AL_FALSE );
  alSourceStop(source);
  ClearQue(source);
  alutMicroSleep(500*1000);

  //---------------------------------------------
  // LOOP=ON to PAUSED source has trouble
  //---------------------------------------------
  printf("LOOP to PAULED source\n");
  alSourceQueueBuffers( source, 1, &buf1 );
  alSourcePlay( source );
  alutMicroSleep(100*1000);
  printf("pause\n");
  alSourcePause( source );
  alutMicroSleep(100*1000);
  alSourcei( source, AL_LOOPING, AL_TRUE );
  alSourcePlay( source );
  alutMicroSleep(1000*1000);
  alSourcei( source, AL_LOOPING, AL_FALSE );
  alSourceStop(source);
  ClearQue(source);
  alutMicroSleep(500*1000);


  //---------------------------------------------
  // adding (ALSource->state == AL_PAUSED) to ALc.c/UpdateSource()
  // is not fine at such case.
  //---------------------------------------------
  IntroLoopRelease();

  //---------------------------------------------
  alDeleteBuffers( 1, &buf1 );
  alDeleteBuffers( 1, &buf2 );
  alDeleteBuffers( 1, &buf3 );
  alDeleteSources( 1, &source );
  alutExit();

  printf("end> "); getchar();
  return 0;
}


//---------------------------------------------------------------------------

static void IntroLoopRelease()
{
  // que buf1(Intro) and buf2(Loop)
  alSourceQueueBuffers( source, 1, &buf1 );
  alSourceQueueBuffers( source, 1, &buf2 );
  alSourcei(source, AL_LOOPING, 0);
  alSourcePlay(source);
  // wait Intro processed
  while (1)
  {
    alutMicroSleep(10*1000);
    ALint proc;
    alGetSourcei( source, AL_BUFFERS_PROCESSED, &proc );
    if (proc>0)
      break;
  }
  printf("unque Intro. start looping buf2\n");
  ClearQue(source);
  alSourcei(source, AL_LOOPING, 1);
  alutMicroSleep(1000*1000);

  printf("pause on\n");
  alSourcePause(source);
  alutMicroSleep(100*1000);

  printf("go RELEASE\n");
  alSourceQueueBuffers( source, 1, &buf3 );
  alSourcei(source, AL_LOOPING, 0);
  printf("pause off (play)\n");
  alSourcePlay(source);
  alutMicroSleep(2000*1000);

  alSourceStop(source);
  ClearQue(source);
}


//---------------------------------------------------------------------------

static void ClearQue(ALuint source)
{
  ALint proc;
  alGetSourcei( source, AL_BUFFERS_PROCESSED, &proc );
  for (ALint i=0; i<proc; i++)
  {
    ALuint unque;
    alSourceUnqueueBuffers( source, 1, &unque );
  }
  alSourcei(source, AL_BUFFER, 0);
  printf("from Source%08X unqued %d buffers\n", source, proc);
}
//---------------------------------------------------------------------------


/** @name  rage2050
    @email rage2050 at mail.goo.ne.jp
    @url   http://hp.vector.co.jp/authors/VA024832/
*/
_______________________________________________
openal-devel mailing list
openal-devel at opensource.creative.com
http://opensource.creative.com/mailman/listinfo/openal-devel

ForwardSourceID:NT0002A856




More information about the Openal-devel mailing list