[Audio] : handle AudioIO pause/resume error correctly
authorJeongho Mok <jho.mok@samsung.com>
Wed, 11 Jan 2017 11:23:01 +0000 (20:23 +0900)
committerJeongho Mok <jho.mok@samsung.com>
Wed, 11 Jan 2017 12:49:33 +0000 (21:49 +0900)
Change-Id: If8ea6cc707311800a23dfe1b30091be470534bc0

src/Tizen.Multimedia/AudioIO/AudioCapture.cs
src/Tizen.Multimedia/AudioIO/AudioPlayback.cs [changed mode: 0644->0755]

index 0edd29f..783521c 100755 (executable)
@@ -210,16 +210,7 @@ namespace Tizen.Multimedia
             }
             ValidateState(AudioIOState.Running);
 
-            int ret = Interop.AudioIO.AudioInput.Pause(_handle);
-
-            // Here, we convert the not supported error into InvalidOperationException.
-            // It is because this exception is more appropriate in C# for this kind of situation.
-            if ((int)AudioIOError.NotSupported == ret)
-            {
-                throw new InvalidOperationException("Cannot change the state in event handlers.");
-            }
-
-            MultimediaDebug.AssertNoError(ret);
+            AudioIOUtil.ThrowIfError(Interop.AudioIO.AudioInput.Pause(_handle));
         }
         /// <summary>
         /// Resumes buffering audio data from the device.
@@ -238,16 +229,7 @@ namespace Tizen.Multimedia
             }
             ValidateState(AudioIOState.Paused);
 
-            int ret = Interop.AudioIO.AudioInput.Resume(_handle);
-
-            // Here, we convert the not supported error into InvalidOperationException.
-            // It is because this exception is more appropriate in C# for this kind of situation.
-            if ((int)AudioIOError.NotSupported == ret)
-            {
-                throw new InvalidOperationException("Cannot change the state in event handlers.");
-            }
-
-            MultimediaDebug.AssertNoError(ret);
+            AudioIOUtil.ThrowIfError(Interop.AudioIO.AudioInput.Resume(_handle));
         }
         /// <summary>
         /// Flushes and discards buffered audio data from the input stream.
old mode 100644 (file)
new mode 100755 (executable)
index e59aa0e..99a8908
@@ -319,16 +319,7 @@ namespace Tizen.Multimedia
             }
             ValidateState(AudioIOState.Running);
 
-            int ret = Interop.AudioIO.AudioOutput.Pause(_handle);
-
-            // Here, we convert the not supported error into InvalidOperationException.
-            // It is because this exception is more appropriate in C# for this kind of situation.
-            if ((int)AudioIOError.NotSupported == ret)
-            {
-                throw new InvalidOperationException("Cannot change the state in event handlers.");
-            }
-
-            MultimediaDebug.AssertNoError(ret);
+            AudioIOUtil.ThrowIfError(Interop.AudioIO.AudioOutput.Pause(_handle));
         }
 
         /// <summary>
@@ -350,16 +341,7 @@ namespace Tizen.Multimedia
             }
             ValidateState(AudioIOState.Paused);
 
-            int ret = Interop.AudioIO.AudioOutput.Resume(_handle);
-
-            // Here, we convert the not supported error into InvalidOperationException.
-            // It is because this exception is more appropriate in C# for this kind of situation.
-            if ((int)AudioIOError.NotSupported == ret)
-            {
-                throw new InvalidOperationException("Cannot change the state in event handlers.");
-            }
-
-            MultimediaDebug.AssertNoError(ret);
+            AudioIOUtil.ThrowIfError(Interop.AudioIO.AudioOutput.Resume(_handle));
         }
 
         /// <summary>