Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
fmodaudio [2019/08/13 08:31] – [Add a FadePoint] adminfmodaudio [2020/01/09 14:20] – [Remarks] admin
Line 189: Line 189:
  
 procedure TForm1.FormShow(Sender: TObject); procedure TForm1.FormShow(Sender: TObject);
-var LSound : PGorillaFMODSound;+var LSound : IGorillaFMODSound;
 begin begin
   {...}   {...}
   LSound := LFMOD.LoadSoundFromFile('drumloop.wav');   LSound := LFMOD.LoadSoundFromFile('drumloop.wav');
-  LSound^.Mode := FMOD_LOOP_NORMAL; +  LSound.Mode := FMOD_LOOP_NORMAL; 
 end; end;
 </file> </file>
Line 209: Line 209:
 Next step: [[assetsmanager|AssetsManager]] Next step: [[assetsmanager|AssetsManager]]
  
 +===== Remarks =====
 +It is not allowed to release FMOD interfaces when the TGorillaFMODAudioManager component, especially the IGorillaFMODSystem interface inside of it, is already destroyed.
 +In this case you will receive an AccessViolation, because FMOD can not destroy the internal handle anymore.
 +
 +**WRONG:**
 +<file pascal>
 +var LFMOD : TGorillaFMODAudioManager;
 +    LSound : IGorillaFMODSound;
 +    
 +[...]
 +
 +LFMOD := TGorillaFMODAudioManager.Create(nil);
 +try
 +  LSound := LFMOD.LoadSoundFromFile(Common_MediaPathRaw('drumloop.wav'));
 +finally
 +  FreeAndNil(LFMOD);
 +  LSound := nil; // <<< WRONG!
 +end;
 +</file>
 +
 +**CORRECT:**
 +<file pascal>
 +var LFMOD : TGorillaFMODAudioManager;
 +    LSound : IGorillaFMODSound;
 +    
 +[...]
 +
 +LFMOD := TGorillaFMODAudioManager.Create(nil);
 +try
 +  LSound := LFMOD.LoadSoundFromFile(Common_MediaPathRaw('drumloop.wav'));
 +finally
 +  LSound := nil; // !!! CORRECT!
 +  FreeAndNil(LFMOD);
 +end;
 +</file>
 +
 +Next step: [[assetsmanager|Assets Manager]]