[Recorder] Add finalizer and modify dispose logic (#6902)
authorHaesu Gwon <haesu.gwon@samsung.com>
Wed, 14 May 2025 05:37:15 +0000 (14:37 +0900)
committerGitHub <noreply@github.com>
Wed, 14 May 2025 05:37:15 +0000 (14:37 +0900)
src/Tizen.Multimedia.Recorder/Recorder/Recorder.cs

index b3fba7e9fbe47c524cf4fa1eafc5d13954d4bfb5..205715ab4cb7665cb07c837e84c22669b2f9c1d9 100755 (executable)
@@ -52,6 +52,14 @@ namespace Tizen.Multimedia
             }
         }
 
+        /// <summary>
+        /// Finalizes an instance of the Recorder class.
+        /// </summary>
+        ~Recorder()
+        {
+            Dispose(false);
+        }
+
         internal NativeHandle Handle
         {
             get
@@ -75,6 +83,7 @@ namespace Tizen.Multimedia
         public void Dispose()
         {
             Dispose(true);
+            GC.SuppressFinalize(this);
         }
 
         /// <summary>
@@ -88,11 +97,13 @@ namespace Tizen.Multimedia
         {
             if (!_disposed)
             {
-                if (_handle != null)
+                if (disposing)
                 {
-                    _handle.Dispose();
+                    _isInAudioStreamStoring?.Dispose();
                 }
 
+                _handle?.Dispose();
+
                 _disposed = true;
             }
         }