473,378 Members | 1,207 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

IDirectSoundBuffer::Play method with thread

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?
Jan 30 '06 #1
4 3721
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/for...opic_id=372315

kind regards,
Bruno.

"Milkas" <Mi****@discussions.microsoft.com> wrote in message
news:94**********************************@microsof t.com...
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?

Jan 30 '06 #2


"Bruno van Dooren" wrote:
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/for...opic_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??
Jan 31 '06 #3
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.
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??

Jan 31 '06 #4


"Bruno van Dooren" wrote:
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
Feb 1 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Michele Petrazzo | last post by:
I have a wxpython application (the main program) and a lot of external modules (import mymodule) that use always 2 thread (one is my application and one is twisted with new threadselectreactor)....
2
by: Steve | last post by:
Is a static method that uses local variables thread safe (eg in a web service) In the following code assuming GetRandomValue() and DoSomethingElse() are thread safe, is the static method thread...
16
by: Alvin Bruney | last post by:
I'm observing that a sleeping thread changes to stopped after a while. Is that accepted framework behavior for web applications? My thread basically does some work, and sleeps for 60 minutes...
6
by: GG | last post by:
Is this public static method thread safe. //Receives a file name as a parameter //and returns the contents of that file as a string public static string FileToStr(string fileName) { FileStream...
0
by: Dmitri Shvetsov | last post by:
Hi, Does anybody know how to write to richTextBox from thread? All variables using by thread should be static, including the thread method (body). The richTextBox control is used on a main...
1
by: Oleg Ogurok | last post by:
Hi all, I've just realized that static data are not thread safe because they are shared by all users of the ASP.NET application. What if a static method is passed an object variable? Do I still...
11
by: dee | last post by:
OleDbCommand class like many .NET classes has the following description in its help file: "Thread Safety Any public static (Shared in Visual Basic) members of this type are safe for...
2
by: Aaron Cutlip | last post by:
I have been looking all over and have seen many possible ways to create a Syncronized Shared Function in VB.NET, but I would like some advice that will make my life easier. Given the following...
22
by: Morpheus | last post by:
Hi, I have been coding in Windows for many years so have a mindset to it, so forgive any stupid questions. Is it possible to create a multithread application in C++ that is portable...
6
Xx r3negade
by: Xx r3negade | last post by:
Consider this: I have the class foo, with the public method thread(), and the private method bar() In the thread() method, I would like to create a new thread, using pthread_create(), that...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.