IDirectSoundBuffer::Play method with thread

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm using a thread that call a function where there is the
IDirectSoundBuffer::Play method inside. When I call this thread and than I
would to play a wav file the IDirectSoundBuffer::Play method return this
error:

DSERR_PRIOLEVELNEEDED

that in the help I can see it is:

DSERR_PRIOLEVELNEEDED
The caller does not have the priority level required for the function to
succeed.

The caller is the thread and I have used for this all the kinds of priority
levels available but the problem is always the same. I have changed the
SetCooperativeLevel priority too with all the combinations but nothing is
changed. I want to know if is possible to call the IDirectSoundBuffer::Play
method from a thread and if yes how is possible to do it with no errors?
 
did you specify a valid hWnd?
you have to use a valid window handle.

this snippet came from the documentation of SetCooperativeLevel:
HWND hWnd = GetForegroundWindow();
if (hWnd == NULL)
{
hWnd = GetDesktopWindow();
}

then set the priority level to at least DSSCL_PRIORITY
if setcooperativelevel should fail, what is the error code?

supplying a NULL ptr for the window handle was the problem for this guy:
http://www.gamedev.net/community/forums/topic.asp?topic_id=372315

kind regards,
Bruno.
 
Bruno van Dooren said:
did you specify a valid hWnd?
you have to use a valid window handle.

this snippet came from the documentation of SetCooperativeLevel:
HWND hWnd = GetForegroundWindow();
if (hWnd == NULL)
{
hWnd = GetDesktopWindow();
}

then set the priority level to at least DSSCL_PRIORITY
if setcooperativelevel should fail, what is the error code?

supplying a NULL ptr for the window handle was the problem for this guy:
http://www.gamedev.net/community/forums/topic.asp?topic_id=372315

kind regards,
Bruno.


problem fixed. Thank you very much.

Just another question about DirectSound. Why when a wav file is playing I
hear its sound and when the application is in icon state or not focused is
impossible to hear any sound??
 
When you create your sound buffer using CreateSoundBuffer, you have to
specify DSBCAPS_GLOBALBUFFER flag.
That will indicates that the application wants to continue playing its
buffers, even if it loses focus.

kind regards,
Bruno.
 
Bruno van Dooren said:
When you create your sound buffer using CreateSoundBuffer, you have to
specify DSBCAPS_GLOBALBUFFER flag.
That will indicates that the application wants to continue playing its
buffers, even if it loses focus.

DSBCAPS_GLOBALFOCUS is ok

Thank you
 
Back
Top