delta3d

 Forum Index >  > SimCore Support New Topic Post Reply
 slot issue in dtAudio::AudioMamanger::SoundObj
   
max
 03/05/2007 10:35AM (Read 2375 times)  
++---
Junior

Status: offline


Registered: 03/23/2006
Posts: 26
Hi,
The mecanism of slot registration for the dtAudio::AudioManager::SoundObj seems to be not safe that can provoque big performance issue.

Each sound is "registered" (via addSender) to the AudioManager and dtCore system once they've been played and reregsitered when they've been stop.

The problem is if you play the same sound many times in the same frame, it will be registered many times but deregistered only once.

This will cause the sender list to grow up and slow down the performance.

I "fixed" the problem on my side by filtering my playing event so that I play a sound only once per frame but it s not a solution.

A better solution would be to had a boolean in the SoundObj to know if it has been already registered or not and avoid multiple registration.

Max

 
Profile Email
 Quote
ErikJohnson
 03/05/2007 10:02PM  
MMMMM
Moderator

Status: offline


Registered: 11/08/2004
Posts: 2851
Good catch. If you'd like to submit a patch for this, I'd be more than willing to merge it in!

Thanks,
Erik

 
Profile Email
 Quote
max
 03/06/2007 10:44AM  
++---
Junior

Status: offline


Registered: 03/23/2006
Posts: 26
Hi,
th current patch I've done locally is just to add
in audiomanager.cpp:1661

PHP Formatted Code

   snd->RemoveSender( this );
   snd->RemoveSender( &dtCore::System::GetInstance() );

   snd->AddSender( this );
   snd->AddSender( &dtCore::System::GetInstance() );
 

This avoid to modifiy the header (so that the patched lib stay compatible and I dont need to rebuild my old executable).

Normaly it works, and don't slow as the performance as sender list should be empty or just contains the elements to delete.

If you prefer a "cleaner" version, let me know and I'll do it.

Max

 
Profile Email
 Quote
ErikJohnson
 03/06/2007 05:05PM  
MMMMM
Moderator

Status: offline


Registered: 11/08/2004
Posts: 2851
Ok, I understand now.

Can we put the AddSender() code into a section of AudioManager.PlaySound() that will only happen once, regardless of how many times the sound is played? Perhaps like in
PHP Formatted Code
if (!snd->IsInitialized() )
{...
or something.

I don't have time to test this theory out at the moment. Perhaps you can find a better place to AddSender() so we can ensure that it only happens once?

Thanks,
Erik

 
Profile Email
 Quote
max
 03/07/2007 11:18AM  
++---
Junior

Status: offline


Registered: 03/23/2006
Posts: 26
Hi,
good catch, so the following code will be the best
(audiomanager.cpp:1665)
PHP Formatted Code

   if(source_is_new)
   {
       snd->AddSender( this );
       snd->AddSender( &dtCore::System::GetInstance() );
       mPlayQueue.push( snd->Source() );
   }
 

And it avoids to push the sound twice in the queue.
But it only works because the Initialized state would be reseted in the same time the senders were removed (in FreeSound and PostFrame) ...
But it works !

Max

 
Profile Email
 Quote
ErikJohnson
 03/28/2007 07:25PM  
MMMMM
Moderator

Status: offline


Registered: 11/08/2004
Posts: 2851
Sorry for the slow reply. I just checked this fix in; it's not 100% robust, but its better than it was.

Thanks,
Erik

 
Profile Email
 Quote
max
 03/29/2007 09:08AM  
++---
Junior

Status: offline


Registered: 03/23/2006
Posts: 26
As nobody modify the initialized state, I think it should work. Anyway, thanks !

Maxime

 
Profile Email
 Quote
Content generated in: 1.65 seconds
New Topic Post Reply

Normal Topic Normal Topic
Sticky Topic Sticky Topic
Locked Topic Locked Topic
New Post New Post
Sticky Topic W/ New Post Sticky Topic W/ New Post
Locked Topic W/ New Post Locked Topic W/ New Post
View Anonymous Posts 
Anonymous users can post 
Filtered HTML Allowed 
Censored Content 

Twitter

User Functions





Don't have an account yet? Sign up as a New User

Lost your password?