Use static_cast instead of dynamic cast 84/132884/1 accepted/tizen/unified/20170608.185106 submit/tizen/20170608.102629
authorSeungbae Shin <seungbae.shin@samsung.com>
Thu, 8 Jun 2017 06:59:11 +0000 (15:59 +0900)
committerSeungbae Shin <seungbae.shin@samsung.com>
Thu, 8 Jun 2017 06:59:11 +0000 (15:59 +0900)
[Version] 0.3.75
[Profile] Common
[Issue Type] Enhancement

Change-Id: I5eb19a26aed1d01cebb77f33c8376a10ddb23a2d

packaging/capi-media-audio-io.spec
src/cpp/cpp_audio_io.cpp

index 3041dfe125daa4d2580a95f50798121fa1468524..6bd1ca8f797e2fbcc09450d39446479fc751a44c 100644 (file)
@@ -1,6 +1,6 @@
 Name:           capi-media-audio-io
 Summary:        An Audio Input & Audio Output library in Tizen Native API
-Version:        0.3.74
+Version:        0.3.75
 Release:        0
 Group:          Multimedia/API
 License:        Apache-2.0
index c2300cd2fb40e43018f66bfb2de412cd7b7a48b0..50a2408feca6b2563ada0ee0ab072e00fecc265c 100644 (file)
@@ -644,7 +644,7 @@ int cpp_audio_in_read(audio_in_h input, void *buffer, unsigned int length) {
         }
         assert(handle->audioIoHandle);
 
-        CAudioInput* inputHandle = dynamic_cast<CAudioInput*>(handle->audioIoHandle);
+        CAudioInput* inputHandle = static_cast<CAudioInput*>(handle->audioIoHandle);
         if (inputHandle == NULL) {
             THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_HANDLE, "Handle is NULL");
         }
@@ -672,7 +672,7 @@ int cpp_audio_in_get_buffer_size(audio_in_h input, int *size) {
         }
         assert(handle->audioIoHandle);
 
-        CAudioIO* inputHandle = dynamic_cast<CAudioInput*>(handle->audioIoHandle);
+        CAudioIO* inputHandle = static_cast<CAudioInput*>(handle->audioIoHandle);
         if (inputHandle == NULL) {
             THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_HANDLE, "Handle is NULL");
         }
@@ -922,8 +922,10 @@ int cpp_audio_in_peek(audio_in_h input, const void **buffer, unsigned int *lengt
                                    "Parameters are NULL input:%p, buffer:%p", input, buffer);
         }
 
-        CAudioInput* inputHandle = dynamic_cast<CAudioInput*>(handle->audioIoHandle);
-        assert(inputHandle);
+        CAudioInput* inputHandle = static_cast<CAudioInput*>(handle->audioIoHandle);
+        if (inputHandle == NULL) {
+            THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_HANDLE, "Handle is NULL");
+        }
 
         inputHandle->peek(buffer, &_length);
     } catch (CAudioError e) {
@@ -945,8 +947,10 @@ int cpp_audio_in_drop(audio_in_h input) {
                                    "Parameters are NULL input:%p", input);
         }
 
-        CAudioInput* inputHandle = dynamic_cast<CAudioInput*>(handle->audioIoHandle);
-        assert(inputHandle);
+        CAudioInput* inputHandle = static_cast<CAudioInput*>(handle->audioIoHandle);
+        if (inputHandle == NULL) {
+            THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_HANDLE, "Handle is NULL");
+        }
 
         inputHandle->drop();
     } catch (CAudioError e) {
@@ -1269,7 +1273,7 @@ int cpp_audio_out_write(audio_out_h output, void *buffer, unsigned int length) {
         }
         assert(handle->audioIoHandle);
 
-        CAudioOutput* outputHandle = dynamic_cast<CAudioOutput*>(handle->audioIoHandle);
+        CAudioOutput* outputHandle = static_cast<CAudioOutput*>(handle->audioIoHandle);
         if (outputHandle == NULL) {
             THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_HANDLE, "Handle is NULL");
         }
@@ -1297,7 +1301,7 @@ int cpp_audio_out_get_buffer_size(audio_out_h output, int *size) {
         }
         assert(handle->audioIoHandle);
 
-        CAudioOutput* outputHandle = dynamic_cast<CAudioOutput*>(handle->audioIoHandle);
+        CAudioOutput* outputHandle = static_cast<CAudioOutput*>(handle->audioIoHandle);
         if (outputHandle == NULL) {
             THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_INVALID_HANDLE, "Handle is NULL");
         }