From: Sangchul Lee Date: Thu, 16 Jul 2015 08:34:43 +0000 (+0900) Subject: Revise internal code and description about error type X-Git-Tag: submit/tizen/20150729.122952~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a82a06b9ae0606f47e7580f58a82ea4ba698a92e;p=platform%2Fcore%2Fapi%2Fsound-manager.git Revise internal code and description about error type Add SOUND_MANAGER_ERROR_NOT_SUPPORTED error type to the description of sound_manager_create_stream_information(). Remove NATIVE_API_RECORDER enumerator because recorder API does not use stream type of sound-manager. Remove string copy for the stream_type of handle. [Version] Release 0.3.14 [profile] Common [Issue Type] revise code Change-Id: Id4caa2ae617c9f4fc31ae1cf4ee342fe2b28966f --- diff --git a/include/sound_manager.h b/include/sound_manager.h index 9774564..a8b53b3 100644 --- a/include/sound_manager.h +++ b/include/sound_manager.h @@ -525,6 +525,7 @@ int sound_manager_unset_volume_changed_cb (void); * otherwise a negative error value * @retval #SOUND_MANAGER_ERROR_NONE Success * @retval #SOUND_MANAGER_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #SOUND_MANAGER_ERROR_NOT_SUPPORTED Not supported * @retval #SOUND_MANAGER_ERROR_INTERNAL Internal error inside the sound system * @see sound_manager_destroy_stream_information() * @see sound_manager_add_device_for_stream_routing() diff --git a/include/sound_manager_internal.h b/include/sound_manager_internal.h index 8582078..26aa843 100644 --- a/include/sound_manager_internal.h +++ b/include/sound_manager_internal.h @@ -52,7 +52,6 @@ typedef enum { NATIVE_API_WAV_PLAYER, /**< Wav-player Native API */ NATIVE_API_TONE_PLAYER, /**< Tone-player Native API */ NATIVE_API_AUDIO_IO, /**< Audio-io Native API */ - NATIVE_API_RECORDER, /**< Recorder Native API */ } native_api_e; /** diff --git a/include/sound_manager_private.h b/include/sound_manager_private.h index 756860e..669c77b 100644 --- a/include/sound_manager_private.h +++ b/include/sound_manager_private.h @@ -100,23 +100,6 @@ if( pthread_mutex_unlock( x_mutex ) ) { \ x_count--; \ } \ -#define SM_STRNCPY(dst,src,size,err) \ -do { \ - if(src != NULL && dst != NULL && size > 0) { \ - strncpy(dst,src,size); \ - dst[size-1] = '\0'; \ - } else if(dst == NULL) { \ - LOGE("STRNCPY ERROR: Destination String is NULL\n"); \ - err = MM_ERROR_SOUND_INTERNAL; \ - } else if(size <= 0) { \ - LOGE("STRNCPY ERROR: Destination String is NULL\n"); \ - err = MM_ERROR_SOUND_INTERNAL; \ - } else { \ - LOGE("STRNCPY ERROR: Destination String is NULL\n"); \ - err = MM_ERROR_SOUND_INTERNAL; \ - } \ -} while(0) - #define SOUND_SESSION_TYPE_DEFAULT SOUND_SESSION_TYPE_MEDIA #define SOUND_STREAM_INFO_ARR_MAX 128 #define SOUND_STREAM_TYPE_LEN 64 @@ -152,7 +135,7 @@ typedef struct _manual_route_info_s { typedef struct _sound_stream_info_s { unsigned int index; - char stream_type[SOUND_STREAM_TYPE_LEN]; + char *stream_type; pa_threaded_mainloop *pa_mainloop; pa_context *pa_context; stream_conf_info_s stream_conf_info; @@ -170,7 +153,7 @@ typedef enum { typedef struct _virtual_stream_info_s { _vstream_state state; - char stream_type[SOUND_STREAM_TYPE_LEN]; + char *stream_type; pa_threaded_mainloop *pa_mainloop; pa_context *pa_context; pa_stream *pa_stream[SOUND_STREAM_DIRECTION_MAX]; @@ -221,9 +204,9 @@ int __convert_sound_manager_error_code (const char *func, int code); int __find_empty_slot (int *index); -int __convert_stream_type (sound_stream_type_e enum_type, char *stream_type); +int __convert_stream_type (sound_stream_type_e enum_type, char **stream_type); -int __convert_stream_type_for_internal (sound_stream_type_internal_e stream_type_enum, char *stream_type); +int __convert_stream_type_for_internal (sound_stream_type_internal_e stream_type_enum, char **stream_type); int __convert_stream_type_to_change_reason (const char *stream_type, sound_stream_focus_change_reason_e *change_reason); diff --git a/packaging/capi-media-sound-manager.spec b/packaging/capi-media-sound-manager.spec index b1ebace..96a4683 100755 --- a/packaging/capi-media-sound-manager.spec +++ b/packaging/capi-media-sound-manager.spec @@ -1,6 +1,6 @@ Name: capi-media-sound-manager Summary: Sound Manager library -Version: 0.3.13 +Version: 0.3.14 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/src/sound_manager.c b/src/sound_manager.c index b08abf7..f7419ac 100644 --- a/src/sound_manager.c +++ b/src/sound_manager.c @@ -187,7 +187,7 @@ int sound_manager_create_stream_information (sound_stream_type_e stream_type, so ret = MM_ERROR_OUT_OF_MEMORY; } else { memset(stream_h, 0, sizeof(sound_stream_info_s)); - ret = __convert_stream_type(stream_type, stream_h->stream_type); + ret = __convert_stream_type(stream_type, &stream_h->stream_type); if (ret == MM_ERROR_NONE) { ret = _make_pa_connection_and_register_focus(stream_h, callback, user_data); if (ret == MM_ERROR_NONE) { diff --git a/src/sound_manager_internal.c b/src/sound_manager_internal.c index be80ac4..13aae4b 100644 --- a/src/sound_manager_internal.c +++ b/src/sound_manager_internal.c @@ -33,7 +33,7 @@ int sound_manager_create_stream_information_internal (sound_stream_type_internal ret = MM_ERROR_OUT_OF_MEMORY; } else { memset(stream_h, 0, sizeof(sound_stream_info_s)); - ret = __convert_stream_type_for_internal(stream_type, stream_h->stream_type); + ret = __convert_stream_type_for_internal(stream_type, &stream_h->stream_type); if (ret == MM_ERROR_NONE) { ret = _make_pa_connection_and_register_focus(stream_h, callback, user_data); if (!ret) { @@ -134,7 +134,7 @@ int sound_manager_create_virtual_stream (sound_stream_info_h stream_info, virtua ret = MM_ERROR_OUT_OF_MEMORY; } else { memset(vstream_h, 0, sizeof(virtual_sound_stream_info_s)); - memcpy(vstream_h->stream_type, stream_h->stream_type, SOUND_STREAM_TYPE_LEN); + vstream_h->stream_type = stream_h->stream_type; vstream_h->pa_mainloop = stream_h->pa_mainloop; vstream_h->pa_context = stream_h->pa_context; vstream_h->pa_proplist = pa_proplist_new(); diff --git a/src/sound_manager_private.c b/src/sound_manager_private.c index 4c5927d..da4eced 100644 --- a/src/sound_manager_private.c +++ b/src/sound_manager_private.c @@ -95,7 +95,7 @@ int __convert_sound_manager_error_code (const char *func, int code) { return ret; } -int __convert_stream_type (sound_stream_type_e stream_type_enum, char *stream_type) +int __convert_stream_type (sound_stream_type_e stream_type_enum, char **stream_type) { int ret = MM_ERROR_NONE; @@ -105,31 +105,31 @@ int __convert_stream_type (sound_stream_type_e stream_type_enum, char *stream_ty switch (stream_type_enum) { case SOUND_STREAM_TYPE_MEDIA: - SM_STRNCPY(stream_type,"media",SOUND_STREAM_TYPE_LEN,ret); + *stream_type = "media"; break; case SOUND_STREAM_TYPE_SYSTEM: - SM_STRNCPY(stream_type,"system",SOUND_STREAM_TYPE_LEN,ret); + *stream_type = "system"; break; case SOUND_STREAM_TYPE_ALARM: - SM_STRNCPY(stream_type,"alarm",SOUND_STREAM_TYPE_LEN,ret); + *stream_type = "alarm"; break; case SOUND_STREAM_TYPE_NOTIFICATION: - SM_STRNCPY(stream_type,"notification",SOUND_STREAM_TYPE_LEN,ret); + *stream_type = "notification"; break; case SOUND_STREAM_TYPE_EMERGENCY: - SM_STRNCPY(stream_type,"emergency",SOUND_STREAM_TYPE_LEN,ret); + *stream_type = "emergency"; break; case SOUND_STREAM_TYPE_VOICE_INFORMATION: - SM_STRNCPY(stream_type,"voice-information",SOUND_STREAM_TYPE_LEN,ret); + *stream_type = "voice-information"; break; case SOUND_STREAM_TYPE_VOICE_RECOGNITION: - SM_STRNCPY(stream_type,"voice-recognition",SOUND_STREAM_TYPE_LEN,ret); + *stream_type = "voice-recognition"; break; case SOUND_STREAM_TYPE_RINGTONE_VOIP: - SM_STRNCPY(stream_type,"ringtone-voip",SOUND_STREAM_TYPE_LEN,ret); + *stream_type = "ringtone-voip"; break; case SOUND_STREAM_TYPE_VOIP: - SM_STRNCPY(stream_type,"voip",SOUND_STREAM_TYPE_LEN,ret); + *stream_type = "voip"; break; default: LOGE("could not find the stream_type[%d] in this switch case statement", stream_type_enum); @@ -141,7 +141,7 @@ int __convert_stream_type (sound_stream_type_e stream_type_enum, char *stream_ty return ret; } -int __convert_stream_type_for_internal (sound_stream_type_internal_e stream_type_enum, char *stream_type) +int __convert_stream_type_for_internal (sound_stream_type_internal_e stream_type_enum, char **stream_type) { int ret = MM_ERROR_NONE; @@ -151,19 +151,19 @@ int __convert_stream_type_for_internal (sound_stream_type_internal_e stream_type switch (stream_type_enum) { case SOUND_STREAM_TYPE_RINGTONE_CALL: - SM_STRNCPY(stream_type,"ringtone-call",SOUND_STREAM_TYPE_LEN,ret); + *stream_type = "ringtone-call"; break; case SOUND_STREAM_TYPE_VOICE_CALL: - SM_STRNCPY(stream_type,"call-voice",SOUND_STREAM_TYPE_LEN,ret); + *stream_type = "call-voice"; break; case SOUND_STREAM_TYPE_VIDEO_CALL: - SM_STRNCPY(stream_type,"call-video",SOUND_STREAM_TYPE_LEN,ret); + *stream_type = "call-video"; break; case SOUND_STREAM_TYPE_RADIO: - SM_STRNCPY(stream_type,"radio",SOUND_STREAM_TYPE_LEN,ret); + *stream_type = "radio"; break; case SOUND_STREAM_TYPE_LOOPBACK: - SM_STRNCPY(stream_type,"loopback",SOUND_STREAM_TYPE_LEN,ret); + *stream_type = "loopback"; break; default: LOGE("could not find the stream_type[%d] in this switch case statement", stream_type_enum); @@ -254,12 +254,8 @@ int __convert_sound_type (sound_type_e sound_type, const char **volume_type) *volume_type = "voice"; break; } - if (!strncmp(*volume_type,"",SOUND_DEVICE_TYPE_LEN)) { - LOGE("could not find the sound_type[%d] in this switch case statement", sound_type); - ret = MM_ERROR_SOUND_INTERNAL; - } else { - LOGI("volume_type[%s]", *volume_type); - } + LOGI("volume_type[%s]", *volume_type); + return ret; } @@ -374,9 +370,6 @@ const char* __convert_api_name (native_api_e api_name) case NATIVE_API_AUDIO_IO: name = "audio-io"; break; - case NATIVE_API_RECORDER: - name = "recorder"; - break; } return name; }