From: Eunhae Choi Date: Fri, 23 Dec 2016 08:54:03 +0000 (+0900) Subject: [v0.2.39] add user cb lock and apply tizen coding rule X-Git-Tag: submit/tizen/20161227.033947^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ddddca7416c6bb21e349734041b92bd3d0c4d92d;p=platform%2Fcore%2Fmultimedia%2Fmmsvc-player.git [v0.2.39] add user cb lock and apply tizen coding rule Change-Id: Id4faebbd5b9a04b5c749424414c690dc9e87a2bb Signed-off-by: Eunhae Choi (cherry picked from commit 4ffc6af66ec1150b590678d90dc06e12f5f9010a) --- diff --git a/legacy/include/legacy_player.h b/legacy/include/legacy_player.h index 4e647ec..4b9468b 100644 --- a/legacy/include/legacy_player.h +++ b/legacy/include/legacy_player.h @@ -51,11 +51,11 @@ typedef struct player_s *player_h; * @since_tizen 2.3 */ typedef enum { - PLAYER_STATE_NONE, /**< Player is not created */ - PLAYER_STATE_IDLE, /**< Player is created, but not prepared */ - PLAYER_STATE_READY, /**< Player is ready to play media */ - PLAYER_STATE_PLAYING, /**< Player is playing media */ - PLAYER_STATE_PAUSED, /**< Player is paused while playing media */ + PLAYER_STATE_NONE, /**< Player is not created */ + PLAYER_STATE_IDLE, /**< Player is created, but not prepared */ + PLAYER_STATE_READY, /**< Player is ready to play media */ + PLAYER_STATE_PLAYING, /**< Player is playing media */ + PLAYER_STATE_PAUSED, /**< Player is paused while playing media */ } player_state_e; /** @@ -63,28 +63,28 @@ typedef enum { * @since_tizen 2.3 */ typedef enum { - PLAYER_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */ - PLAYER_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */ - PLAYER_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */ - PLAYER_ERROR_NO_SUCH_FILE = TIZEN_ERROR_NO_SUCH_FILE, /**< No such file or directory */ - PLAYER_ERROR_INVALID_OPERATION = TIZEN_ERROR_INVALID_OPERATION, /**< Invalid operation */ - PLAYER_ERROR_FILE_NO_SPACE_ON_DEVICE = TIZEN_ERROR_FILE_NO_SPACE_ON_DEVICE, /**< No space left on the device */ - PLAYER_ERROR_FEATURE_NOT_SUPPORTED_ON_DEVICE = TIZEN_ERROR_NOT_SUPPORTED, /**< Not supported */ - PLAYER_ERROR_SEEK_FAILED = PLAYER_ERROR_CLASS | 0x01, /**< Seek operation failure */ - PLAYER_ERROR_INVALID_STATE = PLAYER_ERROR_CLASS | 0x02, /**< Invalid state */ - PLAYER_ERROR_NOT_SUPPORTED_FILE = PLAYER_ERROR_CLASS | 0x03, /**< File format not supported */ - PLAYER_ERROR_INVALID_URI = PLAYER_ERROR_CLASS | 0x04, /**< Invalid URI */ - PLAYER_ERROR_SOUND_POLICY = PLAYER_ERROR_CLASS | 0x05, /**< Sound policy error */ - PLAYER_ERROR_CONNECTION_FAILED = PLAYER_ERROR_CLASS | 0x06, /**< Streaming connection failed */ - PLAYER_ERROR_VIDEO_CAPTURE_FAILED = PLAYER_ERROR_CLASS | 0x07, /**< Video capture failed */ - PLAYER_ERROR_DRM_EXPIRED = PLAYER_ERROR_CLASS | 0x08, /**< Expired license */ - PLAYER_ERROR_DRM_NO_LICENSE = PLAYER_ERROR_CLASS | 0x09, /**< No license */ - PLAYER_ERROR_DRM_FUTURE_USE = PLAYER_ERROR_CLASS | 0x0a, /**< License for future use */ - PLAYER_ERROR_DRM_NOT_PERMITTED = PLAYER_ERROR_CLASS | 0x0b, /**< Format not permitted */ - PLAYER_ERROR_RESOURCE_LIMIT = PLAYER_ERROR_CLASS | 0x0c, /**< Resource limit */ - PLAYER_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */ - PLAYER_ERROR_SERVICE_DISCONNECTED = PLAYER_ERROR_CLASS | 0x0d, /**< Socket connection lost (Since 3.0) */ - PLAYER_ERROR_BUFFER_SPACE = TIZEN_ERROR_BUFFER_SPACE, /**< No buffer space available (Since 3.0)*/ + PLAYER_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */ + PLAYER_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */ + PLAYER_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */ + PLAYER_ERROR_NO_SUCH_FILE = TIZEN_ERROR_NO_SUCH_FILE, /**< No such file or directory */ + PLAYER_ERROR_INVALID_OPERATION = TIZEN_ERROR_INVALID_OPERATION, /**< Invalid operation */ + PLAYER_ERROR_FILE_NO_SPACE_ON_DEVICE = TIZEN_ERROR_FILE_NO_SPACE_ON_DEVICE, /**< No space left on the device */ + PLAYER_ERROR_FEATURE_NOT_SUPPORTED_ON_DEVICE = TIZEN_ERROR_NOT_SUPPORTED, /**< Not supported */ + PLAYER_ERROR_SEEK_FAILED = PLAYER_ERROR_CLASS | 0x01, /**< Seek operation failure */ + PLAYER_ERROR_INVALID_STATE = PLAYER_ERROR_CLASS | 0x02, /**< Invalid state */ + PLAYER_ERROR_NOT_SUPPORTED_FILE = PLAYER_ERROR_CLASS | 0x03, /**< File format not supported */ + PLAYER_ERROR_INVALID_URI = PLAYER_ERROR_CLASS | 0x04, /**< Invalid URI */ + PLAYER_ERROR_SOUND_POLICY = PLAYER_ERROR_CLASS | 0x05, /**< Sound policy error */ + PLAYER_ERROR_CONNECTION_FAILED = PLAYER_ERROR_CLASS | 0x06, /**< Streaming connection failed */ + PLAYER_ERROR_VIDEO_CAPTURE_FAILED = PLAYER_ERROR_CLASS | 0x07, /**< Video capture failed */ + PLAYER_ERROR_DRM_EXPIRED = PLAYER_ERROR_CLASS | 0x08, /**< Expired license */ + PLAYER_ERROR_DRM_NO_LICENSE = PLAYER_ERROR_CLASS | 0x09, /**< No license */ + PLAYER_ERROR_DRM_FUTURE_USE = PLAYER_ERROR_CLASS | 0x0a, /**< License for future use */ + PLAYER_ERROR_DRM_NOT_PERMITTED = PLAYER_ERROR_CLASS | 0x0b, /**< Format not permitted */ + PLAYER_ERROR_RESOURCE_LIMIT = PLAYER_ERROR_CLASS | 0x0c, /**< Resource limit */ + PLAYER_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */ + PLAYER_ERROR_SERVICE_DISCONNECTED = PLAYER_ERROR_CLASS | 0x0d, /**< Socket connection lost (Since 3.0) */ + PLAYER_ERROR_BUFFER_SPACE = TIZEN_ERROR_BUFFER_SPACE, /**< No buffer space available (Since 3.0)*/ } player_error_e; /** @@ -92,14 +92,14 @@ typedef enum { * @since_tizen 2.3 */ typedef enum { - PLAYER_INTERRUPTED_COMPLETED = 0, /**< Interrupt completed (Deprecated since 3.0)*/ - PLAYER_INTERRUPTED_BY_MEDIA, /**< Interrupted by a non-resumable media application (Deprecated since 3.0)*/ - PLAYER_INTERRUPTED_BY_CALL, /**< Interrupted by an incoming call (Deprecated since 3.0)*/ - PLAYER_INTERRUPTED_BY_EARJACK_UNPLUG, /**< Interrupted by unplugging headphones (Deprecated since 3.0)*/ - PLAYER_INTERRUPTED_BY_RESOURCE_CONFLICT, /**< Interrupted by a resource conflict */ - PLAYER_INTERRUPTED_BY_ALARM, /**< Interrupted by an alarm (Deprecated since 3.0)*/ - PLAYER_INTERRUPTED_BY_EMERGENCY, /**< Interrupted by an emergency (Deprecated since 3.0)*/ - PLAYER_INTERRUPTED_BY_NOTIFICATION, /**< Interrupted by a notification (Deprecated since 3.0)*/ + PLAYER_INTERRUPTED_COMPLETED = 0, /**< Interrupt completed (Deprecated since 3.0)*/ + PLAYER_INTERRUPTED_BY_MEDIA, /**< Interrupted by a non-resumable media application (Deprecated since 3.0)*/ + PLAYER_INTERRUPTED_BY_CALL, /**< Interrupted by an incoming call (Deprecated since 3.0)*/ + PLAYER_INTERRUPTED_BY_EARJACK_UNPLUG, /**< Interrupted by unplugging headphones (Deprecated since 3.0)*/ + PLAYER_INTERRUPTED_BY_RESOURCE_CONFLICT, /**< Interrupted by a resource conflict */ + PLAYER_INTERRUPTED_BY_ALARM, /**< Interrupted by an alarm (Deprecated since 3.0)*/ + PLAYER_INTERRUPTED_BY_EMERGENCY, /**< Interrupted by an emergency (Deprecated since 3.0)*/ + PLAYER_INTERRUPTED_BY_NOTIFICATION, /**< Interrupted by a notification (Deprecated since 3.0)*/ } player_interrupted_code_e; /** @@ -107,8 +107,8 @@ typedef enum { * @since_tizen 2.3 */ typedef enum { - PLAYER_PD_STARTED = 0, /**< Progressive download is started */ - PLAYER_PD_COMPLETED, /**< Progressive download is completed */ + PLAYER_PD_STARTED = 0, /**< Progressive download is started */ + PLAYER_PD_COMPLETED, /**< Progressive download is completed */ } player_pd_message_type_e; /** @@ -116,9 +116,9 @@ typedef enum { * @since_tizen 2.3 */ typedef enum { - PLAYER_DISPLAY_TYPE_OVERLAY = 0, /**< Overlay surface display */ - PLAYER_DISPLAY_TYPE_EVAS, /**< Evas image object surface display */ - PLAYER_DISPLAY_TYPE_NONE, /**< This disposes off buffers */ + PLAYER_DISPLAY_TYPE_OVERLAY = 0, /**< Overlay surface display */ + PLAYER_DISPLAY_TYPE_EVAS, /**< Evas image object surface display */ + PLAYER_DISPLAY_TYPE_NONE, /**< This disposes off buffers */ } player_display_type_e; /** @@ -126,9 +126,9 @@ typedef enum { * @since_tizen 2.3 */ typedef enum { - AUDIO_LATENCY_MODE_LOW = 0, /**< Low audio latency mode */ - AUDIO_LATENCY_MODE_MID, /**< Middle audio latency mode */ - AUDIO_LATENCY_MODE_HIGH, /**< High audio latency mode */ + AUDIO_LATENCY_MODE_LOW = 0, /**< Low audio latency mode */ + AUDIO_LATENCY_MODE_MID, /**< Middle audio latency mode */ + AUDIO_LATENCY_MODE_HIGH, /**< High audio latency mode */ } audio_latency_mode_e; /** @@ -136,10 +136,10 @@ typedef enum { * @since_tizen 2.4 */ typedef enum { - PLAYER_STREAM_TYPE_DEFAULT, /**< Container type */ - PLAYER_STREAM_TYPE_AUDIO, /**< Audio element stream type */ - PLAYER_STREAM_TYPE_VIDEO, /**< Video element stream type */ - PLAYER_STREAM_TYPE_TEXT, /**< Text type */ + PLAYER_STREAM_TYPE_DEFAULT, /**< Container type */ + PLAYER_STREAM_TYPE_AUDIO, /**< Audio element stream type */ + PLAYER_STREAM_TYPE_VIDEO, /**< Video element stream type */ + PLAYER_STREAM_TYPE_TEXT, /**< Text type */ } player_stream_type_e; /** @@ -147,8 +147,8 @@ typedef enum { * @since_tizen 2.4 */ typedef enum { - PLAYER_MEDIA_STREAM_BUFFER_UNDERRUN, - PLAYER_MEDIA_STREAM_BUFFER_OVERFLOW, + PLAYER_MEDIA_STREAM_BUFFER_UNDERRUN, + PLAYER_MEDIA_STREAM_BUFFER_OVERFLOW, } player_media_stream_buffer_status_e; /** @@ -179,10 +179,10 @@ typedef void* player_display_h; * @since_tizen 2.3 */ typedef enum { - PLAYER_DISPLAY_ROTATION_NONE, /**< Display is not rotated */ - PLAYER_DISPLAY_ROTATION_90, /**< Display is rotated 90 degrees */ - PLAYER_DISPLAY_ROTATION_180, /**< Display is rotated 180 degrees */ - PLAYER_DISPLAY_ROTATION_270, /**< Display is rotated 270 degrees */ + PLAYER_DISPLAY_ROTATION_NONE, /**< Display is not rotated */ + PLAYER_DISPLAY_ROTATION_90, /**< Display is rotated 90 degrees */ + PLAYER_DISPLAY_ROTATION_180, /**< Display is rotated 180 degrees */ + PLAYER_DISPLAY_ROTATION_270, /**< Display is rotated 270 degrees */ } player_display_rotation_e; /** @@ -190,13 +190,13 @@ typedef enum { * @since_tizen 2.3 */ typedef enum { - PLAYER_DISPLAY_MODE_LETTER_BOX = 0, /**< Letter box */ - PLAYER_DISPLAY_MODE_ORIGIN_SIZE, /**< Origin size */ - PLAYER_DISPLAY_MODE_FULL_SCREEN, /**< Full-screen */ - PLAYER_DISPLAY_MODE_CROPPED_FULL, /**< Cropped full-screen */ - PLAYER_DISPLAY_MODE_ORIGIN_OR_LETTER, /**< Origin size (if surface size is larger than video size(width/height)) or Letter box (if video size(width/height) is larger than surface size) */ - PLAYER_DISPLAY_MODE_DST_ROI, /**< Dst ROI mode (Deprecated since [3.0]).*/ - PLAYER_DISPLAY_MODE_NUM + PLAYER_DISPLAY_MODE_LETTER_BOX = 0, /**< Letter box */ + PLAYER_DISPLAY_MODE_ORIGIN_SIZE, /**< Origin size */ + PLAYER_DISPLAY_MODE_FULL_SCREEN, /**< Full-screen */ + PLAYER_DISPLAY_MODE_CROPPED_FULL, /**< Cropped full-screen */ + PLAYER_DISPLAY_MODE_ORIGIN_OR_LETTER, /**< Origin size (if surface size is larger than video size(width/height)) or Letter box (if video size(width/height) is larger than surface size) */ + PLAYER_DISPLAY_MODE_DST_ROI, /**< Dst ROI mode (Deprecated since [3.0]).*/ + PLAYER_DISPLAY_MODE_NUM } player_display_mode_e; /** @@ -213,12 +213,12 @@ typedef enum { * @since_tizen 2.3 */ typedef enum { - PLAYER_CONTENT_INFO_ALBUM, /**< Album */ - PLAYER_CONTENT_INFO_ARTIST, /**< Artist */ - PLAYER_CONTENT_INFO_AUTHOR, /**< Author */ - PLAYER_CONTENT_INFO_GENRE, /**< Genre */ - PLAYER_CONTENT_INFO_TITLE, /**< Title */ - PLAYER_CONTENT_INFO_YEAR, /**< Year */ + PLAYER_CONTENT_INFO_ALBUM, /**< Album */ + PLAYER_CONTENT_INFO_ARTIST, /**< Artist */ + PLAYER_CONTENT_INFO_AUTHOR, /**< Author */ + PLAYER_CONTENT_INFO_GENRE, /**< Genre */ + PLAYER_CONTENT_INFO_TITLE, /**< Title */ + PLAYER_CONTENT_INFO_YEAR, /**< Year */ } player_content_info_e; /** @@ -349,8 +349,8 @@ typedef void (*player_video_captured_cb)(unsigned char *data, int width, int hei * @since_tizen 2.3 * * @remarks This function is issued in the context of gstreamer so the UI update code should not be directly invoked.\n - * the packet should be released by media_packet_destroy() after use. \n - * Otherwises, decoder can't work more because it can't have enough buffer to fill decoded frame. + * the packet should be released by media_packet_destroy() after use. \n + * Otherwises, decoder can't work more because it can't have enough buffer to fill decoded frame. * * @param[in] pkt Reference pointer to the media packet * @param[in] user_data The user data passed from the callback registration function @@ -385,7 +385,7 @@ typedef void (*player_media_stream_seek_cb) (unsigned long long offset, void *us * @param[in] width The width of the captured image * @param[in] height The height of the captured image * @param[in] fps The frame per second of the video \n - It can be @c 0 if there is no video stream information. + * It can be @c 0 if there is no video stream information. * @param[in] bit_rate The video bit rate [Hz] \n * It can be an invalid value if there is no video stream information. * @param[in] user_data The user data passed from the callback registration function @@ -478,7 +478,7 @@ int legacy_player_prepare(player_h player); * @see legacy_player_unprepare() * @see legacy_player_set_uri() */ -int legacy_player_prepare_async (player_h player, player_prepared_cb callback, void* user_data); +int legacy_player_prepare_async(player_h player, player_prepared_cb callback, void* user_data); /** * @brief Resets the media player. @@ -560,10 +560,10 @@ int legacy_player_get_state(player_h player, player_state_e *state); /** * @brief Sets the player's volume. * @since_tizen 2.3 - * @details Setting this volume adjusts the player's instance volume, not the system volume. - * The valid range is from 0 to 1.0, inclusive (1.0 = 100%). Default value is 1.0. + * @details Setting this volume adjusts the player's instance volume, not the system volume. + * The valid range is from 0 to 1.0, inclusive (1.0 = 100%). Default value is 1.0. * To change system volume, use the @ref CAPI_MEDIA_SOUND_MANAGER_MODULE API. - * Finally, it does not support to set other value into each channel currently. + * Finally, it does not support to set other value into each channel currently. * * @param[in] player The handle to the media player * @param[in] left The left volume scalar @@ -941,7 +941,7 @@ int legacy_player_push_media_stream(player_h player, media_packet_h packet); * @remarks AAC can be supported. * @remarks H.264 can be supported. * @remarks This API should be called before calling the legacy_player_prepare() or legacy_player_prepare_async() \n - to reflect the media information when pipeline is created. + * to reflect the media information when pipeline is created. * @param[in] player The handle to media player * @param[in] type The type of target stream * @param[in] format The media format to set audio information @@ -1194,7 +1194,7 @@ int legacy_player_set_display_rotation(player_h player, player_display_rotation_ * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter * @see legacy_player_set_display_rotation() */ -int legacy_player_get_display_rotation( player_h player, player_display_rotation_e *rotation); +int legacy_player_get_display_rotation(player_h player, player_display_rotation_e *rotation); /** * @} @@ -1365,7 +1365,7 @@ int legacy_player_get_duration(player_h player, int *duration); * @see legacy_player_audio_effect_set_equalizer_band_level() * @see legacy_player_audio_effect_set_equalizer_all_bands() */ -int legacy_player_audio_effect_get_equalizer_bands_count (player_h player, int *count); +int legacy_player_audio_effect_get_equalizer_bands_count(player_h player, int *count); /** * @brief Sets the gain set for the given equalizer band. @@ -1810,7 +1810,7 @@ int legacy_player_set_playback_rate(player_h player, float rate); * @pre The player state must be one of these: #PLAYER_STATE_IDLE, #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED. * @pre The path value can be @c NULL for reset when the player state is set to #PLAYER_STATE_IDLE by calling legacy_player_create() or legacy_player_unprepare(). */ -int legacy_player_set_subtitle_path(player_h player,const char *path); +int legacy_player_set_subtitle_path(player_h player, const char *path); /** * @brief Registers a callback function to be invoked when a subtitle updates. @@ -1878,7 +1878,7 @@ int legacy_player_set_subtitle_position_offset(player_h player, int millisecond) * @see legacy_player_unset_video_stream_changed_cb() * @see legacy_player_video_stream_changed_cb() */ -int legacy_player_set_video_stream_changed_cb (player_h player, player_video_stream_changed_cb callback, void *user_data); +int legacy_player_set_video_stream_changed_cb(player_h player, player_video_stream_changed_cb callback, void *user_data); /** * @brief Unregisters the video stream changed callback function. @@ -1891,7 +1891,7 @@ int legacy_player_set_video_stream_changed_cb (player_h player, player_video_str * @retval #PLAYER_ERROR_INVALID_PARAMETER Invalid parameter * @see legacy_player_set_video_stream_changed_cb() */ -int legacy_player_unset_video_stream_changed_cb (player_h player); +int legacy_player_unset_video_stream_changed_cb(player_h player); /** * @brief Gets current track index. diff --git a/legacy/include/legacy_player_internal.h b/legacy/include/legacy_player_internal.h index 7ba7458..168679a 100644 --- a/legacy/include/legacy_player_internal.h +++ b/legacy/include/legacy_player_internal.h @@ -177,9 +177,9 @@ int legacy_player_set_media_stream_dynamic_resolution(player_h player, bool drc) * @since_tizen 3.0 * * @details Player will transite the media source as seamlessly as possible after finishing current playback. - * If the function call is successful, the uri will be added at the end of uri list. - * You can add several uris and the set of uris will be played repeatedly if you call the player_set_looping(). - * The first uri in the list is the original uri which is set by player_set_uri(). + * If the function call is successful, the uri will be added at the end of uri list. + * You can add several uris and the set of uris will be played repeatedly if you call the player_set_looping(). + * The first uri in the list is the original uri which is set by player_set_uri(). * * @remarks Uri list will be cleared except first one when the player_unprepare() is called. * If you call the player_set_uri(), you can change the first uri too. @@ -197,7 +197,7 @@ int legacy_player_set_media_stream_dynamic_resolution(player_h player, bool drc) * @pre The player state must be one of these: #PLAYER_STATE_IDLE, #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED. * @see player_set_uri(), player_set_looping() */ -int legacy_player_set_next_uri (player_h player, const char *uri); +int legacy_player_set_next_uri(player_h player, const char *uri); /** * @brief Gets the data source path. @@ -215,7 +215,7 @@ int legacy_player_set_next_uri (player_h player, const char *uri); * @pre The player state must be one of these: #PLAYER_STATE_IDLE, #PLAYER_STATE_READY, #PLAYER_STATE_PLAYING, or #PLAYER_STATE_PAUSED. * @see player_set_uri() */ -int legacy_player_get_next_uri (player_h player, char **uri); +int legacy_player_get_next_uri(player_h player, char **uri); /** * @brief Sets the gapless playback status diff --git a/legacy/include/legacy_player_private.h b/legacy/include/legacy_player_private.h index a022ac1..cefba63 100644 --- a/legacy/include/legacy_player_private.h +++ b/legacy/include/legacy_player_private.h @@ -31,28 +31,42 @@ extern "C" { #define LOG_TAG "TIZEN_N_PLAYER" //#define USE_ECORE_FUNCTIONS -#define PLAYER_CHECK_CONDITION(condition,error,msg) \ - if(condition) {} else \ - { LOGE("[%s] %s(0x%08x)",__FUNCTION__, msg,error); return error;}; \ +#define PLAYER_CHECK_CONDITION(condition, error, msg) \ + if (condition) {} else \ + { LOGE("[%s] %s(0x%08x)", __FUNCTION__, msg, error); return error; }; \ #define PLAYER_INSTANCE_CHECK(player) \ - PLAYER_CHECK_CONDITION(player != NULL, PLAYER_ERROR_INVALID_PARAMETER,"PLAYER_ERROR_INVALID_PARAMETER") + PLAYER_CHECK_CONDITION(player != NULL, PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER") -#define PLAYER_STATE_CHECK(player,expected_state) \ - PLAYER_CHECK_CONDITION(player->state == expected_state,PLAYER_ERROR_INVALID_STATE,"PLAYER_ERROR_INVALID_STATE") +#define PLAYER_STATE_CHECK(player, expected_state) \ + PLAYER_CHECK_CONDITION(player->state == expected_state, PLAYER_ERROR_INVALID_STATE, "PLAYER_ERROR_INVALID_STATE") #define PLAYER_NULL_ARG_CHECK(arg) \ - PLAYER_CHECK_CONDITION(arg != NULL,PLAYER_ERROR_INVALID_PARAMETER,"PLAYER_ERROR_INVALID_PARAMETER") + PLAYER_CHECK_CONDITION(arg != NULL, PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER") #define PLAYER_RANGE_ARG_CHECK(arg, min, max) \ - PLAYER_CHECK_CONDITION(arg <= max,PLAYER_ERROR_INVALID_PARAMETER,"PLAYER_ERROR_INVALID_PARAMETER") \ - PLAYER_CHECK_CONDITION(arg >= min,PLAYER_ERROR_INVALID_PARAMETER,"PLAYER_ERROR_INVALID_PARAMETER") + PLAYER_CHECK_CONDITION(arg <= max, PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER") \ + PLAYER_CHECK_CONDITION(arg >= min, PLAYER_ERROR_INVALID_PARAMETER, "PLAYER_ERROR_INVALID_PARAMETER") + +/* user_cb_lock */ +#define LEGACY_PLAYER_USER_CB_LOCK(x_handle, type) \ + do { \ + if (_check_enabled_user_cb_lock(type)) \ + g_mutex_lock(&((player_s*)x_handle)->user_cb_lock[type]); \ + } while (0) + +#define LEGACY_PLAYER_USER_CB_UNLOCK(x_handle, type) \ + do { \ + if (_check_enabled_user_cb_lock(type)) \ + g_mutex_unlock(&((player_s*)x_handle)->user_cb_lock[type]); \ + } while (0) + #ifdef TIZEN_TTRACE #include #define PLAYER_TRACE_BEGIN(NAME) traceBegin(TTRACE_TAG_VIDEO, NAME) #define PLAYER_TRACE_END() traceEnd(TTRACE_TAG_VIDEO) -#define PLAYER_TRACE_ASYNC_BEGIN(NAME, COOKIE) traceAsyncBegin (TTRACE_TAG_VIDEO, COOKIE, NAME); +#define PLAYER_TRACE_ASYNC_BEGIN(NAME, COOKIE) traceAsyncBegin(TTRACE_TAG_VIDEO, COOKIE, NAME); #define PLAYER_TRACE_ASYNC_END(NAME, COOKIE) traceAsyncEnd(TTRACE_TAG_VIDEO, COOKIE, NAME); #else #define PLAYER_TRACE_BEGIN(NAME) @@ -70,13 +84,14 @@ typedef enum { PLAYER_MESSAGE_EOS, PLAYER_MESSAGE_LOOP_EXIT, PLAYER_MESSAGE_MAX -}_player_message_e; +} _player_message_e; #endif -typedef struct _player_s{ +typedef struct _player_s { MMHandleType mm_handle; const void* user_cb[MUSE_PLAYER_EVENT_TYPE_NUM]; void* user_data[MUSE_PLAYER_EVENT_TYPE_NUM]; + GMutex user_cb_lock[MUSE_PLAYER_EVENT_TYPE_NUM]; void* wl_display; void* display_handle; player_display_type_e display_type; @@ -114,6 +129,7 @@ int legacy_player_sound_register(player_h player, int pid); int legacy_player_get_timeout_for_muse(player_h player, int *timeout); int legacy_player_get_num_of_video_out_buffers(player_h player, int *num, int *extra_num); int legacy_player_set_file_buffering_path(player_h player, const char *file_path); +bool _check_enabled_user_cb_lock(int event_id); #ifdef __cplusplus } diff --git a/legacy/src/legacy_player.c b/legacy/src/legacy_player.c index 9ee6974..4130252 100644 --- a/legacy/src/legacy_player.c +++ b/legacy/src/legacy_player.c @@ -585,11 +585,10 @@ static void __message_cb_loop(void *data) case PLAYER_MESSAGE_ERROR: { LOGW("PLAYER_MESSAGE_ERROR"); - if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_ERROR]) { + if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_ERROR]) ((player_error_cb)handle->user_cb[MUSE_PLAYER_EVENT_TYPE_ERROR])(handle->error_code, handle->user_data[MUSE_PLAYER_EVENT_TYPE_ERROR]); - } else { + else LOGE("null handle in PLAYER_MESSAGE_ERROR"); - } } break; case PLAYER_MESSAGE_SEEK_DONE: @@ -607,11 +606,10 @@ static void __message_cb_loop(void *data) case PLAYER_MESSAGE_EOS: { LOGW("PLAYER_MESSAGE_EOS"); - if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_COMPLETE]) { + if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_COMPLETE]) ((player_completed_cb)handle->user_cb[MUSE_PLAYER_EVENT_TYPE_COMPLETE])(handle->user_data[MUSE_PLAYER_EVENT_TYPE_COMPLETE]); - } else { + else LOGE("null handle in PLAYER_MESSAGE_EOS"); - } } break; case PLAYER_MESSAGE_LOOP_EXIT: @@ -865,6 +863,8 @@ static bool __video_stream_callback(void *stream, void *user_data) player_s *handle = (player_s *)user_data; MMPlayerVideoStreamDataType *video_stream = (MMPlayerVideoStreamDataType *)stream; + LEGACY_PLAYER_USER_CB_LOCK(handle, MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME); + if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME]) { /* media packet and zero-copy */ media_packet_h pkt = NULL; @@ -914,16 +914,20 @@ static bool __video_stream_callback(void *stream, void *user_data) unsigned char *ptr = video_stream->data[0]; unsigned char *ptr2 = video_stream->data[1]; - if (!ptr) + if (!ptr) { + LEGACY_PLAYER_USER_CB_UNLOCK(handle, MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME); return TRUE; - if (!ptr2 && video_stream->format == MM_PIXEL_FORMAT_NV12T) + } + if (!ptr2 && video_stream->format == MM_PIXEL_FORMAT_NV12T) { + LEGACY_PLAYER_USER_CB_UNLOCK(handle, MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME); return TRUE; - + } tsurf = tbm_surface_create(video_stream->width, video_stream->height, bo_format); if (tsurf) { /* map surface to set data */ if (tbm_surface_map(tsurf, TBM_SURF_OPTION_READ | TBM_SURF_OPTION_WRITE, &tsuri)) { LOGE("tbm_surface_map failed"); + LEGACY_PLAYER_USER_CB_UNLOCK(handle, MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME); return TRUE; } @@ -1030,6 +1034,8 @@ static bool __video_stream_callback(void *stream, void *user_data) } } } + + LEGACY_PLAYER_USER_CB_UNLOCK(handle, MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME); return TRUE; } @@ -1048,9 +1054,13 @@ static int __pd_message_callback(int message, void *param, void *user_data) return 0; } + LEGACY_PLAYER_USER_CB_LOCK(handle, MUSE_PLAYER_EVENT_TYPE_PD); + if (handle->user_cb[MUSE_PLAYER_EVENT_TYPE_PD]) ((player_pd_message_cb)handle->user_cb[MUSE_PLAYER_EVENT_TYPE_PD])(type, handle->user_data[MUSE_PLAYER_EVENT_TYPE_PD]); + LEGACY_PLAYER_USER_CB_UNLOCK(handle, MUSE_PLAYER_EVENT_TYPE_PD); + return 0; } @@ -1084,6 +1094,18 @@ static MMDisplaySurfaceType __player_convet_display_type(player_display_type_e t } } +bool _check_enabled_user_cb_lock(int type) +{ + if ((type == MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME) || + (type == MUSE_PLAYER_EVENT_TYPE_PD) || + (type == MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS_WITH_INFO) || + (type == MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS_WITH_INFO)) { + return TRUE; + } else { + return FALSE; + } +} + /* * Public Implementation */ @@ -1108,12 +1130,19 @@ int legacy_player_create(player_h *player) handle = NULL; return __player_convert_error_code(ret, (char *)__FUNCTION__); } else { + muse_player_event_e type = MUSE_PLAYER_EVENT_TYPE_PREPARE; + *player = (player_h)handle; handle->state = PLAYER_STATE_IDLE; handle->display_type = PLAYER_DISPLAY_TYPE_NONE; handle->is_stopped = FALSE; handle->is_display_visible = TRUE; handle->is_media_stream = FALSE; + + for (type = MUSE_PLAYER_EVENT_TYPE_PREPARE; type < MUSE_PLAYER_EVENT_TYPE_NUM; type++) { + if (_check_enabled_user_cb_lock(type)) + g_mutex_init(&handle->user_cb_lock[type]); + } #ifdef USE_ECORE_FUNCTIONS handle->ecore_jobs = g_hash_table_new_full(g_str_hash, g_str_equal, __job_key_to_remove, __job_value_to_destroy); #else @@ -1168,7 +1197,15 @@ int legacy_player_destroy(player_h player) LOGE("[%s] PLAYER_ERROR_INVALID_OPERATION(0x%08x)", __FUNCTION__, PLAYER_ERROR_INVALID_OPERATION); return PLAYER_ERROR_INVALID_OPERATION; } else { + muse_player_event_e type = MUSE_PLAYER_EVENT_TYPE_PREPARE; + handle->state = PLAYER_STATE_NONE; + + for (type = MUSE_PLAYER_EVENT_TYPE_PREPARE; type < MUSE_PLAYER_EVENT_TYPE_NUM; type++) { + if (_check_enabled_user_cb_lock(type)) + g_mutex_clear(&handle->user_cb_lock[type]); + } + #ifndef USE_ECORE_FUNCTIONS if (handle->message_queue) { g_queue_free(handle->message_queue); @@ -2565,8 +2602,10 @@ int legacy_player_unset_progressive_download_message_cb(player_h player) PLAYER_INSTANCE_CHECK(player); player_s *handle = (player_s *)player; + LEGACY_PLAYER_USER_CB_LOCK(handle, MUSE_PLAYER_EVENT_TYPE_PD); handle->user_cb[MUSE_PLAYER_EVENT_TYPE_PD] = NULL; handle->user_data[MUSE_PLAYER_EVENT_TYPE_PD] = NULL; + LEGACY_PLAYER_USER_CB_UNLOCK(handle, MUSE_PLAYER_EVENT_TYPE_PD); LOGI("[%s] Event type : %d ", __FUNCTION__, MUSE_PLAYER_EVENT_TYPE_PD); int ret = mm_player_set_pd_message_callback(handle->mm_handle, NULL, NULL); @@ -2603,9 +2642,13 @@ int legacy_player_unset_media_packet_video_frame_decoded_cb(player_h player) PLAYER_INSTANCE_CHECK(player); player_s *handle = (player_s *)player; + LEGACY_PLAYER_USER_CB_LOCK(handle, MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME); + handle->user_cb[MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME] = NULL; handle->user_data[MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME] = NULL; + LEGACY_PLAYER_USER_CB_UNLOCK(handle, MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME); + LOGI("Event type : %d ", MUSE_PLAYER_EVENT_TYPE_MEDIA_PACKET_VIDEO_FRAME); int ret = mm_player_set_video_stream_callback(handle->mm_handle, NULL, NULL); diff --git a/legacy/src/legacy_player_internal.c b/legacy/src/legacy_player_internal.c index 7f00f95..388cb19 100644 --- a/legacy/src/legacy_player_internal.c +++ b/legacy/src/legacy_player_internal.c @@ -38,7 +38,7 @@ do { \ handle->user_cb[event_type] = callback; \ handle->user_data[event_type] = user_data; \ LOGI("[%s] Event type : %d ", __FUNCTION__, event_type); \ -} while (0) \ +} while (0) bool __audio_stream_callback_ex(MMPlayerAudioStreamDataType *stream, void *user_data) { @@ -137,13 +137,18 @@ static bool __media_stream_buffer_status_callback_ex(player_stream_type_e type, LOGE("[%s] event type %d, status %d, bytes %llu", __FUNCTION__, event_type, status, bytes); + LEGACY_PLAYER_USER_CB_LOCK(handle, event_type); + if (handle->user_cb[event_type]) { ((player_media_stream_buffer_status_cb_ex)handle->user_cb[event_type])(status, bytes, handle->user_data[event_type]); } else { LOGE("[%s][type:%d] buffer status cb was not set.", __FUNCTION__, type); + LEGACY_PLAYER_USER_CB_UNLOCK(handle, event_type); return FALSE; } + LEGACY_PLAYER_USER_CB_UNLOCK(handle, event_type); + return TRUE; } @@ -166,21 +171,27 @@ int legacy_player_set_media_stream_buffer_status_cb_ex(player_h player, player_s return PLAYER_ERROR_INVALID_PARAMETER; } - ret = mm_player_set_media_stream_buffer_status_callback(handle->mm_handle, type, (mm_player_media_stream_buffer_status_callback)__media_stream_buffer_status_callback_ex, (void *)handle); - - if (ret != MM_ERROR_NONE) - return __player_convert_error_code(ret, (char *)__FUNCTION__); - if (type == PLAYER_STREAM_TYPE_VIDEO) event_type = MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_VIDEO_BUFFER_STATUS_WITH_INFO; else event_type = MUSE_PLAYER_EVENT_TYPE_MEDIA_STREAM_AUDIO_BUFFER_STATUS_WITH_INFO; - LOGI("[%s] Event type : %d ", __FUNCTION__, type); + + ret = mm_player_set_media_stream_buffer_status_callback(handle->mm_handle, type, (mm_player_media_stream_buffer_status_callback)__media_stream_buffer_status_callback_ex, (void *)handle); + + if (ret != MM_ERROR_NONE) { + LEGACY_PLAYER_USER_CB_UNLOCK(handle, event_type); + return __player_convert_error_code(ret, (char *)__FUNCTION__); + } + + LEGACY_PLAYER_USER_CB_LOCK(handle, event_type); handle->user_cb[event_type] = callback; handle->user_data[event_type] = user_data; + LEGACY_PLAYER_USER_CB_UNLOCK(handle, event_type); + + LOGI("[%s] Event type : %d ", __FUNCTION__, type); return PLAYER_ERROR_NONE; } @@ -198,12 +209,17 @@ int legacy_player_unset_media_stream_buffer_status_cb_ex(player_h player, player else return PLAYER_ERROR_INVALID_PARAMETER; + LEGACY_PLAYER_USER_CB_LOCK(handle, event_type); + handle->user_cb[event_type] = NULL; handle->user_data[event_type] = NULL; + LEGACY_PLAYER_USER_CB_UNLOCK(handle, event_type); + LOGI("[%s] Event type : %d ", __FUNCTION__, type); ret = mm_player_set_media_stream_buffer_status_callback(handle->mm_handle, type, NULL, NULL); + if (ret != MM_ERROR_NONE) return __player_convert_error_code(ret, (char *)__FUNCTION__); else @@ -224,47 +240,39 @@ int legacy_player_set_media_stream_dynamic_resolution(player_h player, bool drc) return PLAYER_ERROR_NONE; } -int legacy_player_set_next_uri (player_h player, const char *uri) +int legacy_player_set_next_uri(player_h player, const char *uri) { PLAYER_INSTANCE_CHECK(player); player_s * handle = (player_s *) player; - if (!__player_state_validate(handle, PLAYER_STATE_IDLE)) - { - LOGE("[%s] PLAYER_ERROR_INVALID_STATE(0x%08x) : current state - %d" ,__FUNCTION__,PLAYER_ERROR_INVALID_STATE, handle->state); + if (!__player_state_validate(handle, PLAYER_STATE_IDLE)) { + LOGE("[%s] PLAYER_ERROR_INVALID_STATE(0x%08x) : current state - %d", __FUNCTION__, PLAYER_ERROR_INVALID_STATE, handle->state); return PLAYER_ERROR_INVALID_STATE; } int ret = mm_player_set_next_uri(handle->mm_handle, uri); - if(ret != MM_ERROR_NONE) - { - return __player_convert_error_code(ret,(char*)__FUNCTION__); - } + if (ret != MM_ERROR_NONE) + return __player_convert_error_code(ret, (char*)__FUNCTION__); else return PLAYER_ERROR_NONE; } -int legacy_player_get_next_uri (player_h player, char **uri) +int legacy_player_get_next_uri(player_h player, char **uri) { PLAYER_INSTANCE_CHECK(player); player_s *handle = (player_s *) player; - if (!__player_state_validate(handle, PLAYER_STATE_IDLE)) - { - LOGE("[%s] PLAYER_ERROR_INVALID_STATE(0x%08x) : current state - %d" ,__FUNCTION__,PLAYER_ERROR_INVALID_STATE, handle->state); + if (!__player_state_validate(handle, PLAYER_STATE_IDLE)) { + LOGE("[%s] PLAYER_ERROR_INVALID_STATE(0x%08x) : current state - %d", __FUNCTION__, PLAYER_ERROR_INVALID_STATE, handle->state); return PLAYER_ERROR_INVALID_STATE; } int ret = mm_player_get_next_uri(handle->mm_handle, uri); /* uri will be free in muse_player.c*/ - if(ret != MM_ERROR_NONE) - { - return __player_convert_error_code(ret,(char*)__FUNCTION__); - } + if (ret != MM_ERROR_NONE) + return __player_convert_error_code(ret, (char*)__FUNCTION__); else - { return PLAYER_ERROR_NONE; - } } int legacy_player_set_gapless(player_h player, bool gapless) @@ -320,4 +328,4 @@ int legacy_player_enable_media_packet_video_frame_decoded_cb(player_h player, bo return __player_convert_error_code(ret, (char *)__FUNCTION__); else return PLAYER_ERROR_NONE; -} \ No newline at end of file +} diff --git a/legacy/test/legacy_player_es_push_test.c b/legacy/test/legacy_player_es_push_test.c index 13e868f..280fb63 100644 --- a/legacy/test/legacy_player_es_push_test.c +++ b/legacy/test/legacy_player_es_push_test.c @@ -453,22 +453,18 @@ static void feed_video_data_thread_func(void *data) void _video_buffer_status_cb_ex(player_media_stream_buffer_status_e status, unsigned long long bytes, void *user_data) { - if (status == PLAYER_MEDIA_STREAM_BUFFER_UNDERRUN) { + if (status == PLAYER_MEDIA_STREAM_BUFFER_UNDERRUN) LOGE("video buffer is underrun state, current level byte = %llu", bytes); - } - else if (status == PLAYER_MEDIA_STREAM_BUFFER_OVERFLOW) { + else if (status == PLAYER_MEDIA_STREAM_BUFFER_OVERFLOW) LOGE("video buffer is overrun state, current level byte = %llu", bytes); - } } void _audio_buffer_status_cb_ex(player_media_stream_buffer_status_e status, unsigned long long bytes, void *user_data) { - if (status == PLAYER_MEDIA_STREAM_BUFFER_UNDERRUN) { + if (status == PLAYER_MEDIA_STREAM_BUFFER_UNDERRUN) LOGE("audio buffer is underrun state, current level byte = %llu", bytes); - } - else if (status == PLAYER_MEDIA_STREAM_BUFFER_OVERFLOW) { + else if (status == PLAYER_MEDIA_STREAM_BUFFER_OVERFLOW) LOGE("audio buffer is overrun state, current level byte = %llu", bytes); - } } void _video_seek_data_cb(unsigned long long offset, void *user_data) diff --git a/muse/test/build_verify.c b/muse/test/build_verify.c index 20a888f..28b47b9 100644 --- a/muse/test/build_verify.c +++ b/muse/test/build_verify.c @@ -23,6 +23,7 @@ * Does NOT include package */ -int main(){ +int main() +{ return 0; } diff --git a/packaging/mmsvc-player.spec b/packaging/mmsvc-player.spec index 6bcc1ee..d7587db 100644 --- a/packaging/mmsvc-player.spec +++ b/packaging/mmsvc-player.spec @@ -1,6 +1,6 @@ Name: mmsvc-player Summary: A Media Player module for muse server -Version: 0.2.38 +Version: 0.2.39 Release: 0 Group: Multimedia/Libraries License: Apache-2.0