Problems with LiveAudioPlayer and Async := True

Please post bug reports, feature requests, or any question regarding the DELPHI AREA products here.

Problems with LiveAudioPlayer and Async := True

Postby pawbyrialsen » October 1st, 2006, 8:20 am

Hi

Im using LiveAudioPlayer in Delphi 2006 to build an "OnlinePlayer" (Datamodule with the liveAudioPlayer component added at designtime). It is important to me that the main thread isn't stalled by the Online Player thus property Async is set to True, instead of implementing the entire Online Player in my own thread.

The problem is that when I do code like this from my mainthread:

OnlinePlayer.LiveAudioPlayer.Active := True

Then i except to get the "OnDataPtr" event afterwards. This happens most of the times but not always. Sporadically I dont get the "OnDataPtr" event at all, and this is ofcourse a very bad situation for me.

If nessesary I can provide a sample application that demonstrates the problem, but I guess that someone must have seen this happens too.

Finally please notice that setting Async := False, I always get the "OnDataPtr" event.

/Paw
pawbyrialsen
Active Member
Active Member
 
Posts: 5
Joined: October 1st, 2006, 7:55 am

Postby Kambiz » October 1st, 2006, 4:22 pm

Providing a sample application will help me a lot to figure out and resolve the problem.

By the way, before sending me the code, verify your event handlers are thread safe.

Thank you.
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2408
Joined: March 7th, 2003, 7:10 pm

Postby pawbyrialsen » October 1st, 2006, 6:04 pm

Hi,

Okay, here goes a very simple example. Just start the application and press Activate until you detect an situation where OnData doesn't occur.

Your might have to "activate" a few times:)

/Paw

PS: After posting this message I tried running the .exe directly in Windows (Delphi closed). It seemed like OnData always occurs then. Hope this gives you an clue to what might be wrong.
Attachments
LiveAudioDemo.zip
(5.9 KiB) Downloaded 407 times
pawbyrialsen
Active Member
Active Member
 
Posts: 5
Joined: October 1st, 2006, 7:55 am

Postby Kambiz » October 2nd, 2006, 12:39 pm

I don't have BDS 2006, but checked your code out with BDS 2005 and Delphi 6, and everything worked as expected.
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2408
Joined: March 7th, 2003, 7:10 pm

Postby pawbyrialsen » October 2nd, 2006, 1:48 pm

Also if you hold ENTER button down for a minut or two (when Activate button is the one with focus)??

/Paw
pawbyrialsen
Active Member
Active Member
 
Posts: 5
Joined: October 1st, 2006, 7:55 am

Postby Kambiz » October 4th, 2006, 8:25 am

Even in this case everything works fine.

Anyway, you have to prevent re-occurrence of the OnClick event.
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2408
Joined: March 7th, 2003, 7:10 pm

Postby pawbyrialsen » October 12th, 2006, 7:55 pm

Hi,

It's been a while but I have done som testing parallel with my other tasks, and finally i succeded to find the problem and also made a temporary solution that fixes the problem for now.

The problem is inside the "InternalOpen" method in TWaveAudioOut class. To be more precise the problem is after you call CreateCallback. You have to guarantee that the thread is actually running (execute is started) before you call WaveOutOpen, Otherwise Windows messages can be lost. And thats excatly what happened with my developer machine in D2006. I have also been able to recreate the problem in D2005 on another machine, but on my D2006 I can recreate it all the time.

So my best advice is to make an Event (CreateEvent) and then signal this event from TWaveThread.Execute. Then you will be able to call WaitForSingleObject between the call to CreateCallback and WaveOutOpen. (I have set Timeout to 1000 ms). My execute looks like this:

Code: Select all
procedure TWaveThread.Execute;
var
  MSG: TMSG;
begin
  // Initiate thread messageque and signal thread is running and ready to recieve messages
  PeekMessage(MSG, 0, 0, 0, PM_NOREMOVE);
  WaveAudioIO.SignalEvent;
  while GetMessage(MSG, 0, 0, 0) do
    WaveAudioIO.ProcessWaveMessage(MSG.Message, PWaveHdr(MSG.lParam));
  WaveAudioIO.ThreadHandle := 0;
end;


Hopefully you see what I mean and maybee you will be able to make an update to the package.

By the way, when looking at the web searching for hints to my problem I found the folowing article. Thought it might be of interrest to you:)

http://www.tech-archive.net/Archive/Dev ... /0130.html

/Paw
Code: Select all
pawbyrialsen
Active Member
Active Member
 
Posts: 5
Joined: October 1st, 2006, 7:55 am

Postby Kambiz » October 12th, 2006, 10:32 pm

Paw, thank you very much for this valuable information.
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2408
Joined: March 7th, 2003, 7:10 pm

Postby pawbyrialsen » October 13th, 2006, 1:41 pm

Have you any idea if a new version is to expect in the near future or do you prefer to upgrade in larger bundles?

/Paw
pawbyrialsen
Active Member
Active Member
 
Posts: 5
Joined: October 1st, 2006, 7:55 am

Postby Johnny_Bit » October 13th, 2006, 9:24 pm

you should know answer b now: when he got the time
Johnny_Bit
VIP Member
VIP Member
 
Posts: 455
Joined: June 15th, 2003, 9:56 am

Postby Kambiz » October 18th, 2006, 4:43 pm

Johnny_Bit is absolutely right.

Hopefully in the next few weeks I can find time to release the updates for WA Package and SB Pro component.
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2408
Joined: March 7th, 2003, 7:10 pm


Return to DELPHI AREA Products

Who is online

Users browsing this forum: No registered users and 2 guests

cron