game engine gaming delta3d
p-51 open source GNU Lesser General Public License
Fedora Surface Tactics Visualization Plane Guard ChrAVE
Chromakeyed Augmented Virtual Environment CAVE Automatic Virtual Environment National Geospatial-Intelligence Agency Terrian Forward Observer PC Simulator FOPCSIM Shipboard Firefighting Trainer
backed by the U.S. military sourceforge eric johnson I/ITSEC Interservice Industry Training Simulation and Education Conference
Delta3D - Open source gaming & simulation engine
      Welcome to Delta3D | Login 
Sunday, May 19 2013 @ 08:46 AM EDT 
MOVES Institute Naval Postgraduate School Naval Education and Training Command
  
IITSEC


AND     OR
 

 
 Home »  SimCore Support »  slot issue in dtAudio::AudioMamanger::SoundObj
     Prev TopicNext Topic          Printable Version
slot issue in dtAudio::AudioMamanger::SoundObj Views: 2242
 Monday, March 05 2007 @ 05:35 AM EST

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

 Quote   

 
 Monday, March 05 2007 @ 05:02 PM EST

Good catch. If you'd like to submit a patch for this, I'd be more than willing to merge it in!

Thanks,
Erik

 Quote   

 
 Tuesday, March 06 2007 @ 05:44 AM EST

Hi,
th current patch I've done locally is just to add
in audiomanager.cpp:1661

   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

 Quote   

 
 Tuesday, March 06 2007 @ 12:05 PM EST

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
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

 Quote   

 
 Wednesday, March 07 2007 @ 06:18 AM EST

Hi,
good catch, so the following code will be the best
(audiomanager.cpp:1665)
   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 ! Big Grin

Max

 Quote   

 
 Wednesday, March 28 2007 @ 02:25 PM EST

Sorry for the slow reply. I just checked this fix in; it's not 100% robust, but its better than it was. Smile

Thanks,
Erik

 Quote   

 
 Thursday, March 29 2007 @ 04:08 AM EST

As nobody modify the initialized state, I think it should work. Anyway, thanks !

Maxime

 Quote   

 

 


Delta3D is released under the GNU Lesser General Public License (LGPL) | Powered by GeekLog