DELPHI AREA
MESSAGE BOARD
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   FavoritesFavorites   Watched TopicsWatched Topics     RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Problems with LiveAudioPlayer and Async := True

 
Post new topic   Reply to topic   printer-friendly view    DELPHI AREA Forum Index -> DELPHI AREA's Products
View previous topic :: View next topic  
Author Message
pawbyrialsen
Member


Joined: 01 Oct 2006
Posts: 5

PostPosted: 01/10/06 08:20    Post subject: Problems with LiveAudioPlayer and Async := True Reply with quote

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
View user's profile Send private message
Kambiz
Administrator


Joined: 07 Mar 2003
Posts: 1044
Location: Tehran, Iran

PostPosted: 01/10/06 16:22    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
pawbyrialsen
Member


Joined: 01 Oct 2006
Posts: 5

PostPosted: 01/10/06 18:04    Post subject: Reply with quote

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.



LiveAudioDemo.zip
 Description:

Download
 Filename:  LiveAudioDemo.zip
 Filesize:  5.9 KB
 Downloaded:  7 Time(s)

Back to top
View user's profile Send private message
Kambiz
Administrator


Joined: 07 Mar 2003
Posts: 1044
Location: Tehran, Iran

PostPosted: 02/10/06 12:39    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
pawbyrialsen
Member


Joined: 01 Oct 2006
Posts: 5

PostPosted: 02/10/06 13:48    Post subject: Reply with quote

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

/Paw
Back to top
View user's profile Send private message
Kambiz
Administrator


Joined: 07 Mar 2003
Posts: 1044
Location: Tehran, Iran

PostPosted: 04/10/06 08:25    Post subject: Reply with quote

Even in this case everything works fine.

Anyway, you have to prevent re-occurrence of the OnClick event.

_________________
Kambiz
Back to top
View user's profile Send private message Send e-mail Visit poster's website
pawbyrialsen
Member


Joined: 01 Oct 2006
Posts: 5

PostPosted: 12/10/06 19:55    Post subject: Reply with quote

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
Code:
Back to top
View user's profile Send private message
Kambiz
Administrator


Joined: 07 Mar 2003
Posts: 1044
Location: Tehran, Iran

PostPosted: 12/10/06 22:32    Post subject: Reply with quote

Paw, thank you very much for this valuable information.
_________________
Kambiz
Back to top
View user's profile Send private message Send e-mail Visit poster's website
pawbyrialsen
Member


Joined: 01 Oct 2006
Posts: 5

PostPosted: 13/10/06 13:41    Post subject: Reply with quote

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
View user's profile Send private message
Johnny_Bit
Moderator


Joined: 15 Jun 2003
Posts: 274

PostPosted: 13/10/06 21:24    Post subject: Reply with quote

you should know answer b now: when he got the time
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Kambiz
Administrator


Joined: 07 Mar 2003
Posts: 1044
Location: Tehran, Iran

PostPosted: 18/10/06 16:43    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    DELPHI AREA Forum Index -> DELPHI AREA's Products All times are GMT
Page 1 of 1

Add to favorites

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group