| View previous topic :: View next topic |
| Author |
Message |
pawbyrialsen Member
Joined: 01 Oct 2006 Posts: 5
|
Posted: 01/10/06 08:20 Post subject: Problems with LiveAudioPlayer and Async := True |
|
|
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
|
|
| Back to top |
|
 |
Kambiz Administrator

Joined: 07 Mar 2003 Posts: 1044 Location: Tehran, Iran
|
Posted: 01/10/06 16:22 Post subject: |
|
|
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 |
|
| Back to top |
|
 |
pawbyrialsen Member
Joined: 01 Oct 2006 Posts: 5
|
Posted: 01/10/06 18:04 Post subject: |
|
|
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.
| Description: |
|
 Download |
| Filename: |
LiveAudioDemo.zip |
| Filesize: |
5.9 KB |
| Downloaded: |
7 Time(s) |
|
|
| Back to top |
|
 |
Kambiz Administrator

Joined: 07 Mar 2003 Posts: 1044 Location: Tehran, Iran
|
Posted: 02/10/06 12:39 Post subject: |
|
|
I don't have BDS 2006, but checked your code out with BDS 2005 and Delphi 6, and everything worked as expected.
_________________ Kambiz |
|
| Back to top |
|
 |
pawbyrialsen Member
Joined: 01 Oct 2006 Posts: 5
|
Posted: 02/10/06 13:48 Post subject: |
|
|
Also if you hold ENTER button down for a minut or two (when Activate button is the one with focus)??
/Paw
|
|
| Back to top |
|
 |
Kambiz Administrator

Joined: 07 Mar 2003 Posts: 1044 Location: Tehran, Iran
|
Posted: 04/10/06 08:25 Post subject: |
|
|
Even in this case everything works fine.
Anyway, you have to prevent re-occurrence of the OnClick event.
_________________ Kambiz |
|
| Back to top |
|
 |
pawbyrialsen Member
Joined: 01 Oct 2006 Posts: 5
|
Posted: 12/10/06 19:55 Post subject: |
|
|
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: | 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/Development/microsoft.public.win32.programmer.mmedia/2004-03/0130.html
/Paw
|
|
| Back to top |
|
 |
Kambiz Administrator

Joined: 07 Mar 2003 Posts: 1044 Location: Tehran, Iran
|
Posted: 12/10/06 22:32 Post subject: |
|
|
Paw, thank you very much for this valuable information.
_________________ Kambiz |
|
| Back to top |
|
 |
pawbyrialsen Member
Joined: 01 Oct 2006 Posts: 5
|
Posted: 13/10/06 13:41 Post subject: |
|
|
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
|
|
| Back to top |
|
 |
Johnny_Bit Moderator
Joined: 15 Jun 2003 Posts: 274
|
Posted: 13/10/06 21:24 Post subject: |
|
|
| you should know answer b now: when he got the time
|
|
| Back to top |
|
 |
Kambiz Administrator

Joined: 07 Mar 2003 Posts: 1044 Location: Tehran, Iran
|
Posted: 18/10/06 16:43 Post subject: |
|
|
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 |
|
| Back to top |
|
 |
|