apply tizen coding rules 77/83377/3
authorNAMJEONGYOON <just.nam@samsung.com>
Wed, 10 Aug 2016 11:02:36 +0000 (20:02 +0900)
committerNAMJEONGYOON <just.nam@samsung.com>
Thu, 11 Aug 2016 05:36:42 +0000 (14:36 +0900)
Change-Id: Id04521cbe066936146f3a3885ea715974e910cb7

15 files changed:
src/include/mm_player_audioeffect.h
src/include/mm_player_es.h
src/include/mm_player_ini.h
src/include/mm_player_internal.h
src/include/mm_player_pd.h
src/include/mm_player_streaming.h
src/include/mm_player_tracks.h
src/include/mm_player_utils.h
src/mm_player_attrs.c
src/mm_player_audioeffect.c
src/mm_player_pd.c
src/mm_player_resource.c
src/mm_player_sound_focus.c
src/mm_player_tracks.c
src/mm_player_utils.c

index bde45e3..ec47722 100644 (file)
@@ -164,7 +164,7 @@ int mm_player_get_foreach_present_supported_effect_type(MMHandleType player, MMA
  * @see
  * @since
  */
-int mm_player_audio_effect_bypass (MMHandleType hplayer);
+int mm_player_audio_effect_bypass(MMHandleType hplayer);
 
 /**
  * This function is to apply custom effect(Equalizer and Extension effects).
index ede0059..94730aa 100644 (file)
@@ -37,39 +37,39 @@ extern "C"
 /*=======================================================================================
 | GLOBAL FUNCTION PROTOTYPES                                                           |
 ========================================================================================*/
-int _mmplayer_set_video_info (MMHandleType player, media_format_h format);
+int _mmplayer_set_video_info(MMHandleType player, media_format_h format);
 
-int _mmplayer_set_audio_info (MMHandleType player, media_format_h format);
+int _mmplayer_set_audio_info(MMHandleType player, media_format_h format);
 
-int _mmplayer_set_subtitle_info (MMHandleType player, MMPlayerSubtitleStreamInfo * info);
+int _mmplayer_set_subtitle_info(MMHandleType player, MMPlayerSubtitleStreamInfo * info);
 
-int _mmplayer_submit_packet (MMHandleType player, media_packet_h packet);
+int _mmplayer_submit_packet(MMHandleType player, media_packet_h packet);
 
-int _mmplayer_set_media_stream_buffer_status_cb (MMHandleType player,
-                                                 MMPlayerStreamType type,
-                                                 mm_player_media_stream_buffer_status_callback callback,
-                                                 void * user_param);
+int _mmplayer_set_media_stream_buffer_status_cb(MMHandleType player,
+                                                                                       MMPlayerStreamType type,
+                                                                                       mm_player_media_stream_buffer_status_callback callback,
+                                                                                       void * user_param);
 
-int _mmplayer_set_media_stream_seek_data_cb (MMHandleType player,
-                                             MMPlayerStreamType type,
-                                             mm_player_media_stream_seek_data_callback callback,
-                                             void * user_param);
+int _mmplayer_set_media_stream_seek_data_cb(MMHandleType player,
+                                                                                       MMPlayerStreamType type,
+                                                                                       mm_player_media_stream_seek_data_callback callback,
+                                                                                       void * user_param);
 
-int _mmplayer_set_media_stream_max_size (MMHandleType hplayer,
-                                         MMPlayerStreamType type,
-                                         guint64 max_size);
+int _mmplayer_set_media_stream_max_size(MMHandleType hplayer,
+                                                                                       MMPlayerStreamType type,
+                                                                                       guint64 max_size);
 
 int _mmplayer_get_media_stream_max_size(MMHandleType hplayer,
-                                        MMPlayerStreamType type,
-                                        guint64 *max_size);
+                                                                                       MMPlayerStreamType type,
+                                                                                       guint64 *max_size);
 
 int _mmplayer_set_media_stream_min_percent(MMHandleType hplayer,
-                                           MMPlayerStreamType type,
-                                           guint min_percent);
+                                                                                       MMPlayerStreamType type,
+                                                                                       guint min_percent);
 
 int _mmplayer_get_media_stream_min_percent(MMHandleType hplayer,
-                                           MMPlayerStreamType type,
-                                           guint *min_percent);
+                                                                                       MMPlayerStreamType type,
+                                                                                       guint *min_percent);
 int _mmplayer_set_media_stream_dynamic_resolution(MMHandleType hplayer, bool drc);
 
 #ifdef __cplusplus
index f849a4f..145d982 100644 (file)
  * before that time, we should be careful with size limitation
  * of each string item.
  */
-enum keyword_type
-{
+enum keyword_type {
        KEYWORD_EXCLUDE,        // for element exclude keyworld
        KEYWORD_DUMP            // for dump element keyworld
 };
 
-typedef struct __mm_player_ini
-{
+typedef struct __mm_player_ini {
        /* general */
        gchar videosink_element_overlay[PLAYER_INI_MAX_STRLEN];
        gchar videosink_element_evas[PLAYER_INI_MAX_STRLEN];
@@ -138,8 +136,8 @@ typedef struct __mm_player_ini
 #define DEFAULT_SKIP_RESCAN                            TRUE
 #define DEFAULT_GENERATE_DOT                           FALSE
 #define DEFAULT_USE_SYSTEM_CLOCK               TRUE
-#define DEFAULT_DELAY_BEFORE_REPEAT                    50 /* msec */
-#define DEFAULT_EOS_DELAY                              0 /* msec */
+#define DEFAULT_DELAY_BEFORE_REPEAT                    50 /* msec */
+#define DEFAULT_EOS_DELAY                              0 /* msec */
 #define DEFAULT_VIDEOSINK_OVERLAY                      "waylandsink"
 #define DEFAULT_VIDEOSINK_EVAS                         "evasimagesink"
 #define DEFAULT_VIDEOSINK_FAKE                         "fakesink"
@@ -152,8 +150,8 @@ typedef struct __mm_player_ini
 #define DEFAULT_DISABLE_SEGTRAP                                TRUE
 #define DEFAULT_VIDEO_CONVERTER                                ""
 #define DEFAULT_VIDEO_PLAYBACK_SUPPORTED                               TRUE
-#define DEFAULT_LIVE_STATE_CHANGE_TIMEOUT              30 /* sec */
-#define DEFAULT_LOCALPLAYBACK_STATE_CHANGE_TIMEOUT     10 /* sec */
+#define DEFAULT_LIVE_STATE_CHANGE_TIMEOUT              30 /* sec */
+#define DEFAULT_LOCALPLAYBACK_STATE_CHANGE_TIMEOUT     10 /* sec */
 #define DEFAULT_PCM_BUFFER_SIZE                        51200 /* bytes */
 #define DEFAULT_NUM_OF_VIDEO_BO                        10
 #define DEFAULT_TIMEOUT_OF_VIDEO_BO            10 /* sec */
index 0f8fe6f..60304e9 100644 (file)
@@ -30,7 +30,7 @@
 #endif
 
 /**
-       @addtogroup PLAYER-INTERNAL
+       @addtogroup PLAYER-INTERNAL
        @{
 
        @par
  * Enumerations of video colorspace
  */
 typedef enum {
-    MM_PLAYER_COLORSPACE_I420 = 0,             /**< I420 format - planer */
-    MM_PLAYER_COLORSPACE_RGB888,                       /**< RGB888 pixel format */
-    MM_PLAYER_COLORSPACE_NV12_TILED,           /**< Customized color format */
-    MM_PLAYER_COLORSPACE_NV12,
-}MMPlayerVideoColorspace;
+       MM_PLAYER_COLORSPACE_I420 = 0,                  /**< I420 format - planer */
+       MM_PLAYER_COLORSPACE_RGB888,                    /**< RGB888 pixel format */
+       MM_PLAYER_COLORSPACE_NV12_TILED,                /**< Customized color format */
+       MM_PLAYER_COLORSPACE_NV12,
+} MMPlayerVideoColorspace;
 
-typedef struct
-{
+typedef struct {
        unsigned char *data;                                    /* capture image buffer */
        int size;                                                               /* capture image size */
        MMPlayerVideoColorspace fmt;                    /* color space type */
        unsigned int width;                                             /* width of captured image */
        unsigned int height;                                    /* height of captured image */
        unsigned int orientation;                               /* content orientation */
-}MMPlayerVideoCapture;
+} MMPlayerVideoCapture;
 
-typedef struct
-{
+typedef struct {
        void *data;
        int data_size;
        int channel;
@@ -121,7 +119,7 @@ typedef struct
        int depth;
        bool is_little_endian;
        guint64 channel_mask;
-}MMPlayerAudioStreamDataType;
+} MMPlayerAudioStreamDataType;
 
 /**
  * Video stream callback function type.
@@ -179,8 +177,8 @@ typedef bool        (*mm_player_audio_stream_callback_ex) (MMPlayerAudioStreamDataType
  * @return     This function returns zero on success, or negative value with error
  *                     code
  * @remark     The current supported range is from -64x to 64x.
- *             But, the quailty is dependent on codec performance.
- *             And, the sound is muted under normal speed and more than double speed.
+ *             But, the quailty is dependent on codec performance.
+ *             And, the sound is muted under normal speed and more than double speed.
  * @see
  * @since
  */
index 3583526..9e54cb2 100644 (file)
        extern "C" {
 #endif
 
-typedef struct
-{
+typedef struct {
        gchar *path_read_from;          // path for download and playback
-       gchar *location_to_save;                // path for saving to local
+       gchar *location_to_save;                // path for saving to local
        gint64 total_size;                              // size of file to download (bytes)
 
        GstElement *playback_pipeline_src;  // src element of playback pipeline
@@ -44,7 +43,7 @@ typedef struct
        GstElement *downloader_src;
        GstElement *downloader_queue;
        GstElement *downloader_sink;
-}mm_player_pd_t;
+} mm_player_pd_t;
 
 /**
  * This function allocates handle of progressive download.
@@ -54,7 +53,7 @@ typedef struct
  * @see                _mmplayer_destroy_pd_downloader()
  *
  */
-mm_player_pd_t * _mmplayer_create_pd_downloader ();
+mm_player_pd_t * _mmplayer_create_pd_downloader();
 /**
  * This function destroy progressive download.
  *
@@ -64,7 +63,7 @@ mm_player_pd_t * _mmplayer_create_pd_downloader ();
  * @see                _mmplayer_create_pd_downloader()
  *
  */
-gboolean _mmplayer_destroy_pd_downloader  (MMHandleType handle);
+gboolean _mmplayer_destroy_pd_downloader(MMHandleType handle);
 /**
  * This function realize progressive download.
  *
@@ -77,7 +76,7 @@ gboolean _mmplayer_destroy_pd_downloader  (MMHandleType handle);
  * @see
  *
  */
-gboolean _mmplayer_realize_pd_downloader (MMHandleType handle, gchar *src_uri, gchar *dst_uri, GstElement *pushsrc);
+gboolean _mmplayer_realize_pd_downloader(MMHandleType handle, gchar *src_uri, gchar *dst_uri, GstElement *pushsrc);
 /**
  * This function unrealize progressive download.
  *
@@ -87,7 +86,7 @@ gboolean _mmplayer_realize_pd_downloader (MMHandleType handle, gchar *src_uri, g
  * @see                _mmplayer_realize_pd_downloader()
  *
  */
-gboolean _mmplayer_unrealize_pd_downloader (MMHandleType handle);
+gboolean _mmplayer_unrealize_pd_downloader(MMHandleType handle);
 /**
  * This function start progressive download.
  *
@@ -97,7 +96,7 @@ gboolean _mmplayer_unrealize_pd_downloader (MMHandleType handle);
  * @see
  *
  */
-gboolean _mmplayer_start_pd_downloader (MMHandleType handle);
+gboolean _mmplayer_start_pd_downloader(MMHandleType handle);
 /**
  * This function get pd current status.
  *
index 55c97f7..105d889 100644 (file)
 
 #define GET_BYTE_FROM_BIT(bit) (bit/8)
 #define GET_BIT_FROM_BYTE(byte) (byte*8)
-#define CALC_PERCENT(a,b) ((gdouble)(a) * 100 / (gdouble)(b))
+#define CALC_PERCENT(a, b) ((gdouble)(a) * 100 / (gdouble)(b))
 #define GET_PERCENT(a, b, c, d) \
-do \
-{ \
-       if (((a) > 0) && ((b) > 0))             \
-       {       \
+do { \
+       if (((a) > 0) && ((b) > 0)) { \
                d = CALC_PERCENT(a, b); \
-       }       \
-       else    \
-       {       \
-               LOGW ("set default per info\n");        \
-               d = c;  \
+       } else { \
+               LOGW("set default per info\n"); \
+               d = c; \
        } \
-} while ( 0 );
+} while (0);
 
 
-#define PLAYER_BUFFER_CAST(handle)     ((streaming_buffer_t *)(handle))
-#define PLAYER_STREAM_CAST(sr)                 ((mm_player_streaming_t *)(sr))
+#define PLAYER_BUFFER_CAST(handle)     ((streaming_buffer_t *)(handle))
+#define PLAYER_STREAM_CAST(sr)         ((mm_player_streaming_t *)(sr))
 
 #define GET_CURRENT_BUFFERING_BYTE(handle)     (PLAYER_BUFFER_CAST(handle)->buffering_bytes)
 #define GET_CURRENT_BUFFERING_TIME(handle)     (PLAYER_BUFFER_CAST(handle)->buffering_time)
 
-#define IS_MUXED_BUFFERING_MODE(sr)            (PLAYER_STREAM_CAST(sr)->streaming_buffer_type == BUFFER_TYPE_MUXED)?(TRUE):(FALSE)
-#define IS_DEMUXED_BUFFERING_MODE(sr)  (PLAYER_STREAM_CAST(sr)->streaming_buffer_type == BUFFER_TYPE_DEMUXED)?(TRUE):(FALSE)
+#define IS_MUXED_BUFFERING_MODE(sr)            (PLAYER_STREAM_CAST(sr)->streaming_buffer_type == BUFFER_TYPE_MUXED) ? (TRUE) : (FALSE)
+#define IS_DEMUXED_BUFFERING_MODE(sr)  (PLAYER_STREAM_CAST(sr)->streaming_buffer_type == BUFFER_TYPE_DEMUXED) ? (TRUE) : (FALSE)
 
-#define GET_NEW_BUFFERING_BYTE(size)   ((size) < MAX_DECODEBIN_BUFFER_BYTES)?(size):(MAX_DECODEBIN_BUFFER_BYTES)
-#define GET_MAX_BUFFER_BYTES(sr)               ((PLAYER_STREAM_CAST(sr)->is_adaptive_streaming)?(MAX_DECODEBIN_ADAPTIVE_BUFFER_BYTES):(MAX_DECODEBIN_BUFFER_BYTES))
-#define GET_MAX_BUFFER_TIME(sr)                        ((PLAYER_STREAM_CAST(sr)->is_adaptive_streaming)?(MAX_DECODEBIN_ADAPTIVE_BUFFER_TIME):(MAX_DECODEBIN_BUFFER_TIME))
-#define GET_DEFAULT_PLAYING_TIME(sr)   ((PLAYER_STREAM_CAST(sr)->is_adaptive_streaming)?(DEFAULT_ADAPTIVE_PLAYING_TIME):(DEFAULT_PLAYING_TIME))
+#define GET_NEW_BUFFERING_BYTE(size)   ((size) < MAX_DECODEBIN_BUFFER_BYTES) ? (size) : (MAX_DECODEBIN_BUFFER_BYTES)
+#define GET_MAX_BUFFER_BYTES(sr)               ((PLAYER_STREAM_CAST(sr)->is_adaptive_streaming) ? (MAX_DECODEBIN_ADAPTIVE_BUFFER_BYTES) : (MAX_DECODEBIN_BUFFER_BYTES))
+#define GET_MAX_BUFFER_TIME(sr)                        ((PLAYER_STREAM_CAST(sr)->is_adaptive_streaming) ? (MAX_DECODEBIN_ADAPTIVE_BUFFER_TIME) : (MAX_DECODEBIN_BUFFER_TIME))
+#define GET_DEFAULT_PLAYING_TIME(sr)   ((PLAYER_STREAM_CAST(sr)->is_adaptive_streaming) ? (DEFAULT_ADAPTIVE_PLAYING_TIME) : (DEFAULT_PLAYING_TIME))
 
 typedef enum {
        BUFFER_TYPE_DEFAULT,
        BUFFER_TYPE_MUXED = BUFFER_TYPE_DEFAULT,        /* queue2 */
-       BUFFER_TYPE_DEMUXED,            /* multi Q in decodebin */
+       BUFFER_TYPE_DEMUXED,            /* multi Q in decodebin */
        BUFFER_TYPE_MAX,
 } BufferType;
 
@@ -99,18 +95,16 @@ typedef enum {
        MUXED_BUFFER_TYPE_FILE, /* pull mode in queue2 */
 } muxed_buffer_type_e;
 
-typedef struct
-{
+typedef struct {
        MMPlayerBufferingMode mode;
        gboolean is_pre_buffering;
        gint initial_second;
        gint runtime_second;
 
-}streaming_requirement_t;
+} streaming_requirement_t;
 
-typedef struct
-{
-       GstElement* buffer;             /* buffering element of playback pipeline */
+typedef struct {
+       GstElement* buffer;                     /* buffering element of playback pipeline */
 
        guint buffering_bytes;
        gdouble buffering_time;         // mq : max buffering time value till now
@@ -118,26 +112,24 @@ typedef struct
        gdouble buffer_low_percent;
 
        gboolean is_live;
-}streaming_buffer_t;
+} streaming_buffer_t;
 
-typedef struct
-{
+typedef struct {
        gboolean buffering_monitor;
-       gint64  prev_pos;
+       gint64 prev_pos;
        gdouble buffering_time; // DEFAULT_BUFFERING_TIME
-}streaming_default_t;
+} streaming_default_t;
 
-typedef struct
-{
+typedef struct {
        BufferType      streaming_buffer_type;
-       streaming_buffer_t buffer_handle[BUFFER_TYPE_MAX];      /* front buffer : queue2 */
+       streaming_buffer_t buffer_handle[BUFFER_TYPE_MAX];      /* front buffer : queue2 */
 
        streaming_requirement_t buffering_req;
        streaming_default_t default_val;
 
        gboolean        is_buffering;
        gboolean        is_buffering_done;      /* get info from bus sync callback */
-       gboolean        is_adaptive_streaming;
+       gboolean        is_adaptive_streaming;
 
        gint            buffering_percent;
 
@@ -146,14 +138,14 @@ typedef struct
        gboolean        need_update;
        gboolean        need_sync;
        gint            ring_buffer_size;
-}mm_player_streaming_t;
+} mm_player_streaming_t;
 
 
-mm_player_streaming_t *__mm_player_streaming_create (void);
-void __mm_player_streaming_initialize (mm_player_streaming_t* streaming_player);
-void __mm_player_streaming_deinitialize (mm_player_streaming_t* streaming_player);
+mm_player_streaming_t *__mm_player_streaming_create(void);
+void __mm_player_streaming_initialize(mm_player_streaming_t* streaming_player);
+void __mm_player_streaming_deinitialize(mm_player_streaming_t* streaming_player);
 void __mm_player_streaming_destroy(mm_player_streaming_t* streaming_player);
-void __mm_player_streaming_set_queue2(         mm_player_streaming_t* streamer,
+void __mm_player_streaming_set_queue2(mm_player_streaming_t* streamer,
                                                                                GstElement* buffer,
                                                                                gboolean use_buffering,
                                                                                guint buffering_bytes,
@@ -163,14 +155,14 @@ void __mm_player_streaming_set_queue2(    mm_player_streaming_t* streamer,
                                                                                muxed_buffer_type_e type,
                                                                                gchar* file_path,
                                                                                guint64 content_size);
-void __mm_player_streaming_set_multiqueue(     mm_player_streaming_t* streamer,
+void __mm_player_streaming_set_multiqueue(mm_player_streaming_t* streamer,
                                                                                GstElement* buffer,
                                                                                gboolean use_buffering,
                                                                                gdouble buffering_time,
                                                                                gdouble low_percent,
                                                                                gdouble high_percent);
 void __mm_player_streaming_sync_property(mm_player_streaming_t* streamer, GstElement* decodebin);
-void __mm_player_streaming_buffering( mm_player_streaming_t* streamer,
+void __mm_player_streaming_buffering(mm_player_streaming_t* streamer,
                                                                          GstMessage *buffering_msg,
                                                                          guint64 content_size,
                                                                          gint64 position,
index dbf1e8b..c9f1bdc 100644 (file)
@@ -51,7 +51,7 @@ int _mmplayer_get_track_language_code(MMHandleType hplayer, MMPlayerTrackType ty
 
 int _mmplayer_get_current_track(MMHandleType hplayer, MMPlayerTrackType type, int *index);
 #ifdef _MULTI_TRACK
-int _mmplayer_track_foreach_selected_subtitle_language(MMHandleType hplayer,_mmplayer_track_selected_subtitle_language_cb callback, void *user_data);
+int _mmplayer_track_foreach_selected_subtitle_language(MMHandleType hplayer, _mmplayer_track_selected_subtitle_language_cb callback, void *user_data);
 #endif
 #ifdef __cplusplus
        }
index 94da65c..41fec00 100644 (file)
 
 /* general */
 #ifndef ARRAY_SIZE
-#define ARRAY_SIZE(arr)                (sizeof(arr) / sizeof((arr)[0]))
+#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
 #endif
 
-#define MMPLAYER_MAX_INT       (2147483647)
+#define MMPLAYER_MAX_INT (2147483647)
 
 #define MMPLAYER_FREEIF(x) \
-if ( x ) \
-       g_free( x ); \
+if (x) \
+       g_free(x); \
 x = NULL;
 
 #define MMPLAYER_CMD_LOCK(x_player) g_mutex_lock(&((mm_player_t *)x_player)->cmd_lock)
-#define MMPLAYER_CMD_UNLOCK(x_player)  g_mutex_unlock( &((mm_player_t*)x_player)->cmd_lock )
+#define MMPLAYER_CMD_UNLOCK(x_player) g_mutex_unlock(&((mm_player_t*)x_player)->cmd_lock)
 #define MMPLAYER_PLAYBACK_LOCK(x_player) g_mutex_lock(&((mm_player_t *)x_player)->playback_lock)
-#define MMPLAYER_PLAYBACK_UNLOCK(x_player) g_mutex_unlock( &((mm_player_t*)x_player)->playback_lock )
-#define MMPLAYER_GET_ATTRS(x_player)           ((mm_player_t*)x_player)->attrs
+#define MMPLAYER_PLAYBACK_UNLOCK(x_player) g_mutex_unlock(&((mm_player_t*)x_player)->playback_lock)
+#define MMPLAYER_GET_ATTRS(x_player) ((mm_player_t*)x_player)->attrs
 
 #if 0
 #define MMPLAYER_FENTER();                                     LOGD("<ENTER>");
@@ -70,198 +70,184 @@ x = NULL;
 
 /* element linking */
 #ifdef GST_EXT_PAD_LINK_UNCHECKED
-#define GST_ELEMENT_LINK_FILTERED      gst_element_link_filtered_unchecked
-#define GST_ELEMENT_LINK_MANY          gst_element_link_many_unchecked
-#define GST_ELEMENT_LINK                       gst_element_link_unchecked
-#define GST_ELEMENT_LINK_PADS          gst_element_link_pads_unchecked
-#define GST_PAD_LINK                           gst_pad_link_unchecked
+#define GST_ELEMENT_LINK_FILTERED      gst_element_link_filtered_unchecked
+#define GST_ELEMENT_LINK_MANY          gst_element_link_many_unchecked
+#define GST_ELEMENT_LINK                       gst_element_link_unchecked
+#define GST_ELEMENT_LINK_PADS          gst_element_link_pads_unchecked
+#define GST_PAD_LINK                           gst_pad_link_unchecked
 #else
-#define GST_ELEMENT_LINK_FILTERED      gst_element_link_filtered
-#define GST_ELEMENT_LINK_MANY          gst_element_link_many
-#define GST_ELEMENT_LINK                       gst_element_link
-#define GST_ELEMENT_UNLINK                     gst_element_unlink
-#define GST_ELEMENT_LINK_PADS          gst_element_link_pads
-#define GST_PAD_LINK                           gst_pad_link
+#define GST_ELEMENT_LINK_FILTERED      gst_element_link_filtered
+#define GST_ELEMENT_LINK_MANY          gst_element_link_many
+#define GST_ELEMENT_LINK                       gst_element_link
+#define GST_ELEMENT_UNLINK                     gst_element_unlink
+#define GST_ELEMENT_LINK_PADS          gst_element_link_pads
+#define GST_PAD_LINK                           gst_pad_link
 #endif
 
 #define MMPLAYER_RETURN_IF_FAIL(expr) \
-               if(!(expr)) { \
-                       LOGW("faild [%s]", #expr); \
-                       return; \
-               }
+if (!(expr)) { \
+       LOGW("faild [%s]", #expr); \
+       return; \
+}
 
 #define MMPLAYER_RETURN_VAL_IF_FAIL(expr, var) \
-               if(!(expr)) { \
-                       LOGW("faild [%s]", #expr); \
-                       return (var); \
-               }
+if (!(expr)) { \
+       LOGW("faild [%s]", #expr); \
+       return (var); \
+}
 
 /* debug caps string */
 #define MMPLAYER_LOG_GST_CAPS_TYPE(x_caps) \
-do \
-{ \
+do { \
        gchar* caps_type = NULL; \
        caps_type = gst_caps_to_string(x_caps); \
-       LOGD ("caps: %s\n", caps_type ); \
-       MMPLAYER_FREEIF (caps_type) \
+       LOGD("caps: %s\n", caps_type); \
+       MMPLAYER_FREEIF(caps_type) \
 } while (0)
 
 /* message posting */
-#define MMPLAYER_POST_MSG( x_player, x_msgtype, x_msg_param ) \
+#define MMPLAYER_POST_MSG(x_player, x_msgtype, x_msg_param) \
 LOGD("posting %s to application\n", #x_msgtype); \
 __mmplayer_post_message(x_player, x_msgtype, x_msg_param);
 
 /* setting player state */
-#define MMPLAYER_SET_STATE( x_player, x_state ) \
+#define MMPLAYER_SET_STATE(x_player, x_state) \
 LOGD("update state machine to %d\n", x_state); \
 __mmplayer_set_state(x_player, x_state);
 
-#define MMPLAYER_CHECK_STATE( x_player, x_command ) \
+#define MMPLAYER_CHECK_STATE(x_player, x_command) \
 LOGD("checking player state before doing %s\n", #x_command); \
-switch ( __mmplayer_check_state(x_player, x_command) ) \
-{ \
-       case MM_ERROR_PLAYER_INVALID_STATE: \
-               return MM_ERROR_PLAYER_INVALID_STATE; \
+switch (__mmplayer_check_state(x_player, x_command)) { \
+case MM_ERROR_PLAYER_INVALID_STATE: \
+       return MM_ERROR_PLAYER_INVALID_STATE; \
        break; \
        /* NOTE : for robustness of player. we won't treat it as an error */ \
-       case MM_ERROR_PLAYER_NO_OP: \
-               return MM_ERROR_NONE; \
+case MM_ERROR_PLAYER_NO_OP: \
+       return MM_ERROR_NONE; \
        break; \
-       case MM_ERROR_PLAYER_DOING_SEEK: \
-               return MM_ERROR_PLAYER_DOING_SEEK; \
-       default: \
+case MM_ERROR_PLAYER_DOING_SEEK: \
+       return MM_ERROR_PLAYER_DOING_SEEK; \
+default: \
        break; \
 }
 
 /* setting element state */
-#define MMPLAYER_ELEMENT_SET_STATE( x_element, x_state ) \
-LOGD("setting state [%s:%d] to [%s]\n", #x_state, x_state, GST_ELEMENT_NAME( x_element ) ); \
-if ( GST_STATE_CHANGE_FAILURE == gst_element_set_state ( x_element, x_state) ) \
-{ \
-       LOGE("failed to set state %s to %s\n", #x_state, GST_ELEMENT_NAME( x_element )); \
+#define MMPLAYER_ELEMENT_SET_STATE(x_element, x_state) \
+LOGD("setting state [%s:%d] to [%s]\n", #x_state, x_state, GST_ELEMENT_NAME(x_element)); \
+if (GST_STATE_CHANGE_FAILURE == gst_element_set_state(x_element, x_state)) { \
+       LOGE("failed to set state %s to %s\n", #x_state, GST_ELEMENT_NAME(x_element)); \
        goto STATE_CHANGE_FAILED; \
 }
 
-#define MMPLAYER_CHECK_NULL( x_var ) \
-if ( ! x_var ) \
-{ \
-       LOGE("[%s] is NULL\n", #x_var ); \
+#define MMPLAYER_CHECK_NULL(x_var) \
+if (!x_var) { \
+       LOGE("[%s] is NULL\n", #x_var); \
        goto ERROR; \
 }
 
-#define MMPLAYER_CHECK_CMD_IF_EXIT( x_player ) \
-if ( x_player->cmd == MMPLAYER_COMMAND_UNREALIZE || x_player->cmd == MMPLAYER_COMMAND_DESTROY ) \
-{ \
+#define MMPLAYER_CHECK_CMD_IF_EXIT(x_player) \
+if (x_player->cmd == MMPLAYER_COMMAND_UNREALIZE || x_player->cmd == MMPLAYER_COMMAND_DESTROY) { \
        LOGD("it's exit state...\n");\
        goto ERROR;  \
 }
 
 /* generating dot */
-#define MMPLAYER_GENERATE_DOT_IF_ENABLED( x_player, x_name ) \
-if ( x_player->ini.generate_dot ) \
-{ \
-       GST_DEBUG_BIN_TO_DOT_FILE (GST_BIN (player->pipeline->mainbin[MMPLAYER_M_PIPE].gst), \
+#define MMPLAYER_GENERATE_DOT_IF_ENABLED(x_player, x_name) \
+if (x_player->ini.generate_dot) { \
+       GST_DEBUG_BIN_TO_DOT_FILE(GST_BIN(player->pipeline->mainbin[MMPLAYER_M_PIPE].gst), \
        GST_DEBUG_GRAPH_SHOW_ALL, x_name); \
 }
 
 /* signal manipulation */
-#define MMPLAYER_SIGNAL_CONNECT( x_player, x_object, x_type, x_signal, x_callback, x_arg ) \
-do \
-{ \
+#define MMPLAYER_SIGNAL_CONNECT(x_player, x_object, x_type, x_signal, x_callback, x_arg) \
+do { \
        MMPlayerSignalItem* item = NULL; \
-       item = (MMPlayerSignalItem*) g_malloc( sizeof (MMPlayerSignalItem) ); \
-       if ( ! item ) \
-       { \
-               LOGE("cannot connect signal [%s]\n", x_signal ); \
-       } \
-       else \
-       { \
-               item->obj = G_OBJECT( x_object ); \
-               item->sig = g_signal_connect( G_OBJECT(x_object), x_signal, \
-                                       x_callback, x_arg ); \
+       item = (MMPlayerSignalItem*) g_malloc(sizeof(MMPlayerSignalItem)); \
+       if (!item) { \
+               LOGE("cannot connect signal [%s]\n", x_signal); \
+       } else { \
+               item->obj = G_OBJECT(x_object); \
+               item->sig = g_signal_connect(G_OBJECT(x_object), x_signal, \
+                                       x_callback, x_arg); \
                if ((x_type >= MM_PLAYER_SIGNAL_TYPE_AUTOPLUG) && (x_type < MM_PLAYER_SIGNAL_TYPE_MAX)) \
                        x_player->signals[x_type] = g_list_append(x_player->signals[x_type], item); \
                else \
-                       LOGE("wrong signal type [%d]\n", x_type ); \
+                       LOGE("wrong signal type [%d]\n", x_type); \
        } \
-} while ( 0 );
+} while (0);
 
 /* release element resource */
-#define MMPLAYER_RELEASE_ELEMENT( x_player, x_bin, x_id ) \
-do \
-{ \
-       if (x_bin[x_id].gst) \
-       { \
+#define MMPLAYER_RELEASE_ELEMENT(x_player, x_bin, x_id) \
+do { \
+       if (x_bin[x_id].gst) { \
                gst_element_set_state(x_bin[x_id].gst, GST_STATE_NULL); \
                gst_bin_remove(GST_BIN(x_player->pipeline->mainbin[MMPLAYER_M_PIPE].gst), x_bin[x_id].gst); \
                x_bin[x_id].gst = NULL; \
                LOGD("release done [element %d]", x_id); \
        } \
-} while ( 0 )
+} while (0)
 
 /* state */
-#define        MMPLAYER_PREV_STATE(x_player)           ((mm_player_t*)x_player)->prev_state
-#define        MMPLAYER_CURRENT_STATE(x_player)                ((mm_player_t*)x_player)->state
-#define        MMPLAYER_PENDING_STATE(x_player)                ((mm_player_t*)x_player)->pending_state
-#define        MMPLAYER_TARGET_STATE(x_player)         ((mm_player_t*)x_player)->target_state
-#define        MMPLAYER_STATE_GET_NAME(state) __get_state_name(state)
+#define        MMPLAYER_PREV_STATE(x_player) ((mm_player_t*)x_player)->prev_state
+#define        MMPLAYER_CURRENT_STATE(x_player) ((mm_player_t*)x_player)->state
+#define MMPLAYER_PENDING_STATE(x_player) ((mm_player_t*)x_player)->pending_state
+#define MMPLAYER_TARGET_STATE(x_player) ((mm_player_t*)x_player)->target_state
+#define MMPLAYER_STATE_GET_NAME(state) __get_state_name(state)
 
-#define        MMPLAYER_PRINT_STATE(x_player) \
+#define MMPLAYER_PRINT_STATE(x_player) \
 LOGD("-- prev %s, current %s, pending %s, target %s --\n", \
        MMPLAYER_STATE_GET_NAME(MMPLAYER_PREV_STATE(x_player)), \
-       MMPLAYER_STATE_GET_NAME(MMPLAYER_CURRENT_STATE(x_player)), \
+       MMPLAYER_STATE_GET_NAME(MMPLAYER_CURRENT_STATE(x_player)), \
        MMPLAYER_STATE_GET_NAME(MMPLAYER_PENDING_STATE(x_player)), \
        MMPLAYER_STATE_GET_NAME(MMPLAYER_TARGET_STATE(x_player)));
 
-#define        MMPLAYER_STATE_CHANGE_TIMEOUT(x_player )         ((mm_player_t*)x_player)->state_change_timeout
+#define MMPLAYER_STATE_CHANGE_TIMEOUT(x_player)         ((mm_player_t*)x_player)->state_change_timeout
 
 /* streaming */
-#define MMPLAYER_IS_STREAMING(x_player)                        __is_streaming(x_player)
-#define MMPLAYER_IS_RTSP_STREAMING(x_player)   __is_rtsp_streaming(x_player)
-#define MMPLAYER_IS_WFD_STREAMING(x_player)    __is_wfd_streaming(x_player)
-#define MMPLAYER_IS_HTTP_STREAMING(x_player)   __is_http_streaming(x_player)
-#define MMPLAYER_IS_HTTP_PD(x_player)                  __is_http_progressive_down(x_player)
-#define MMPLAYER_IS_HTTP_LIVE_STREAMING(x_player)  __is_http_live_streaming(x_player)
-#define MMPLAYER_IS_LIVE_STREAMING(x_player)   __is_live_streaming(x_player)
-#define MMPLAYER_IS_DASH_STREAMING(x_player)   __is_dash_streaming(x_player)
-#define MMPLAYER_IS_SMOOTH_STREAMING(x_player) __is_smooth_streaming(x_player)
-#define MMPLAYER_IS_MS_BUFF_SRC(x_player)              __is_ms_buff_src(x_player)
+#define MMPLAYER_IS_STREAMING(x_player) __is_streaming(x_player)
+#define MMPLAYER_IS_RTSP_STREAMING(x_player) __is_rtsp_streaming(x_player)
+#define MMPLAYER_IS_WFD_STREAMING(x_player) __is_wfd_streaming(x_player)
+#define MMPLAYER_IS_HTTP_STREAMING(x_player) __is_http_streaming(x_player)
+#define MMPLAYER_IS_HTTP_PD(x_player) __is_http_progressive_down(x_player)
+#define MMPLAYER_IS_HTTP_LIVE_STREAMING(x_player) __is_http_live_streaming(x_player)
+#define MMPLAYER_IS_LIVE_STREAMING(x_player) __is_live_streaming(x_player)
+#define MMPLAYER_IS_DASH_STREAMING(x_player) __is_dash_streaming(x_player)
+#define MMPLAYER_IS_SMOOTH_STREAMING(x_player) __is_smooth_streaming(x_player)
+#define MMPLAYER_IS_MS_BUFF_SRC(x_player) __is_ms_buff_src(x_player)
 
 #define MMPLAYER_URL_HAS_DASH_SUFFIX(x_player) __has_suffix(x_player, "mpd")
 #define MMPLAYER_URL_HAS_HLS_SUFFIX(x_player) __has_suffix(x_player, "m3u8")
 
 /* etc */
-#define        MMF_PLAYER_FILE_BACKUP_PATH             "/tmp/media_temp."
-#define        MMPLAYER_PT_IS_AUDIO( x_pt )            ( strstr(x_pt, "_97") || strstr(x_pt, "audio") )
-#define        MMPLAYER_PT_IS_VIDEO( x_pt )            ( strstr(x_pt, "_96") || strstr(x_pt, "video") )
+#define MMF_PLAYER_FILE_BACKUP_PATH "/tmp/media_temp."
+#define MMPLAYER_PT_IS_AUDIO(x_pt) (strstr(x_pt, "_97") || strstr(x_pt, "audio"))
+#define MMPLAYER_PT_IS_VIDEO(x_pt) (strstr(x_pt, "_96") || strstr(x_pt, "video"))
 
 #define MMPLAYER_VIDEO_SINK_CHECK(x_player) \
-do \
-{ \
-       MMPLAYER_RETURN_VAL_IF_FAIL ( x_player && \
+do { \
+       MMPLAYER_RETURN_VAL_IF_FAIL(x_player && \
                x_player->pipeline && \
                x_player->pipeline->videobin && \
                x_player->pipeline->videobin[MMPLAYER_V_SINK].gst, \
-               MM_ERROR_PLAYER_NOT_INITIALIZED ); \
-} while(0)
+               MM_ERROR_PLAYER_NOT_INITIALIZED); \
+} while (0)
 
-enum
-{
+enum {
        MMPLAYER_DISPLAY_NULL = 0,
        MMPLAYER_DISPLAY_HDMI_ACTIVE,
        MMPLAYER_DISPLAY_MIRRORING_ACTIVE,
 };
 
-bool util_is_sdp_file ( const char *path );
-int util_get_rank_increase ( const char *factory_class );
+bool util_is_sdp_file(const char *path);
+int util_get_rank_increase(const char *factory_class);
 int util_factory_rank_compare(GstPluginFeature *f1, GstPluginFeature *f2); // @
 int util_exist_file_path(const char *file_path);
 bool util_write_file_backup(const char *backup_path, char *data_ptr, int data_size);
 bool util_remove_file_backup(const char *backup_path); /* For Midi Player */
 int util_is_midi_type_by_mem(void *mem, int size);
 int util_is_midi_type_by_file(const char *file_path);
-char** util_get_cookie_list ( const char *cookies );
-bool util_check_valid_url ( const char *proxy );
+char** util_get_cookie_list(const char *cookies);
+bool util_check_valid_url(const char *proxy);
 const char* util_get_charset(const char *file_path);
 int util_get_pixtype(unsigned int fourcc);
 
index bbddf80..3869e4d 100644 (file)
@@ -65,7 +65,7 @@ _mmplayer_get_attribute(MMHandleType handle,  char **err_attr_name, const char *
 
        result = mm_attrs_get_valist(attrs, err_attr_name, attribute_name, args_list);
 
-       if ( result != MM_ERROR_NONE)
+       if (result != MM_ERROR_NONE)
                LOGE("failed to get %s attribute\n", attribute_name);
 
        return result;
@@ -87,15 +87,13 @@ _mmplayer_set_attribute(MMHandleType handle,  char **err_attr_name, const char *
        /* set attributes and commit them */
        result = mm_attrs_set_valist(attrs, err_attr_name, attribute_name, args_list);
 
-       if (result != MM_ERROR_NONE)
-       {
+       if (result != MM_ERROR_NONE) {
                LOGE("failed to set %s attribute\n", attribute_name);
                return result;
        }
 
        result = __mmplayer_apply_attribute(handle, attribute_name);
-       if (result != MM_ERROR_NONE)
-       {
+       if (result != MM_ERROR_NONE) {
                LOGE("failed to apply attributes\n");
                return result;
        }
@@ -118,8 +116,7 @@ _mmplayer_get_attributes_info(MMHandleType handle,  const char *attribute_name,
 
        result = mm_attrs_get_info_by_name(attrs, attribute_name, &src_info);
 
-       if ( result != MM_ERROR_NONE)
-       {
+       if (result != MM_ERROR_NONE) {
                LOGE("failed to get attribute info\n");
                return result;
        }
@@ -128,35 +125,34 @@ _mmplayer_get_attributes_info(MMHandleType handle,  const char *attribute_name,
 
        dst_info->type = src_info.type;
        dst_info->flag = src_info.flag;
-       dst_info->validity_type= src_info.validity_type;
+       dst_info->validity_type = src_info.validity_type;
 
-       switch(src_info.validity_type)
-       {
-               case MM_ATTRS_VALID_TYPE_INT_ARRAY:
-                       dst_info->int_array.array = src_info.int_array.array;
-                       dst_info->int_array.count = src_info.int_array.count;
-                       dst_info->int_array.d_val = src_info.int_array.dval;
+       switch (src_info.validity_type) {
+       case MM_ATTRS_VALID_TYPE_INT_ARRAY:
+               dst_info->int_array.array = src_info.int_array.array;
+               dst_info->int_array.count = src_info.int_array.count;
+               dst_info->int_array.d_val = src_info.int_array.dval;
                break;
 
-               case MM_ATTRS_VALID_TYPE_INT_RANGE:
-                       dst_info->int_range.min = src_info.int_range.min;
-                       dst_info->int_range.max = src_info.int_range.max;
-                       dst_info->int_range.d_val = src_info.int_range.dval;
+       case MM_ATTRS_VALID_TYPE_INT_RANGE:
+               dst_info->int_range.min = src_info.int_range.min;
+               dst_info->int_range.max = src_info.int_range.max;
+               dst_info->int_range.d_val = src_info.int_range.dval;
                break;
 
-               case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
-                       dst_info->double_array.array = src_info.double_array.array;
-                       dst_info->double_array.count = src_info.double_array.count;
-                       dst_info->double_array.d_val = src_info.double_array.dval;
+       case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
+               dst_info->double_array.array = src_info.double_array.array;
+               dst_info->double_array.count = src_info.double_array.count;
+               dst_info->double_array.d_val = src_info.double_array.dval;
                break;
 
-               case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
-                       dst_info->double_range.min = src_info.double_range.min;
-                       dst_info->double_range.max = src_info.double_range.max;
-                       dst_info->double_range.d_val = src_info.double_range.dval;
+       case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
+               dst_info->double_range.min = src_info.double_range.min;
+               dst_info->double_range.max = src_info.double_range.max;
+               dst_info->double_range.d_val = src_info.double_range.dval;
                break;
 
-               default:
+       default:
                break;
        }
 
@@ -174,10 +170,10 @@ __mmplayer_apply_attribute(MMHandleType handle, const char *attribute_name)
        player = MM_PLAYER_CAST(handle);
        MMPlayerGstPipelineInfo *pipeline = player->pipeline;
 
+       /* Currently, there are only display related implementation at below */
        if (!pipeline ||
                !pipeline->videobin ||
-               !pipeline->videobin[MMPLAYER_V_SINK].gst ) /* Currently, there are only display related implementation at below */
-       {
+               !pipeline->videobin[MMPLAYER_V_SINK].gst) {
                /*
                 * The attribute should be committed even though videobin is not created yet.
                 * So, true should be returned here.
@@ -186,8 +182,7 @@ __mmplayer_apply_attribute(MMHandleType handle, const char *attribute_name)
                return MM_ERROR_NONE;
        }
 
-       if ( g_strrstr(attribute_name, "display") || g_strrstr(attribute_name, "wl_window_render_x"))
-       {
+       if (g_strrstr(attribute_name, "display") || g_strrstr(attribute_name, "wl_window_render_x")) {
                char *param_name = NULL;
                int str_len = strlen(attribute_name);
                param_name = g_malloc0(str_len);
@@ -197,8 +192,7 @@ __mmplayer_apply_attribute(MMHandleType handle, const char *attribute_name)
                }
                strncpy(param_name, attribute_name, str_len);
                LOGD(" param_name: %s", param_name);
-               if ( MM_ERROR_NONE != _mmplayer_update_video_param( player, param_name))
-               {
+               if (MM_ERROR_NONE != _mmplayer_update_video_param(player, param_name)) {
                        g_free(param_name);
                        LOGE("failed to update video param");
                        return MM_ERROR_PLAYER_INTERNAL;
@@ -206,11 +200,10 @@ __mmplayer_apply_attribute(MMHandleType handle, const char *attribute_name)
                g_free(param_name);
        }
 
-       if (g_strrstr(attribute_name, MM_PLAYER_GAPLESS_MODE))
-       {
+       if (g_strrstr(attribute_name, MM_PLAYER_GAPLESS_MODE)) {
                int gapless = 0;
 
-               mm_attrs_get_int_by_name (player->attrs, "gapless_mode", &gapless);
+               mm_attrs_get_int_by_name(player->attrs, "gapless_mode", &gapless);
 
                if (gapless > 0) {
                        LOGD("disable last-sample at videosink");
@@ -230,12 +223,11 @@ _mmplayer_construct_attribute(MMHandleType handle)
        int num_of_attrs = 0;
        mmf_attrs_construct_info_t *base = NULL;
 
-       MMPLAYER_RETURN_VAL_IF_FAIL (handle, 0);
+       MMPLAYER_RETURN_VAL_IF_FAIL(handle, 0);
 
        player = MM_PLAYER_CAST(handle);
 
-       MMPlayerAttrsSpec player_attrs[] =
-       {
+       MMPlayerAttrsSpec player_attrs[] = {
                {
                        "profile_uri",                                  // name
                        MM_ATTRS_TYPE_STRING,           // type
@@ -1110,17 +1102,15 @@ _mmplayer_construct_attribute(MMHandleType handle)
 
        num_of_attrs = ARRAY_SIZE(player_attrs);
 
-       base = (mmf_attrs_construct_info_t* )malloc(num_of_attrs * sizeof(mmf_attrs_construct_info_t));
+       base = (mmf_attrs_construct_info_t*)malloc(num_of_attrs * sizeof(mmf_attrs_construct_info_t));
 
-       if ( !base )
-       {
+       if (!base) {
                LOGE("failed to alloc attrs constructor");
                return 0;
        }
 
        /* initialize values of attributes */
-       for ( idx = 0; idx < num_of_attrs; idx++ )
-       {
+       for (idx = 0; idx < num_of_attrs; idx++) {
                base[idx].name = player_attrs[idx].name;
                base[idx].value_type = player_attrs[idx].value_type;
                base[idx].flags = player_attrs[idx].flags;
@@ -1137,31 +1127,28 @@ _mmplayer_construct_attribute(MMHandleType handle)
        /* clean */
        MMPLAYER_FREEIF(base);
 
-       if ( !attrs )
-       {
+       if (!attrs) {
                LOGE("failed to create player attrs");
                return 0;
        }
 
        /* set validity type and range */
-       for ( idx = 0; idx < num_of_attrs; idx++ )
-       {
-               switch ( player_attrs[idx].valid_type)
-               {
-                       case MM_ATTRS_VALID_TYPE_INT_RANGE:
-                       {
-                               mmf_attrs_set_valid_type (attrs, idx, MM_ATTRS_VALID_TYPE_INT_RANGE);
-                               mmf_attrs_set_valid_range (attrs, idx,
-                                               player_attrs[idx].value_min,
-                                               player_attrs[idx].value_max,
-                                               (int)(intptr_t)(player_attrs[idx].default_value));
-                       }
+       for (idx = 0; idx < num_of_attrs; idx++) {
+               switch (player_attrs[idx].valid_type) {
+               case MM_ATTRS_VALID_TYPE_INT_RANGE:
+               {
+                       mmf_attrs_set_valid_type(attrs, idx, MM_ATTRS_VALID_TYPE_INT_RANGE);
+                       mmf_attrs_set_valid_range(attrs, idx,
+                                       player_attrs[idx].value_min,
+                                       player_attrs[idx].value_max,
+                                       (int)(intptr_t)(player_attrs[idx].default_value));
+               }
                        break;
 
-                       case MM_ATTRS_VALID_TYPE_INT_ARRAY:
-                       case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
-                       case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
-                       default:
+               case MM_ATTRS_VALID_TYPE_INT_ARRAY:
+               case MM_ATTRS_VALID_TYPE_DOUBLE_ARRAY:
+               case MM_ATTRS_VALID_TYPE_DOUBLE_RANGE:
+               default:
                        break;
                }
        }
@@ -1177,11 +1164,10 @@ _mmplayer_deconstruct_attribute(MMHandleType handle) // @
 {
        mm_player_t *player = MM_PLAYER_CAST(handle);
 
-       MMPLAYER_RETURN_VAL_IF_FAIL ( player, FALSE );
+       MMPLAYER_RETURN_VAL_IF_FAIL(player, FALSE);
 
-       if (player->attrs)
-       {
-               mmf_attrs_free (player->attrs);
+       if (player->attrs) {
+               mmf_attrs_free(player->attrs);
                player->attrs = 0;
        }
 
index 3b560a5..0a4be16 100644 (file)
@@ -41,7 +41,7 @@ mm_player_get_foreach_present_supported_effect_type(MMHandleType hplayer, MMAudi
 
        MMPLAYER_FENTER();
 
-       MMPLAYER_RETURN_VAL_IF_FAIL ( hplayer, MM_ERROR_PLAYER_NOT_INITIALIZED );
+       MMPLAYER_RETURN_VAL_IF_FAIL(hplayer, MM_ERROR_PLAYER_NOT_INITIALIZED);
 
        player = MM_PLAYER_CAST(hplayer);
 
@@ -49,16 +49,16 @@ mm_player_get_foreach_present_supported_effect_type(MMHandleType hplayer, MMAudi
        /* (1) get current device list */
        result = mm_sound_get_current_device_list(flags, &device_list);
 
-       if ( result ) {
+       if (result) {
                LOGE("mm_sound_get_current_device_list() failed [%x]!!", result);
                MMPLAYER_FLEAVE();
                return result;
        }
 
        /* (2) get device handle of device list */
-       result = mm_sound_get_next_device (device_list, &device_h);
+       result = mm_sound_get_next_device(device_list, &device_h);
 
-       if ( result ) {
+       if (result) {
                LOGE("mm_sound_get_next_device() failed [%x]!!", result);
                MMPLAYER_FLEAVE();
                return result;
@@ -67,52 +67,37 @@ mm_player_get_foreach_present_supported_effect_type(MMHandleType hplayer, MMAudi
        /* (3) get device type */
        result = mm_sound_get_device_type(device_h, &device_type);
 
-       if ( result ) {
+       if (result) {
                LOGE("mm_sound_get_device_type() failed [%x]!!", result);
                MMPLAYER_FLEAVE();
                return result;
        }
 
-       /* preset */
-       if (effect_type == MM_AUDIO_EFFECT_TYPE_PRESET)
-       {
-               for ( i = 0; i < MM_AUDIO_EFFECT_PRESET_NUM; i++ )
-               {
-                       if (player->ini.audio_effect_preset_list[i] )
-                       {
+       if (effect_type == MM_AUDIO_EFFECT_TYPE_PRESET) {
+               /* preset */
+               for (i = 0; i < MM_AUDIO_EFFECT_PRESET_NUM; i++) {
+                       if (player->ini.audio_effect_preset_list[i]) {
                                if (device_type == MM_SOUND_DEVICE_TYPE_BUILTIN_SPEAKER &&
                                        player->ini.audio_effect_preset_earphone_only_list[i])
-                               {
                                        continue;
-                               }
-                               if (!foreach_cb(effect_type,i, user_data))
-                               {
+
+                               if (!foreach_cb(effect_type, i, user_data))
                                        goto CALLBACK_ERROR;
-                               }
                        }
                }
-       }
-       /* custom */
-       else if (effect_type == MM_AUDIO_EFFECT_TYPE_CUSTOM)
-       {
-               for ( i = 0; i < MM_AUDIO_EFFECT_CUSTOM_NUM; i++ )
-               {
-                       if (player->ini.audio_effect_custom_list[i] )
-                       {
+       } else if (effect_type == MM_AUDIO_EFFECT_TYPE_CUSTOM) {
+               /* custom */
+               for (i = 0; i < MM_AUDIO_EFFECT_CUSTOM_NUM; i++) {
+                       if (player->ini.audio_effect_custom_list[i]) {
                                if (device_type == MM_SOUND_DEVICE_TYPE_BUILTIN_SPEAKER &&
-                                       player->ini.audio_effect_custom_earphone_only_list[i])
-                               {
+                                       player->ini.audio_effect_custom_earphone_only_list[i]) {
                                        continue;
                                }
-                               if (!foreach_cb(effect_type,i, user_data))
-                               {
+                               if (!foreach_cb(effect_type, i, user_data))
                                        goto CALLBACK_ERROR;
-                               }
                        }
                }
-       }
-       else
-       {
+       } else {
                LOGE("invalid effect type(%d)", effect_type);
                result = MM_ERROR_INVALID_ARGUMENT;
        }
@@ -138,63 +123,48 @@ __mmplayer_set_harmony_effect(mm_player_t *player, GstElement *audio_effect_elem
 
        MMPLAYER_FENTER();
 
-       MMPLAYER_RETURN_VAL_IF_FAIL ( player, MM_ERROR_PLAYER_NOT_INITIALIZED );
-       MMPLAYER_RETURN_VAL_IF_FAIL ( audio_effect_element, MM_ERROR_INVALID_ARGUMENT );
+       MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
+       MMPLAYER_RETURN_VAL_IF_FAIL(audio_effect_element, MM_ERROR_INVALID_ARGUMENT);
 
        /* Custom EQ */
-       if( player->ini.audio_effect_custom_eq_band_num )
-       {
+       if (player->ini.audio_effect_custom_eq_band_num) {
                LOGD("pass custom EQ level list to audio effect plugin");
                /* set custom-equalizer level list */
                g_object_set(audio_effect_element, "custom-eq", player->audio_effect_info.custom_eq_level, NULL);
-       }
-       else
-       {
+       } else
                LOGW("no custom EQ");
-       }
 
        /* Custom Extension effects */
-       if( player->ini.audio_effect_custom_ext_num )
-       {
+       if (player->ini.audio_effect_custom_ext_num) {
                LOGD("pass custom extension level list to audio effect plugin");
                ext_effect_level_list = player->audio_effect_info.custom_ext_level_for_plugin;
                if (!ext_effect_level_list) {
-                       ext_effect_level_list = (gint*) malloc (sizeof(gint)*player->ini.audio_effect_custom_ext_num);
-                       if (!ext_effect_level_list)
-                       {
+                       ext_effect_level_list = (gint*) malloc(sizeof(gint)*player->ini.audio_effect_custom_ext_num);
+                       if (!ext_effect_level_list) {
                                LOGE("memory allocation for extension effect list failed");
                                return MM_ERROR_OUT_OF_MEMORY;
-                       }
-                       else
-                       {
-                               memset (ext_effect_level_list, 0, player->ini.audio_effect_custom_ext_num);
+                       } else {
+                               memset(ext_effect_level_list, 0, player->ini.audio_effect_custom_ext_num);
 
                                /* associate it to player handle */
                                player->audio_effect_info.custom_ext_level_for_plugin = ext_effect_level_list;
                        }
                }
 
-               while ( count < MM_AUDIO_EFFECT_CUSTOM_NUM )
-               {
-                       if ( player->ini.audio_effect_custom_list[count] )
-                       {
+               while (count < MM_AUDIO_EFFECT_CUSTOM_NUM) {
+                       if (player->ini.audio_effect_custom_list[count]) {
                                ext_effect_level_list[ext_level_index] = player->audio_effect_info.custom_ext_level[count-1];
                                ext_level_index++;
                                if (ext_level_index == player->ini.audio_effect_custom_ext_num)
-                               {
                                        break;
-                               }
                        }
                        count++;
                }
 
                /* set custom-extension effects level list */
                g_object_set(audio_effect_element, "custom-ext", ext_effect_level_list, NULL);
-       }
-       else
-       {
+       } else
                LOGW("no custom extension effect");
-       }
 
        /* order action to audio effect plugin */
        g_object_set(audio_effect_element, "filter-action", MM_AUDIO_EFFECT_TYPE_CUSTOM, NULL);
@@ -216,35 +186,26 @@ __mmplayer_is_earphone_only_effect_type(mm_player_t *player, MMAudioEffectType e
 
        MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
 
-       /* preset */
-       if (effect_type == MM_AUDIO_EFFECT_TYPE_PRESET)
-       {
-               if (player->ini.audio_effect_preset_earphone_only_list[effect])
-               {
+       if (effect_type == MM_AUDIO_EFFECT_TYPE_PRESET) {
+               /* preset */
+               if (player->ini.audio_effect_preset_earphone_only_list[effect]) {
                        LOGI("this preset effect(%d) is only available with earphone", effect);
                        result = TRUE;
                }
-       }
-       /* custom */
-       else if (effect_type == MM_AUDIO_EFFECT_TYPE_CUSTOM)
-       {
-               for (i = 1; i < MM_AUDIO_EFFECT_CUSTOM_NUM; i++) /* it starts from 1(except testing for EQ) */
-               {
-                       if (player->ini.audio_effect_custom_earphone_only_list[i])
-                       {
+       } else if (effect_type == MM_AUDIO_EFFECT_TYPE_CUSTOM) {
+               /* custom */
+               for (i = 1; i < MM_AUDIO_EFFECT_CUSTOM_NUM; i++) {
+                       /* it starts from 1(except testing for EQ) */
+                       if (player->ini.audio_effect_custom_earphone_only_list[i]) {
                                /* check if the earphone only custom effect was set */
-                               if (player->audio_effect_info.custom_ext_level[i-1])
-                               {
+                               if (player->audio_effect_info.custom_ext_level[i-1]) {
                                        LOGI("this custom effect(%d) is only available with earphone", i);
                                        result = TRUE;
                                }
                        }
                }
-       }
-       else
-       {
+       } else
                LOGE("invalid effect type(%d)", effect_type);
-       }
 
        MMPLAYER_FLEAVE();
 
@@ -252,7 +213,7 @@ __mmplayer_is_earphone_only_effect_type(mm_player_t *player, MMAudioEffectType e
 }
 
 int
-__mmplayer_audio_set_output_type (mm_player_t *player, MMAudioEffectType effect_type, int effect)
+__mmplayer_audio_set_output_type(mm_player_t *player, MMAudioEffectType effect_type, int effect)
 {
        GstElement *audio_effect_element = NULL;
        mm_sound_device_flags_e flags = MM_SOUND_DEVICE_ALL_FLAG;
@@ -271,16 +232,16 @@ __mmplayer_audio_set_output_type (mm_player_t *player, MMAudioEffectType effect_
        /* (1) get current device list */
        result = mm_sound_get_current_device_list(flags, &device_list);
 
-       if ( result ) {
+       if (result) {
                LOGE("mm_sound_get_current_device_list() failed [%x]!!", result);
                MMPLAYER_FLEAVE();
                return result;
        }
 
        /* (2) get device handle of device list */
-       result = mm_sound_get_next_device (device_list, &device_h);
+       result = mm_sound_get_next_device(device_list, &device_h);
 
-       if ( result ) {
+       if (result) {
                LOGE("mm_sound_get_next_device() failed [%x]!!", result);
                MMPLAYER_FLEAVE();
                return result;
@@ -289,45 +250,32 @@ __mmplayer_audio_set_output_type (mm_player_t *player, MMAudioEffectType effect_
        /* (3) get device type */
        result = mm_sound_get_device_type(device_h, &device_type);
 
-       if ( result ) {
+       if (result) {
                LOGE("mm_sound_get_device_type() failed [%x]!!", result);
                MMPLAYER_FLEAVE();
                return result;
        }
 
        /* SPEAKER case */
-       if (device_type == MM_SOUND_DEVICE_TYPE_BUILTIN_SPEAKER)
-       {
-               if ( MM_AUDIO_EFFECT_TYPE_SQUARE != effect_type ) {
-                       if (__mmplayer_is_earphone_only_effect_type(player, effect_type, effect))
-                       {
+       if (device_type == MM_SOUND_DEVICE_TYPE_BUILTIN_SPEAKER) {
+               if (MM_AUDIO_EFFECT_TYPE_SQUARE != effect_type) {
+                       if (__mmplayer_is_earphone_only_effect_type(player, effect_type, effect)) {
                                LOGE("earphone is not equipped, this filter will not be applied");
                                MMPLAYER_FLEAVE();
                                return MM_ERROR_PLAYER_SOUND_EFFECT_INVALID_STATUS;
                        }
                }
-
                output_type = MM_AUDIO_EFFECT_OUTPUT_SPK;
-       }
-       else if (device_type == MM_SOUND_DEVICE_TYPE_MIRRORING)
-       {
+       } else if (device_type == MM_SOUND_DEVICE_TYPE_MIRRORING) {
                output_type = MM_AUDIO_EFFECT_OUTPUT_OTHERS;
-       }
-       else if (device_type == MM_SOUND_DEVICE_TYPE_HDMI)
-       {
+       } else if (device_type == MM_SOUND_DEVICE_TYPE_HDMI) {
                output_type = MM_AUDIO_EFFECT_OUTPUT_HDMI;
-       }
-       else if (device_type == MM_SOUND_DEVICE_TYPE_BLUETOOTH)
-       {
+       } else if (device_type == MM_SOUND_DEVICE_TYPE_BLUETOOTH) {
                output_type = MM_AUDIO_EFFECT_OUTPUT_BT;
-       }
-       else if (device_type == MM_SOUND_DEVICE_TYPE_USB_AUDIO)
-       {
+       } else if (device_type == MM_SOUND_DEVICE_TYPE_USB_AUDIO) {
                output_type = MM_AUDIO_EFFECT_OUTPUT_USB_AUDIO;
-       }
-       /* Other case, include WIRED_ACCESSORY */
-       else
-       {
+       } else {
+               /* Other case, include WIRED_ACCESSORY */
                output_type = MM_AUDIO_EFFECT_OUTPUT_EAR;
        }
        LOGW("output_type = %d (0:spk,1:ear,2:others)", output_type);
@@ -360,7 +308,7 @@ _mmplayer_is_supported_effect_type(mm_player_t* player, MMAudioEffectType effect
        }
 
        /* (2) get device handle of device list */
-       ret = mm_sound_get_next_device (device_list, &device_h);
+       ret = mm_sound_get_next_device(device_list, &device_h);
 
        if (ret) {
                LOGE("mm_sound_get_next_device() failed [%x]!!", ret);
@@ -378,65 +326,43 @@ _mmplayer_is_supported_effect_type(mm_player_t* player, MMAudioEffectType effect
        }
 
        /* preset */
-       if (effect_type == MM_AUDIO_EFFECT_TYPE_PRESET)
-       {
-               if ( effect < MM_AUDIO_EFFECT_PRESET_AUTO || effect >= MM_AUDIO_EFFECT_PRESET_NUM )
-               {
+       if (effect_type == MM_AUDIO_EFFECT_TYPE_PRESET) {
+               if (effect < MM_AUDIO_EFFECT_PRESET_AUTO || effect >= MM_AUDIO_EFFECT_PRESET_NUM) {
                        LOGE("out of range, preset effect(%d)", effect);
                        result = FALSE;
-               }
-               else
-               {
-                       if (!player->ini.audio_effect_preset_list[effect])
-                       {
+               } else {
+                       if (!player->ini.audio_effect_preset_list[effect]) {
                                LOGE("this effect(%d) is not supported", effect);
                                result = FALSE;
-                       }
-                       else
-                       {
+                       } else {
                                if (device_type == MM_SOUND_DEVICE_TYPE_BUILTIN_SPEAKER &&
-                                               player->ini.audio_effect_preset_earphone_only_list[effect])
-                               {
+                                               player->ini.audio_effect_preset_earphone_only_list[effect]) {
                                        result = FALSE;
                                }
                        }
                }
-       }
-       /* custom */
-       else if (effect_type == MM_AUDIO_EFFECT_TYPE_CUSTOM)
-       {
-               if ( effect < MM_AUDIO_EFFECT_CUSTOM_EQ || effect >= MM_AUDIO_EFFECT_CUSTOM_NUM )
-               {
+       } else if (effect_type == MM_AUDIO_EFFECT_TYPE_CUSTOM) {
+               /* custom */
+               if (effect < MM_AUDIO_EFFECT_CUSTOM_EQ || effect >= MM_AUDIO_EFFECT_CUSTOM_NUM) {
                        LOGE("out of range, custom effect(%d)", effect);
                        result = FALSE;
-               }
-               else
-               {
-                       if (!player->ini.audio_effect_custom_list[effect])
-                       {
+               } else {
+                       if (!player->ini.audio_effect_custom_list[effect]) {
                                LOGE("this custom effect(%d) is not supported", effect);
                                result = FALSE;
-                       }
-                       else
-                       {
+                       } else {
                                if (device_type == MM_SOUND_DEVICE_TYPE_BUILTIN_SPEAKER &&
-                                               player->ini.audio_effect_custom_earphone_only_list[effect])
-                               {
+                                               player->ini.audio_effect_custom_earphone_only_list[effect]) {
                                        result = FALSE;
                                }
                        }
                }
-       }
-       else if (effect_type == MM_AUDIO_EFFECT_TYPE_SQUARE)
-       {
-               if (!player->ini.use_audio_effect_custom)
-               {
+       } else if (effect_type == MM_AUDIO_EFFECT_TYPE_SQUARE) {
+               if (!player->ini.use_audio_effect_custom) {
                        LOGE("Square effect is not supported");
                        result = FALSE;
                }
-       }
-       else
-       {
+       } else {
                LOGE("invalid effect type(%d)", effect_type);
                result = FALSE;
        }
@@ -455,34 +381,29 @@ _mmplayer_audio_effect_custom_apply(mm_player_t *player)
 
        MMPLAYER_FENTER();
 
-       MMPLAYER_RETURN_VAL_IF_FAIL( player, MM_ERROR_PLAYER_NOT_INITIALIZED );
+       MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
 
        /* Music Player can set audio effect value before Audiobin is created. */
-       if ( !player->pipeline || !player->pipeline->audiobin || !player->pipeline->audiobin[MMPLAYER_A_FILTER].gst )
-       {
+       if (!player->pipeline || !player->pipeline->audiobin || !player->pipeline->audiobin[MMPLAYER_A_FILTER].gst) {
                LOGW("effect element is not created yet.");
-
                player->bypass_audio_effect = FALSE;
 
                /* store audio effect setting in order to apply it when audio effect plugin is created */
                player->audio_effect_info.effect_type = MM_AUDIO_EFFECT_TYPE_CUSTOM;
-       }
-       else
-       {
+       } else {
                audio_effect_element = player->pipeline->audiobin[MMPLAYER_A_FILTER].gst;
 
                /* get status if speaker is activated */
                result = __mmplayer_audio_set_output_type(player, MM_AUDIO_EFFECT_TYPE_CUSTOM, 0);
 
-               if ( result != MM_ERROR_NONE) {
+               if (result != MM_ERROR_NONE) {
                        LOGE("failed to set output mode");
                        MMPLAYER_FLEAVE();
                        return result;
                }
 
                result = __mmplayer_set_harmony_effect(player, audio_effect_element);
-               if ( result )
-               {
+               if (result) {
                        LOGE("_set_harmony_effect() failed(%x)", result);
                        MMPLAYER_FLEAVE();
                        return result;
@@ -508,7 +429,7 @@ _mmplayer_audio_effect_custom_update_level(mm_player_t *player)
 
        MMPLAYER_FENTER();
 
-       MMPLAYER_RETURN_VAL_IF_FAIL( player, MM_ERROR_PLAYER_NOT_INITIALIZED );
+       MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
 
        audio_effect_element = player->pipeline->audiobin[MMPLAYER_A_FILTER].gst;
 
@@ -517,19 +438,15 @@ _mmplayer_audio_effect_custom_update_level(mm_player_t *player)
 
        memcpy(player->audio_effect_info.custom_eq_level, custom_eq, sizeof(gint) * player->ini.audio_effect_custom_eq_band_num);
 
-       for (i=0; i<player->ini.audio_effect_custom_eq_band_num;i++)
-       {
+       for (i = 0; i < player->ini.audio_effect_custom_eq_band_num; i++)
                LOGD("updated custom-eq [%d] = %d", i, player->audio_effect_info.custom_eq_level[i]);
-       }
 
        /* get custom ext effect */
 
        g_object_get(audio_effect_element, "custom-ext", &custom_ext_effect_level_list, NULL);
 
-       while ( count < MM_AUDIO_EFFECT_CUSTOM_NUM )
-       {
-               if ( player->ini.audio_effect_custom_list[count] )
-               {
+       while (count < MM_AUDIO_EFFECT_CUSTOM_NUM) {
+               if (player->ini.audio_effect_custom_list[count]) {
                        player->audio_effect_info.custom_ext_level[count-1]
                                = custom_ext_effect_level_list[ext_level_index];
                        LOGD("updated custom-ext [%d] = %d", count, player->audio_effect_info.custom_ext_level[count-1]);
@@ -577,10 +494,8 @@ mm_player_audio_effect_custom_clear_ext_all(MMHandleType hplayer)
        MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
 
        /* clear ALL custom effects, except EQ */
-       for ( i = 0 ; i < MM_AUDIO_EFFECT_CUSTOM_NUM - 1 ; i++ )
-       {
+       for (i = 0 ; i < MM_AUDIO_EFFECT_CUSTOM_NUM - 1 ; i++)
                player->audio_effect_info.custom_ext_level[i] = MM_AUDIO_EFFECT_CUSTOM_LEVEL_INIT;
-       }
 
        LOGI("All the extension effects clearing success");
 
@@ -600,10 +515,8 @@ mm_player_is_supported_preset_effect_type(MMHandleType hplayer, MMAudioEffectPre
 
        MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
 
-       if ( !_mmplayer_is_supported_effect_type( player, MM_AUDIO_EFFECT_TYPE_PRESET, effect ) )
-       {
+       if (!_mmplayer_is_supported_effect_type(player, MM_AUDIO_EFFECT_TYPE_PRESET, effect))
                result = MM_ERROR_PLAYER_SOUND_EFFECT_NOT_SUPPORTED_FILTER;
-       }
 
        MMPLAYER_FLEAVE();
 
@@ -621,10 +534,8 @@ mm_player_is_supported_custom_effect_type(MMHandleType hplayer, MMAudioEffectCus
 
        MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
 
-       if ( !_mmplayer_is_supported_effect_type( player, MM_AUDIO_EFFECT_TYPE_CUSTOM, effect ) )
-       {
+       if (!_mmplayer_is_supported_effect_type(player, MM_AUDIO_EFFECT_TYPE_CUSTOM, effect))
                result = MM_ERROR_PLAYER_SOUND_EFFECT_NOT_SUPPORTED_FILTER;
-       }
 
        MMPLAYER_FLEAVE();
 
@@ -641,8 +552,7 @@ mm_player_audio_effect_custom_apply(MMHandleType hplayer)
 
        MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
 
-       if (!player->ini.use_audio_effect_custom)
-       {
+       if (!player->ini.use_audio_effect_custom) {
                LOGE("audio effect(custom) is not supported");
                MMPLAYER_FLEAVE();
                return MM_ERROR_NOT_SUPPORT_API;
@@ -657,7 +567,7 @@ mm_player_audio_effect_custom_apply(MMHandleType hplayer)
 
 
 int
-mm_player_audio_effect_bypass (MMHandleType hplayer)
+mm_player_audio_effect_bypass(MMHandleType hplayer)
 {
        mm_player_t* player = (mm_player_t*)hplayer;
        int result = MM_ERROR_NONE;
@@ -667,18 +577,14 @@ mm_player_audio_effect_bypass (MMHandleType hplayer)
 
        MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
 
-       if ( !player->ini.use_audio_effect_preset && !player->ini.use_audio_effect_custom )
-       {
+       if (!player->ini.use_audio_effect_preset && !player->ini.use_audio_effect_custom) {
                LOGE("audio effect(preset/custom) is not supported");
                MMPLAYER_FLEAVE();
                return MM_ERROR_NOT_SUPPORT_API;
        }
-       if ( !player->pipeline || !player->pipeline->audiobin || !player->pipeline->audiobin[MMPLAYER_A_FILTER].gst )
-       {
+       if (!player->pipeline || !player->pipeline->audiobin || !player->pipeline->audiobin[MMPLAYER_A_FILTER].gst) {
                LOGW("effect element is not created yet.");
-       }
-       else
-       {
+       } else {
                audio_effect_element = player->pipeline->audiobin[MMPLAYER_A_FILTER].gst;
 
                /* order action to audio effect plugin */
@@ -703,29 +609,24 @@ _mmplayer_audio_effect_custom_set_level_ext(mm_player_t *player, MMAudioEffectCu
 
        MMPLAYER_FENTER();
 
-       MMPLAYER_RETURN_VAL_IF_FAIL( player, MM_ERROR_PLAYER_NOT_INITIALIZED );
+       MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
 
        /* check if EQ is supported */
-       if ( !_mmplayer_is_supported_effect_type( player,  MM_AUDIO_EFFECT_TYPE_CUSTOM, custom_effect_type ) )
-       {
+       if (!_mmplayer_is_supported_effect_type(player,  MM_AUDIO_EFFECT_TYPE_CUSTOM, custom_effect_type)) {
                MMPLAYER_FLEAVE();
                return MM_ERROR_PLAYER_SOUND_EFFECT_NOT_SUPPORTED_FILTER;
        }
 
-       while ( count < MM_AUDIO_EFFECT_CUSTOM_NUM )
-       {
-               if ( player->ini.audio_effect_custom_list[count] )
-               {
-                       if ( count == custom_effect_type )
-                       {
+       while (count < MM_AUDIO_EFFECT_CUSTOM_NUM) {
+               if (player->ini.audio_effect_custom_list[count]) {
+                       if (count == custom_effect_type) {
                                effect_level_min = player->ini.audio_effect_custom_min_level_list[ext_level_index];
                                effect_level_max = player->ini.audio_effect_custom_max_level_list[ext_level_index];
                                LOGI("level min value(%d), level max value(%d)", effect_level_min, effect_level_max);
                                break;
                        }
                        ext_level_index++;
-                       if (ext_level_index == player->ini.audio_effect_custom_ext_num + 1)
-                       {
+                       if (ext_level_index == player->ini.audio_effect_custom_ext_num + 1) {
                                LOGE("could not find min, max value. maybe effect information in ini file is not proper for audio effect plugin");
                                break;
                        }
@@ -733,13 +634,10 @@ _mmplayer_audio_effect_custom_set_level_ext(mm_player_t *player, MMAudioEffectCu
                count++;
        }
 
-       if ( level < effect_level_min || level > effect_level_max )
-       {
+       if (level < effect_level_min || level > effect_level_max) {
                LOGE("out of range, level(%d)", level);
                result = MM_ERROR_INVALID_ARGUMENT;
-       }
-       else
-       {
+       } else {
                player->audio_effect_info.custom_ext_level[custom_effect_type-1] = level;
                LOGI("set ext[%d] = %d", custom_effect_type-1, level);
        }
@@ -759,33 +657,26 @@ _mmplayer_audio_effect_custom_set_level_eq(mm_player_t *player, int index, int l
 
        MMPLAYER_FENTER();
 
-       MMPLAYER_RETURN_VAL_IF_FAIL( player, MM_ERROR_PLAYER_NOT_INITIALIZED );
+       MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
 
        /* check if EQ is supported */
-       if ( !_mmplayer_is_supported_effect_type( player, MM_AUDIO_EFFECT_TYPE_CUSTOM, MM_AUDIO_EFFECT_CUSTOM_EQ ) )
-       {
+       if (!_mmplayer_is_supported_effect_type(player, MM_AUDIO_EFFECT_TYPE_CUSTOM, MM_AUDIO_EFFECT_CUSTOM_EQ)) {
                MMPLAYER_FLEAVE();
                return MM_ERROR_PLAYER_SOUND_EFFECT_NOT_SUPPORTED_FILTER;
        }
 
-       if ( index < 0 || index > player->ini.audio_effect_custom_eq_band_num - 1 )
-       {
+       if (index < 0 || index > player->ini.audio_effect_custom_eq_band_num - 1) {
                LOGE("out of range, index(%d)", index);
                result = MM_ERROR_INVALID_ARGUMENT;
-       }
-       else
-       {
+       } else {
                eq_level_min = player->ini.audio_effect_custom_min_level_list[MM_AUDIO_EFFECT_CUSTOM_EQ];
                eq_level_max = player->ini.audio_effect_custom_max_level_list[MM_AUDIO_EFFECT_CUSTOM_EQ];
                LOGI("EQ level min value(%d), EQ level max value(%d)", eq_level_min, eq_level_max);
 
-               if ( level < eq_level_min || level > eq_level_max )
-               {
+               if (level < eq_level_min || level > eq_level_max) {
                        LOGE("out of range, EQ level(%d)", level);
                        result =  MM_ERROR_INVALID_ARGUMENT;
-               }
-               else
-               {
+               } else {
                        player->audio_effect_info.custom_eq_level[index] = level;
                        LOGI("set EQ[%d] = %d", index, level);
                }
@@ -806,25 +697,17 @@ mm_player_audio_effect_custom_set_level(MMHandleType hplayer, MMAudioEffectCusto
 
        MMPLAYER_FENTER();
 
-       MMPLAYER_RETURN_VAL_IF_FAIL( player, MM_ERROR_PLAYER_NOT_INITIALIZED );
+       MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
 
        /* check if this effect type is supported */
-       if ( !_mmplayer_is_supported_effect_type( player, MM_AUDIO_EFFECT_TYPE_CUSTOM, effect_custom_type ) )
-       {
+       if (!_mmplayer_is_supported_effect_type(player, MM_AUDIO_EFFECT_TYPE_CUSTOM, effect_custom_type)) {
                result = MM_ERROR_PLAYER_SOUND_EFFECT_NOT_SUPPORTED_FILTER;
-       }
-       else
-       {
-               if (effect_custom_type == MM_AUDIO_EFFECT_CUSTOM_EQ)
-               {
+       } else {
+               if (effect_custom_type == MM_AUDIO_EFFECT_CUSTOM_EQ) {
                        result = _mmplayer_audio_effect_custom_set_level_eq(player, eq_index, level);
-               }
-               else if (effect_custom_type > MM_AUDIO_EFFECT_CUSTOM_EQ && effect_custom_type < MM_AUDIO_EFFECT_CUSTOM_NUM)
-               {
+               } else if (effect_custom_type > MM_AUDIO_EFFECT_CUSTOM_EQ && effect_custom_type < MM_AUDIO_EFFECT_CUSTOM_NUM) {
                        result = _mmplayer_audio_effect_custom_set_level_ext(player, effect_custom_type, level);
-               }
-               else
-               {
+               } else {
                        LOGE("out of range, effect type(%d)", effect_custom_type);
                        result = MM_ERROR_INVALID_ARGUMENT;
                }
@@ -844,11 +727,10 @@ mm_player_audio_effect_custom_get_eq_bands_number(MMHandleType hplayer, int *ban
 
        MMPLAYER_FENTER();
 
-       MMPLAYER_RETURN_VAL_IF_FAIL( player, MM_ERROR_PLAYER_NOT_INITIALIZED );
+       MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
 
        /* check if EQ is supported */
-       if ( !_mmplayer_is_supported_effect_type( player, MM_AUDIO_EFFECT_TYPE_CUSTOM, MM_AUDIO_EFFECT_CUSTOM_EQ ) )
-       {
+       if (!_mmplayer_is_supported_effect_type(player, MM_AUDIO_EFFECT_TYPE_CUSTOM, MM_AUDIO_EFFECT_CUSTOM_EQ)) {
                MMPLAYER_FLEAVE();
                return MM_ERROR_PLAYER_SOUND_EFFECT_NOT_SUPPORTED_FILTER;
        }
@@ -871,23 +753,19 @@ mm_player_audio_effect_custom_get_eq_bands_width(MMHandleType hplayer, int band_
 
        MMPLAYER_FENTER();
 
-       MMPLAYER_RETURN_VAL_IF_FAIL( player, MM_ERROR_PLAYER_NOT_INITIALIZED );
+       MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
 
        /* check if EQ is supported */
-       if ( !_mmplayer_is_supported_effect_type( player, MM_AUDIO_EFFECT_TYPE_CUSTOM, MM_AUDIO_EFFECT_CUSTOM_EQ ) )
-       {
+       if (!_mmplayer_is_supported_effect_type(player, MM_AUDIO_EFFECT_TYPE_CUSTOM, MM_AUDIO_EFFECT_CUSTOM_EQ)) {
                MMPLAYER_FLEAVE();
                return MM_ERROR_PLAYER_SOUND_EFFECT_NOT_SUPPORTED_FILTER;
        }
 
        eq_num = player->ini.audio_effect_custom_eq_band_num;
-       if (band_idx < 0 || band_idx > eq_num-1)
-       {
+       if (band_idx < 0 || band_idx > eq_num-1) {
                LOGE("out of range, invalid band_idx(%d)", band_idx);
                result = MM_ERROR_INVALID_ARGUMENT;
-       }
-       else
-       {
+       } else {
                /* set the width of EQ band */
                *width = player->ini.audio_effect_custom_eq_band_width[band_idx];
                LOGD("width of band_idx(%d) = %dHz", band_idx, *width);
@@ -908,23 +786,19 @@ mm_player_audio_effect_custom_get_eq_bands_freq(MMHandleType hplayer, int band_i
 
        MMPLAYER_FENTER();
 
-       MMPLAYER_RETURN_VAL_IF_FAIL( player, MM_ERROR_PLAYER_NOT_INITIALIZED );
+       MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
 
        /* check if EQ is supported */
-       if ( !_mmplayer_is_supported_effect_type( player, MM_AUDIO_EFFECT_TYPE_CUSTOM, MM_AUDIO_EFFECT_CUSTOM_EQ ) )
-       {
+       if (!_mmplayer_is_supported_effect_type(player, MM_AUDIO_EFFECT_TYPE_CUSTOM, MM_AUDIO_EFFECT_CUSTOM_EQ)) {
                MMPLAYER_FLEAVE();
                return MM_ERROR_PLAYER_SOUND_EFFECT_NOT_SUPPORTED_FILTER;
        }
 
        eq_num = player->ini.audio_effect_custom_eq_band_num;
-       if (band_idx < 0 || band_idx > eq_num-1)
-       {
+       if (band_idx < 0 || band_idx > eq_num-1) {
                LOGE("out of range, invalid band_idx(%d)", band_idx);
                result = MM_ERROR_INVALID_ARGUMENT;
-       }
-       else
-       {
+       } else {
                /* set the frequency of EQ band */
                *freq = player->ini.audio_effect_custom_eq_band_freq[band_idx];
                LOGD("frequency of band_idx(%d) = %dHz", band_idx, *freq);
@@ -944,36 +818,27 @@ mm_player_audio_effect_custom_get_level(MMHandleType hplayer, MMAudioEffectCusto
 
        MMPLAYER_FENTER();
 
-       MMPLAYER_RETURN_VAL_IF_FAIL( player, MM_ERROR_PLAYER_NOT_INITIALIZED );
-       MMPLAYER_RETURN_VAL_IF_FAIL( level, MM_ERROR_PLAYER_NOT_INITIALIZED );
+       MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
+       MMPLAYER_RETURN_VAL_IF_FAIL(level, MM_ERROR_PLAYER_NOT_INITIALIZED);
 
        /* check if this effect type is supported */
-       if ( !_mmplayer_is_supported_effect_type( player, MM_AUDIO_EFFECT_TYPE_CUSTOM, type ) )
-       {
+       if (!_mmplayer_is_supported_effect_type(player, MM_AUDIO_EFFECT_TYPE_CUSTOM, type)) {
                MMPLAYER_FLEAVE();
                return MM_ERROR_PLAYER_SOUND_EFFECT_NOT_SUPPORTED_FILTER;
        }
 
-       if (type == MM_AUDIO_EFFECT_CUSTOM_EQ)
-       {
-               if ( eq_index < 0 || eq_index > player->ini.audio_effect_custom_eq_band_num - 1 )
-               {
+       if (type == MM_AUDIO_EFFECT_CUSTOM_EQ) {
+               if (eq_index < 0 || eq_index > player->ini.audio_effect_custom_eq_band_num - 1) {
                        LOGE("out of range, EQ index(%d)", eq_index);
                        result = MM_ERROR_INVALID_ARGUMENT;
-               }
-               else
-               {
+               } else {
                        *level = player->audio_effect_info.custom_eq_level[eq_index];
                        LOGD("EQ index = %d, level = %d", eq_index, *level);
                }
-       }
-       else if ( type > MM_AUDIO_EFFECT_CUSTOM_EQ && type < MM_AUDIO_EFFECT_CUSTOM_NUM )
-       {
+       } else if (type > MM_AUDIO_EFFECT_CUSTOM_EQ && type < MM_AUDIO_EFFECT_CUSTOM_NUM) {
                *level = player->audio_effect_info.custom_ext_level[type-1];
                LOGD("extension effect index = %d, level = %d", type, *level);
-       }
-       else
-       {
+       } else {
                LOGE("out of range, type(%d)", type);
                result = MM_ERROR_INVALID_ARGUMENT;
        }
@@ -994,39 +859,31 @@ mm_player_audio_effect_custom_get_level_range(MMHandleType hplayer, MMAudioEffec
 
        MMPLAYER_FENTER();
 
-       MMPLAYER_RETURN_VAL_IF_FAIL( player, MM_ERROR_PLAYER_NOT_INITIALIZED );
-       MMPLAYER_RETURN_VAL_IF_FAIL( min, MM_ERROR_PLAYER_NOT_INITIALIZED );
-       MMPLAYER_RETURN_VAL_IF_FAIL( max, MM_ERROR_PLAYER_NOT_INITIALIZED );
+       MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
+       MMPLAYER_RETURN_VAL_IF_FAIL(min, MM_ERROR_PLAYER_NOT_INITIALIZED);
+       MMPLAYER_RETURN_VAL_IF_FAIL(max, MM_ERROR_PLAYER_NOT_INITIALIZED);
 
        /* check if this effect type is supported */
-       if ( !_mmplayer_is_supported_effect_type( player, MM_AUDIO_EFFECT_TYPE_CUSTOM, type ) )
-       {
+       if (!_mmplayer_is_supported_effect_type(player, MM_AUDIO_EFFECT_TYPE_CUSTOM, type)) {
                MMPLAYER_FLEAVE();
                return MM_ERROR_PLAYER_SOUND_EFFECT_NOT_SUPPORTED_FILTER;
        }
 
-       if ( type == MM_AUDIO_EFFECT_CUSTOM_EQ )
-       {
+       if (type == MM_AUDIO_EFFECT_CUSTOM_EQ) {
                *min = player->ini.audio_effect_custom_min_level_list[MM_AUDIO_EFFECT_CUSTOM_EQ];
                *max = player->ini.audio_effect_custom_max_level_list[MM_AUDIO_EFFECT_CUSTOM_EQ];
                LOGD("EQ min level = %d, max level = %d", *min, *max);
-       }
-       else
-       {
-               while ( count < MM_AUDIO_EFFECT_CUSTOM_NUM )
-               {
-                       if ( player->ini.audio_effect_custom_list[count] )
-                       {
-                               if ( count == type )
-                               {
+       } else {
+               while (count < MM_AUDIO_EFFECT_CUSTOM_NUM) {
+                       if (player->ini.audio_effect_custom_list[count]) {
+                               if (count == type) {
                                        *min = player->ini.audio_effect_custom_min_level_list[ext_level_index];
                                        *max = player->ini.audio_effect_custom_max_level_list[ext_level_index];
                                        LOGI("Extension effect(%d) min level = %d, max level = %d", count, *min, *max);
                                        break;
                                }
                                ext_level_index++;
-                               if ( ext_level_index == player->ini.audio_effect_custom_ext_num + 1 )
-                               {
+                               if (ext_level_index == player->ini.audio_effect_custom_ext_num + 1) {
                                        LOGE("could not find min, max value. maybe effect information in ini file is not proper for audio effect plugin");
                                        break;
                                }
@@ -1052,29 +909,23 @@ mm_player_audio_effect_custom_set_level_eq_from_list(MMHandleType hplayer, int *
 
        MMPLAYER_FENTER();
 
-       MMPLAYER_RETURN_VAL_IF_FAIL( player, MM_ERROR_PLAYER_NOT_INITIALIZED );
+       MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
 
        /* check if EQ is supported */
-       if ( !_mmplayer_is_supported_effect_type( player, MM_AUDIO_EFFECT_TYPE_CUSTOM, MM_AUDIO_EFFECT_CUSTOM_EQ ) )
-       {
+       if (!_mmplayer_is_supported_effect_type(player, MM_AUDIO_EFFECT_TYPE_CUSTOM, MM_AUDIO_EFFECT_CUSTOM_EQ)) {
                MMPLAYER_FLEAVE();
                return MM_ERROR_PLAYER_SOUND_EFFECT_NOT_SUPPORTED_FILTER;
        }
 
-       if ( size != player->ini.audio_effect_custom_eq_band_num )
-       {
+       if (size != player->ini.audio_effect_custom_eq_band_num) {
                LOGE("input size variable(%d) does not match with number of eq band(%d)", size, player->ini.audio_effect_custom_eq_band_num);
                result = MM_ERROR_INVALID_ARGUMENT;
-       }
-       else
-       {
+       } else {
                eq_level_min = player->ini.audio_effect_custom_min_level_list[MM_AUDIO_EFFECT_CUSTOM_EQ];
                eq_level_max = player->ini.audio_effect_custom_max_level_list[MM_AUDIO_EFFECT_CUSTOM_EQ];
 
-               for ( i = 0 ; i < size ; i++ )
-               {
-                       if ( level_list[i] < eq_level_min || level_list[i] > eq_level_max)
-                       {
+               for (i = 0 ; i < size ; i++) {
+                       if (level_list[i] < eq_level_min || level_list[i] > eq_level_max) {
                                LOGE("out of range, level[%d]=%d", i, level_list[i]);
                                result = MM_ERROR_INVALID_ARGUMENT;
                                break;
index f090664..4a8851c 100644 (file)
@@ -49,143 +49,140 @@ __pd_downloader_callback(GstBus *bus, GstMessage *msg, gpointer data)
        MMPLAYER_FENTER();
 
        /* chech player handle */
-       MMPLAYER_RETURN_VAL_IF_FAIL ( data, MM_ERROR_INVALID_ARGUMENT );
+       MMPLAYER_RETURN_VAL_IF_FAIL(data, MM_ERROR_INVALID_ARGUMENT);
 
        player = MM_PLAYER_CAST((MMHandleType)data);
 
        /* get PD downloader handle */
        pd = MM_PLAYER_GET_PD((MMHandleType)data);
 
-       MMPLAYER_RETURN_VAL_IF_FAIL ( pd, MM_ERROR_INVALID_ARGUMENT );
+       MMPLAYER_RETURN_VAL_IF_FAIL(pd, MM_ERROR_INVALID_ARGUMENT);
 
 //     g_print("%s\n", GST_MESSAGE_TYPE_NAME(msg));
 
-       switch ( GST_MESSAGE_TYPE( msg ) )
-       {
-               case GST_MESSAGE_EOS:
-                       {
-                               LOGD("PD Downloader EOS received....\n");
+       switch (GST_MESSAGE_TYPE(msg)) {
+       case GST_MESSAGE_EOS:
+               {
+                       LOGD("PD Downloader EOS received....\n");
 
-                               g_object_set (G_OBJECT (pd->playback_pipeline_src), "eos", TRUE, NULL);
+                       g_object_set(G_OBJECT(pd->playback_pipeline_src), "eos", TRUE, NULL);
 
-                               /* notify application that download is completed */
-                               __pd_downloader_post_message(player, MM_MESSAGE_PD_DOWNLOADER_END, NULL);
+                       /* notify application that download is completed */
+                       __pd_downloader_post_message(player, MM_MESSAGE_PD_DOWNLOADER_END, NULL);
 
-                               #ifdef PD_SELF_DOWNLOAD
-                               _mmplayer_unrealize_pd_downloader ((MMHandleType)data);
-                               #endif
-                       }
-                       break;
+                       #ifdef PD_SELF_DOWNLOAD
+                       _mmplayer_unrealize_pd_downloader((MMHandleType)data);
+                       #endif
+               }
+               break;
 
-               case GST_MESSAGE_ERROR:
-                       {
-                               GError *error = NULL;
-                               gchar* debug = NULL;
-                               GstMessage *new_msg = NULL;
+       case GST_MESSAGE_ERROR:
+               {
+                       GError *error = NULL;
+                       gchar* debug = NULL;
+                       GstMessage *new_msg = NULL;
 
-                               /* get error code */
-                               gst_message_parse_error( msg, &error, &debug );
-                               LOGE ("GST_MESSAGE_ERROR = %s\n", debug);
+                       /* get error code */
+                       gst_message_parse_error(msg, &error, &debug);
+                       LOGE("GST_MESSAGE_ERROR = %s\n", debug);
 
-                               new_msg = gst_message_new_error (GST_OBJECT_CAST (pd->playback_pipeline_src), error, debug);
+                       new_msg = gst_message_new_error(GST_OBJECT_CAST(pd->playback_pipeline_src), error, debug);
+
+                       /* notify application that pd has any error */
+                       gst_element_post_message(pd->playback_pipeline_src, new_msg);
+
+                       _mmplayer_unrealize_pd_downloader((MMHandleType)data);
+                       MMPLAYER_FREEIF(debug);
+                       g_error_free(error);
+               }
+               break;
+
+       case GST_MESSAGE_WARNING:
+               {
+                       char* debug = NULL;
+                       GError* error = NULL;
 
-                               /* notify application that pd has any error */
-                               gst_element_post_message (pd->playback_pipeline_src, new_msg);
+                       gst_message_parse_warning(msg, &error, &debug);
+                       LOGW("warning : %s\n", error->message);
+                       LOGW("debug : %s\n", debug);
 
-                               _mmplayer_unrealize_pd_downloader ((MMHandleType)data);
-                               MMPLAYER_FREEIF(debug);
-                               g_error_free( error);
-                       }
+                       MMPLAYER_FREEIF(debug);
+                       g_error_free(error);
+               }
+               break;
+
+       case GST_MESSAGE_STATE_CHANGED:
+       {
+               GstState old_state, new_state;
+               gchar *src_name;
+
+               /* get old and new state */
+               gst_message_parse_state_changed(msg, &old_state, &new_state, NULL);
+
+               if (old_state == new_state)
                        break;
 
-               case GST_MESSAGE_WARNING:
-                       {
-                               char* debug = NULL;
-                               GError* error = NULL;
+               /* we only care about pipeline state changes */
+               if (GST_MESSAGE_SRC(msg) != GST_OBJECT(pd->downloader_pipeline))
+                       break;
 
-                               gst_message_parse_warning(msg, &error, &debug);
-                               LOGW("warning : %s\n", error->message);
-                               LOGW("debug : %s\n", debug);
+               src_name = gst_object_get_name(msg->src);
+               LOGD("%s changed state from %s to %s", src_name,
+                       gst_element_state_get_name(old_state),
+                       gst_element_state_get_name(new_state));
+               g_free(src_name);
+
+               switch (new_state) {
+               case GST_STATE_VOID_PENDING:
+               case GST_STATE_NULL:
+               case GST_STATE_READY:
+               case GST_STATE_PAUSED:
+                       break;
 
-                               MMPLAYER_FREEIF(debug);
-                               g_error_free( error);
-                       }
+               case GST_STATE_PLAYING:
+                               /* notify application that download is stated */
+                       __pd_downloader_post_message(player, MM_MESSAGE_PD_DOWNLOADER_START, NULL);
                        break;
 
-               case GST_MESSAGE_STATE_CHANGED:
-               {
-                       GstState old_state, new_state;
-                       gchar *src_name;
-
-                       /* get old and new state */
-                       gst_message_parse_state_changed (msg, &old_state, &new_state, NULL);
-
-                       if (old_state == new_state)
-                               break;
-
-                       /* we only care about pipeline state changes */
-                       if (GST_MESSAGE_SRC (msg) != GST_OBJECT (pd->downloader_pipeline))
-                               break;
-
-                       src_name = gst_object_get_name (msg->src);
-                       LOGD ("%s changed state from %s to %s", src_name,
-                               gst_element_state_get_name (old_state),
-                               gst_element_state_get_name (new_state));
-                       g_free (src_name);
-
-                       switch(new_state)
-                       {
-                               case GST_STATE_VOID_PENDING:
-                               case GST_STATE_NULL:
-                               case GST_STATE_READY:
-                               case GST_STATE_PAUSED:
-                                       break;
-
-                               case GST_STATE_PLAYING:
-                                       /* notify application that download is stated */
-                                       __pd_downloader_post_message(player, MM_MESSAGE_PD_DOWNLOADER_START, NULL);
-                                       break;
-
-                               default:
-                                       break;
-                       }
+               default:
+                       break;
                }
-               break;
+       }
+       break;
 
-               case GST_MESSAGE_DURATION:
-               {
-                       gint64 size = 0LL;
+       case GST_MESSAGE_DURATION:
+       {
+               gint64 size = 0LL;
 
-                       /* get total size  of download file, (bytes) */
-                       if ( ! gst_element_query_duration( pd->downloader_pipeline, GST_FORMAT_BYTES, &size ) )
-                       {
-                               GError *err = NULL;
-                               GstMessage *new_msg = NULL;
+               /* get total size  of download file, (bytes) */
+               if (!gst_element_query_duration(pd->downloader_pipeline, GST_FORMAT_BYTES, &size)) {
+                       GError *err = NULL;
+                       GstMessage *new_msg = NULL;
 
-                               err = g_error_new (GST_STREAM_ERROR, GST_STREAM_ERROR_FAILED, "can't get total size");
-                               new_msg = gst_message_new_error (GST_OBJECT_CAST (pd->playback_pipeline_src), err, NULL);
-                               gst_element_post_message (pd->playback_pipeline_src, new_msg);
+                       err = g_error_new(GST_STREAM_ERROR, GST_STREAM_ERROR_FAILED, "can't get total size");
+                       new_msg = gst_message_new_error(GST_OBJECT_CAST(pd->playback_pipeline_src), err, NULL);
+                       gst_element_post_message(pd->playback_pipeline_src, new_msg);
 
-                               g_error_free (err);
+                       g_error_free(err);
 
-                               // TODO: check if playback pipeline is closed well or not
-                               g_object_set (G_OBJECT (pd->playback_pipeline_src), "eos", TRUE, NULL);
+                       // TODO: check if playback pipeline is closed well or not
+                       g_object_set(G_OBJECT(pd->playback_pipeline_src), "eos", TRUE, NULL);
 
-                               _mmplayer_unrealize_pd_downloader ((MMHandleType)data);
+                       _mmplayer_unrealize_pd_downloader((MMHandleType)data);
 
-                               LOGE("failed to query total size for download\n");
-                               break;
-                       }
+                       LOGE("failed to query total size for download\n");
+                       break;
+               }
 
-                       pd->total_size = size;
+               pd->total_size = size;
 
-                       LOGD("PD total size : %lld bytes\n", size);
-               }
-               break;
+               LOGD("PD total size : %lld bytes\n", size);
+       }
+       break;
 
-               default:
-                       LOGW("unhandled message\n");
-                       break;
+       default:
+               LOGW("unhandled message\n");
+               break;
        }
 
        MMPLAYER_FLEAVE();
@@ -198,10 +195,9 @@ gboolean __pd_downloader_post_message(mm_player_t * player, enum MMMessageType m
 {
        MMPLAYER_FENTER();
 
-       MMPLAYER_RETURN_VAL_IF_FAIL( player, FALSE );
+       MMPLAYER_RETURN_VAL_IF_FAIL(player, FALSE);
 
-       if ( !player->pd_msg_cb )
-       {
+       if (!player->pd_msg_cb) {
                LOGW("no msg callback. can't post\n");
                return FALSE;
        }
@@ -228,8 +224,7 @@ int _mmplayer_get_pd_downloader_status(MMHandleType handle, guint64 *current_pos
        MMPLAYER_RETURN_VAL_IF_FAIL(pd, MM_ERROR_INVALID_ARGUMENT);
        MMPLAYER_RETURN_VAL_IF_FAIL(pd->downloader_pipeline, MM_ERROR_PLAYER_INVALID_STATE);
 
-       if ( !pd->total_size )
-       {
+       if (!pd->total_size) {
                LOGW("not ready to get total size\n");
                return MM_ERROR_PLAYER_INTERNAL;
        }
@@ -254,13 +249,12 @@ mm_player_pd_t * _mmplayer_create_pd_downloader()
        mm_player_pd_t * pd = NULL;
 
        /* create PD handle */
-       pd = (mm_player_pd_t *) malloc (sizeof (mm_player_pd_t));
-       if ( !pd )
-       {
-               LOGE ("Failed to create pd downloader handle...\n");
+       pd = (mm_player_pd_t *) malloc(sizeof(mm_player_pd_t));
+       if (!pd) {
+               LOGE("Failed to create pd downloader handle...\n");
                return FALSE;
        }
-       memset( pd, 0, sizeof (mm_player_pd_t));
+       memset(pd, 0, sizeof(mm_player_pd_t));
 
        MMPLAYER_FLEAVE();
 
@@ -268,18 +262,18 @@ mm_player_pd_t * _mmplayer_create_pd_downloader()
 }
 
 
-gboolean _mmplayer_destroy_pd_downloader (MMHandleType handle)
+gboolean _mmplayer_destroy_pd_downloader(MMHandleType handle)
 {
        MMPLAYER_FENTER();
 
        mm_player_pd_t * pd = NULL;
 
-       MMPLAYER_RETURN_VAL_IF_FAIL ( handle, MM_ERROR_INVALID_ARGUMENT );
+       MMPLAYER_RETURN_VAL_IF_FAIL(handle, MM_ERROR_INVALID_ARGUMENT);
 
        pd = MM_PLAYER_GET_PD(handle);
 
        if (pd && pd->downloader_pipeline)
-               _mmplayer_unrealize_pd_downloader (handle);
+               _mmplayer_unrealize_pd_downloader(handle);
 
        /* release PD handle */
        MMPLAYER_FREEIF(pd);
@@ -290,22 +284,22 @@ gboolean _mmplayer_destroy_pd_downloader (MMHandleType handle)
 }
 
 
-gboolean _mmplayer_realize_pd_downloader (MMHandleType handle, gchar *src_uri, gchar *dst_uri, GstElement *pushsrc)
+gboolean _mmplayer_realize_pd_downloader(MMHandleType handle, gchar *src_uri, gchar *dst_uri, GstElement *pushsrc)
 {
        MMPLAYER_FENTER();
 
        mm_player_pd_t * pd = NULL;
 
-       MMPLAYER_RETURN_VAL_IF_FAIL ( handle, MM_ERROR_INVALID_ARGUMENT );
-       MMPLAYER_RETURN_VAL_IF_FAIL ( src_uri, MM_ERROR_INVALID_ARGUMENT );
-       MMPLAYER_RETURN_VAL_IF_FAIL ( dst_uri, MM_ERROR_INVALID_ARGUMENT );
-       MMPLAYER_RETURN_VAL_IF_FAIL ( pushsrc, MM_ERROR_INVALID_ARGUMENT );
+       MMPLAYER_RETURN_VAL_IF_FAIL(handle, MM_ERROR_INVALID_ARGUMENT);
+       MMPLAYER_RETURN_VAL_IF_FAIL(src_uri, MM_ERROR_INVALID_ARGUMENT);
+       MMPLAYER_RETURN_VAL_IF_FAIL(dst_uri, MM_ERROR_INVALID_ARGUMENT);
+       MMPLAYER_RETURN_VAL_IF_FAIL(pushsrc, MM_ERROR_INVALID_ARGUMENT);
 
        pd = MM_PLAYER_GET_PD(handle);
 
        /* initialize */
-       pd->path_read_from = g_strdup (src_uri);
-       pd->location_to_save = g_strdup (dst_uri);
+       pd->path_read_from = g_strdup(src_uri);
+       pd->location_to_save = g_strdup(dst_uri);
        pd->playback_pipeline_src = pushsrc;
        pd->total_size = 0LL;
 
@@ -315,7 +309,7 @@ gboolean _mmplayer_realize_pd_downloader (MMHandleType handle, gchar *src_uri, g
 }
 
 
-gboolean _mmplayer_start_pd_downloader (MMHandleType handle)
+gboolean _mmplayer_start_pd_downloader(MMHandleType handle)
 {
        GstBus* bus = NULL;
        gboolean bret = FALSE;
@@ -327,87 +321,80 @@ gboolean _mmplayer_start_pd_downloader (MMHandleType handle)
 
        mm_player_pd_t * pd = NULL;
 
-       MMPLAYER_RETURN_VAL_IF_FAIL ( handle, MM_ERROR_INVALID_ARGUMENT );
+       MMPLAYER_RETURN_VAL_IF_FAIL(handle, MM_ERROR_INVALID_ARGUMENT);
 
        pd = MM_PLAYER_GET_PD(handle);
 
        /* pipeline */
-       pd->downloader_pipeline = gst_pipeline_new ("PD Downloader");
-       if (NULL == pd->downloader_pipeline)
-       {
-               LOGE ("Can't create PD download pipeline...");
+       pd->downloader_pipeline = gst_pipeline_new("PD Downloader");
+       if (NULL == pd->downloader_pipeline) {
+               LOGE("Can't create PD download pipeline...");
                return FALSE;
        }
 
        /* source */
-       pd->downloader_src = gst_element_factory_make ("souphttpsrc", "PD HTTP download source");
-       if (NULL == pd->downloader_src)
-       {
-               LOGE ("Can't create PD download src...");
+       pd->downloader_src = gst_element_factory_make("souphttpsrc", "PD HTTP download source");
+       if (NULL == pd->downloader_src) {
+               LOGE("Can't create PD download src...");
                return FALSE;
        }
 
        /* queue */
-       pd->downloader_queue = gst_element_factory_make ("queue", "PD download queue");
-       if (NULL == pd->downloader_queue)
-       {
-               LOGE ("Can't create PD download queue...");
+       pd->downloader_queue = gst_element_factory_make("queue", "PD download queue");
+       if (NULL == pd->downloader_queue) {
+               LOGE("Can't create PD download queue...");
                return FALSE;
        }
 
        /* filesink */
-       pd->downloader_sink = gst_element_factory_make ("filesink", "PD download sink");
-       if (NULL == pd->downloader_sink)
-       {
-               LOGE ("Can't create PD download sink...");
+       pd->downloader_sink = gst_element_factory_make("filesink", "PD download sink");
+       if (NULL == pd->downloader_sink) {
+               LOGE("Can't create PD download sink...");
                return FALSE;
        }
 
        g_object_set(pd->downloader_sink, "sync", FALSE, NULL);
 
        /* Add to bin and link */
-       gst_bin_add_many (GST_BIN (pd->downloader_pipeline),
+       gst_bin_add_many(GST_BIN(pd->downloader_pipeline),
                                        pd->downloader_src, pd->downloader_queue, pd->downloader_sink,
                                        NULL);
 
-       bret = gst_element_link_many (pd->downloader_src, pd->downloader_queue, pd->downloader_sink, NULL);
-       if (FALSE == bret)
-       {
-               LOGE ("Can't link elements src and sink...");
+       bret = gst_element_link_many(pd->downloader_src, pd->downloader_queue, pd->downloader_sink, NULL);
+       if (FALSE == bret) {
+               LOGE("Can't link elements src and sink...");
                return FALSE;
        }
 
        /* Get Bus and set callback to watch */
-       bus = gst_pipeline_get_bus (GST_PIPELINE (pd->downloader_pipeline));
-       gst_bus_add_watch (bus, __pd_downloader_callback, (gpointer)handle);
-       gst_object_unref (bus);
+       bus = gst_pipeline_get_bus(GST_PIPELINE(pd->downloader_pipeline));
+       gst_bus_add_watch(bus, __pd_downloader_callback, (gpointer)handle);
+       gst_object_unref(bus);
 
        /* Set URI on HTTP source */
-       g_object_set (G_OBJECT (pd->downloader_src), "location", pd->path_read_from, NULL);
+       g_object_set(G_OBJECT(pd->downloader_src), "location", pd->path_read_from, NULL);
 
        /* set file download location on filesink*/
-       g_object_set (G_OBJECT (pd->downloader_sink), "location", pd->location_to_save, NULL);
+       g_object_set(G_OBJECT(pd->downloader_sink), "location", pd->location_to_save, NULL);
 
-       SECURE_LOGD ("src location = %s, save location = %s\n", pd->path_read_from, pd->location_to_save);
+       SECURE_LOGD("src location = %s, save location = %s\n", pd->path_read_from, pd->location_to_save);
 
        /* Start to download */
-       sret = gst_element_set_state (pd->downloader_pipeline, GST_STATE_PLAYING);
-       if (GST_STATE_CHANGE_FAILURE == sret)
-       {
-               LOGE ("PD download pipeline failed to go to PLAYING state...");
+       sret = gst_element_set_state(pd->downloader_pipeline, GST_STATE_PLAYING);
+       if (GST_STATE_CHANGE_FAILURE == sret) {
+               LOGE("PD download pipeline failed to go to PLAYING state...");
                return FALSE;
        }
 
-       LOGD ("set_state :: sret = %d\n", sret);
+       LOGD("set_state :: sret = %d\n", sret);
 
-       sret = gst_element_get_state (pd->downloader_pipeline, &cur_state, &pending_state, GST_CLOCK_TIME_NONE);
-       if (GST_STATE_CHANGE_FAILURE == sret)
-       {
-               LOGE ("PD download pipeline failed to do get_state...");
+       sret = gst_element_get_state(pd->downloader_pipeline, &cur_state, &pending_state, GST_CLOCK_TIME_NONE);
+       if (GST_STATE_CHANGE_FAILURE == sret) {
+               LOGE("PD download pipeline failed to do get_state...");
                return FALSE;
        }
 
-       LOGD ("get-state :: sret = %d\n", sret);
+       LOGD("get-state :: sret = %d\n", sret);
 
        MMPLAYER_FLEAVE();
 
@@ -415,22 +402,22 @@ gboolean _mmplayer_start_pd_downloader (MMHandleType handle)
 }
 
 
-gboolean _mmplayer_unrealize_pd_downloader (MMHandleType handle)
+gboolean _mmplayer_unrealize_pd_downloader(MMHandleType handle)
 {
        MMPLAYER_FENTER();
 
        mm_player_pd_t * pd = NULL;
 
-       MMPLAYER_RETURN_VAL_IF_FAIL ( handle, FALSE );
+       MMPLAYER_RETURN_VAL_IF_FAIL(handle, FALSE);
 
        pd = MM_PLAYER_GET_PD(handle);
 
-       MMPLAYER_RETURN_VAL_IF_FAIL ( pd && pd->downloader_pipeline, FALSE );
+       MMPLAYER_RETURN_VAL_IF_FAIL(pd && pd->downloader_pipeline, FALSE);
 
-       gst_element_set_state (pd->downloader_pipeline, GST_STATE_NULL);
-       gst_element_get_state (pd->downloader_pipeline, NULL, NULL, GST_CLOCK_TIME_NONE);
+       gst_element_set_state(pd->downloader_pipeline, GST_STATE_NULL);
+       gst_element_get_state(pd->downloader_pipeline, NULL, NULL, GST_CLOCK_TIME_NONE);
 
-       gst_object_unref (G_OBJECT (pd->downloader_pipeline));
+       gst_object_unref(G_OBJECT(pd->downloader_pipeline));
        pd->downloader_pipeline = NULL;
 
        /* free */
@@ -449,7 +436,7 @@ gint _mm_player_set_pd_downloader_message_cb(MMHandleType handle, MMMessageCallb
 
        mm_player_t * player = NULL;
 
-       MMPLAYER_RETURN_VAL_IF_FAIL ( handle, MM_ERROR_INVALID_ARGUMENT );
+       MMPLAYER_RETURN_VAL_IF_FAIL(handle, MM_ERROR_INVALID_ARGUMENT);
 
        player = MM_PLAYER_CAST((MMHandleType)handle);
 
index 54940e6..3c84ca5 100644 (file)
@@ -35,57 +35,50 @@ enum {
        MRP_RESOURCE_MAX,
 };
 const char* resource_str[MRP_RESOURCE_MAX] = {
-    "video_overlay",
-    "video_decoder",
+       "video_overlay",
+       "video_decoder",
 };
 
 #define MMPLAYER_CHECK_RESOURCE_MANAGER_INSTANCE(x_player_resource_manager) \
-do \
-{ \
-       if (!x_player_resource_manager) \
-       { \
+do { \
+       if (!x_player_resource_manager) { \
                LOGE("no resource manager instance");\
                return MM_ERROR_INVALID_ARGUMENT; \
        } \
-}while(0);
+} while (0);
 
 #define MMPLAYER_CHECK_CONNECTION_RESOURCE_MANAGER(x_player_resource_manager) \
-do \
-{ \
-       if (!x_player_resource_manager) \
-       { \
+do { \
+       if (!x_player_resource_manager) { \
                LOGE("no resource manager instance");\
                return MM_ERROR_INVALID_ARGUMENT; \
-       } \
-       else \
-       { \
-               if (!x_player_resource_manager->is_connected) \
-               { \
+       } else { \
+               if (!x_player_resource_manager->is_connected) { \
                        LOGE("not connected to resource server yet"); \
                        return MM_ERROR_RESOURCE_NOT_INITIALIZED; \
                } \
        } \
-}while(0);
+} while (0);
 
 static char *state_to_str(mrp_res_resource_state_t st)
 {
        char *state = "unknown";
        switch (st) {
-               case MRP_RES_RESOURCE_ACQUIRED:
-                       state = "acquired";
-                       break;
-               case MRP_RES_RESOURCE_LOST:
-                       state = "lost";
-                       break;
-               case MRP_RES_RESOURCE_AVAILABLE:
-                       state = "available";
-                       break;
-               case MRP_RES_RESOURCE_PENDING:
-                       state = "pending";
-                       break;
-               case MRP_RES_RESOURCE_ABOUT_TO_LOOSE:
-                       state = "about to loose";
-                       break;
+       case MRP_RES_RESOURCE_ACQUIRED:
+               state = "acquired";
+               break;
+       case MRP_RES_RESOURCE_LOST:
+               state = "lost";
+               break;
+       case MRP_RES_RESOURCE_AVAILABLE:
+               state = "available";
+               break;
+       case MRP_RES_RESOURCE_PENDING:
+               state = "pending";
+               break;
+       case MRP_RES_RESOURCE_ABOUT_TO_LOOSE:
+               state = "about to loose";
+               break;
        }
        return state;
 }
@@ -99,54 +92,45 @@ static void mrp_state_callback(mrp_res_context_t *context, mrp_res_error_t err,
 
        MMPLAYER_FENTER();
 
-       if (user_data == NULL)
-       {
+       if (user_data == NULL) {
                LOGE(" - user data is null\n");
                return;
        }
        player = (mm_player_t*)user_data;
-       if (err != MRP_RES_ERROR_NONE)
-       {
+       if (err != MRP_RES_ERROR_NONE) {
                LOGE(" - error message received from Murphy, for the player(%p), err(0x%x)\n", player, err);
                return;
        }
 
-       switch(context->state)
-       {
-               case MRP_RES_CONNECTED:
-                       LOGD(" - connected to Murphy\n");
-                       if ((rset = mrp_res_list_resources(context)) != NULL)
-                       {
-                               mrp_res_string_array_t *resource_names;
-                               resource_names = mrp_res_list_resource_names(rset);
-                               if (!resource_names)
-                               {
-                                       LOGE(" - no resources available\n");
-                                       return;
-                               }
-                               for(i = 0; i < resource_names->num_strings; i++)
-                               {
-                                       resource = mrp_res_get_resource_by_name(rset, resource_names->strings[i]);
-                                       if(resource)
-                                       {
-                                               LOGD(" - available resource: %s", resource->name);
-                                       }
-                               }
-                               mrp_res_free_string_array(resource_names);
+       switch (context->state) {
+       case MRP_RES_CONNECTED:
+               LOGD(" - connected to Murphy\n");
+               if ((rset = mrp_res_list_resources(context)) != NULL) {
+                       mrp_res_string_array_t *resource_names;
+                       resource_names = mrp_res_list_resource_names(rset);
+                       if (!resource_names) {
+                               LOGE(" - no resources available\n");
+                               return;
                        }
-                       player->resource_manager.is_connected = TRUE;
-                       break;
-               case MRP_RES_DISCONNECTED:
-                       LOGD(" - disconnected from Murphy\n");
-                       if (player->resource_manager.rset)
-                       {
-                               mrp_res_delete_resource_set(player->resource_manager.rset);
-                               player->resource_manager.rset = NULL;
+                       for (i = 0; i < resource_names->num_strings; i++) {
+                               resource = mrp_res_get_resource_by_name(rset, resource_names->strings[i]);
+                               if (resource)
+                                       LOGD(" - available resource: %s", resource->name);
                        }
-                       mrp_res_destroy(player->resource_manager.context);
-                       player->resource_manager.context = NULL;
-                       player->resource_manager.is_connected = FALSE;
-                       break;
+                       mrp_res_free_string_array(resource_names);
+               }
+               player->resource_manager.is_connected = TRUE;
+               break;
+       case MRP_RES_DISCONNECTED:
+               LOGD(" - disconnected from Murphy\n");
+               if (player->resource_manager.rset) {
+                       mrp_res_delete_resource_set(player->resource_manager.rset);
+                       player->resource_manager.rset = NULL;
+               }
+               mrp_res_destroy(player->resource_manager.context);
+               player->resource_manager.context = NULL;
+               player->resource_manager.is_connected = FALSE;
+               break;
        }
 
        MMPLAYER_FLEAVE();
@@ -164,21 +148,19 @@ static void mrp_rset_state_callback(mrp_res_context_t *cx, const mrp_res_resourc
 
        MMPLAYER_RESOURCE_LOCK(&player->resource_manager);
 
-       if(!mrp_res_equal_resource_set(rs, player->resource_manager.rset)) {
+       if (!mrp_res_equal_resource_set(rs, player->resource_manager.rset)) {
                LOGW("- resource set(%p) is not same as this player handle's(%p)", rs, player->resource_manager.rset);
                MMPLAYER_RESOURCE_UNLOCK(&player->resource_manager);
                return;
        }
 
        LOGD(" - resource set state of player(%p) is changed to [%s]\n", player, state_to_str(rs->state));
-       for (i = 0; i < MRP_RESOURCE_MAX; i++)
-       {
+       for (i = 0; i < MRP_RESOURCE_MAX; i++) {
                res = mrp_res_get_resource_by_name(rs, resource_str[i]);
-               if(res == NULL){
+               if (res == NULL)
                        LOGW(" -- %s not present in resource set\n", resource_str[i]);
-               } else {
+               else
                        LOGD(" -- resource name [%s] -> [%s]'\n", res->name, state_to_str(res->state));
-               }
        }
 
        mrp_res_delete_resource_set(player->resource_manager.rset);
@@ -201,7 +183,7 @@ static void mrp_rset_state_callback(mrp_res_context_t *cx, const mrp_res_resourc
 }
 
 
-static void mrp_resource_release_cb (mrp_res_context_t *cx, const mrp_res_resource_set_t *rs, void *user_data)
+static void mrp_resource_release_cb(mrp_res_context_t *cx, const mrp_res_resource_set_t *rs, void *user_data)
 {
        int i = 0;
        int result = MM_ERROR_NONE;
@@ -210,46 +192,39 @@ static void mrp_resource_release_cb (mrp_res_context_t *cx, const mrp_res_resour
 
        MMPLAYER_FENTER();
 
-       if (user_data == NULL)
-       {
+       if (user_data == NULL) {
                LOGE("- user_data is null\n");
                return;
        }
        player = (mm_player_t*)user_data;
 
-       if(!mrp_res_equal_resource_set(rs, player->resource_manager.rset))
-       {
+       if (!mrp_res_equal_resource_set(rs, player->resource_manager.rset)) {
                LOGW("- resource set(%p) is not same as this player handle's(%p)", rs, player->resource_manager.rset);
                return;
        }
 
        LOGD(" - resource set state of player(%p) is changed to [%s]\n", player, state_to_str(rs->state));
-       for (i = 0; i < MRP_RESOURCE_MAX; i++)
-       {
+       for (i = 0; i < MRP_RESOURCE_MAX; i++) {
                res = mrp_res_get_resource_by_name(rs, resource_str[i]);
-               if(res == NULL){
+               if (res == NULL)
                        LOGW(" -- %s not present in resource set\n", resource_str[i]);
-               } else {
+               else
                        LOGD(" -- resource name [%s] -> [%s]'\n", res->name, state_to_str(res->state));
-               }
        }
 
        /* do something to release resource here.
         * player stop and interrupt forwarding */
-       if (!__mmplayer_can_do_interrupt(player))
+       if (!__mmplayer_can_do_interrupt(player)) {
                LOGW("no need to interrupt, so leave");
-       else
-       {
-               if(player->pipeline->videobin)
-               {
+       } else {
+               if (player->pipeline->videobin) {
                        player->resource_manager.by_rm_cb = TRUE;
                        LOGD("video resource conflict so, resource will be freed by unrealizing");
                        result = _mmplayer_unrealize((MMHandleType)player);
                        if (result)
                                LOGW("failed to unrealize");
                        player->resource_manager.by_rm_cb = FALSE;
-               }
-               else
+               } else
                        LOGW("could not find videobin");
 
                /* lock is called in __mmplayer_can_do_interrupt() */
@@ -263,8 +238,7 @@ static void mrp_resource_release_cb (mrp_res_context_t *cx, const mrp_res_resour
 
 static int create_rset(MMPlayerResourceManager *resource_manager)
 {
-       if (resource_manager->rset)
-       {
+       if (resource_manager->rset) {
                LOGE(" - resource set was already created\n");
                return MM_ERROR_RESOURCE_INVALID_STATE;
        }
@@ -273,16 +247,13 @@ static int create_rset(MMPlayerResourceManager *resource_manager)
                                MRP_APP_CLASS_FOR_PLAYER,
                                mrp_rset_state_callback,
                                (void*)resource_manager->user_data);
-       if(resource_manager->rset == NULL)
-       {
+       if (resource_manager->rset == NULL) {
                LOGE(" - could not create resource set\n");
                return MM_ERROR_RESOURCE_INTERNAL;
        }
 
-       if(!mrp_res_set_autorelease(TRUE, resource_manager->rset))
-       {
+       if (!mrp_res_set_autorelease(TRUE, resource_manager->rset))
                LOGW(" - could not set autorelease flag!\n");
-       }
 
        return MM_ERROR_NONE;
 }
@@ -294,8 +265,7 @@ static int include_resource(MMPlayerResourceManager *resource_manager, const cha
                                resource_name,
                                MRP_RESOURCE_TYPE_MANDATORY,
                                MRP_RESOURCE_TYPE_EXCLUSIVE);
-       if (resource == NULL)
-       {
+       if (resource == NULL) {
                LOGE(" - could not include resource[%s]\n", resource_name);
                return MM_ERROR_RESOURCE_INTERNAL;
        }
@@ -312,8 +282,7 @@ static int set_resource_release_cb(MMPlayerResourceManager *resource_manager)
 
        if (resource_manager->rset) {
                mrp_ret = mrp_res_set_release_callback(resource_manager->rset, mrp_resource_release_cb, resource_manager->user_data);
-               if (!mrp_ret)
-               {
+               if (!mrp_ret) {
                        LOGE(" - could not set release callback\n");
                        ret = MM_ERROR_RESOURCE_INTERNAL;
                }
@@ -331,20 +300,16 @@ int _mmplayer_resource_manager_init(MMPlayerResourceManager *resource_manager, v
        MMPLAYER_CHECK_RESOURCE_MANAGER_INSTANCE(resource_manager);
 
        resource_manager->mloop = mrp_mainloop_glib_get(g_main_loop_new(NULL, TRUE));
-       if (resource_manager->mloop)
-       {
+       if (resource_manager->mloop) {
                resource_manager->context = mrp_res_create(resource_manager->mloop, mrp_state_callback, user_data);
-               if (resource_manager->context == NULL)
-               {
+               if (resource_manager->context == NULL) {
                        LOGE(" - could not get context for resource manager\n");
                        mrp_mainloop_destroy(resource_manager->mloop);
                        resource_manager->mloop = NULL;
                        return MM_ERROR_RESOURCE_INTERNAL;
                }
                resource_manager->user_data = user_data;
-       }
-       else
-       {
+       } else {
                LOGE("- could not get mainloop for resource manager\n");
                return MM_ERROR_RESOURCE_INTERNAL;
        }
@@ -366,13 +331,10 @@ int _mmplayer_resource_manager_prepare(MMPlayerResourceManager *resource_manager
        MMPLAYER_CHECK_CONNECTION_RESOURCE_MANAGER(resource_manager);
 
        if (!resource_manager->rset)
-       {
                ret = create_rset(resource_manager);
-       }
-       if (ret == MM_ERROR_NONE)
-       {
-               switch (resource_type)
-               {
+
+       if (ret == MM_ERROR_NONE) {
+               switch (resource_type) {
                case RESOURCE_TYPE_VIDEO_OVERLAY:
                        ret = include_resource(resource_manager, resource_str[MRP_RESOURCE_FOR_VIDEO_OVERLAY]);
                        break;
@@ -396,36 +358,26 @@ int _mmplayer_resource_manager_acquire(MMPlayerResourceManager *resource_manager
        MMPLAYER_CHECK_RESOURCE_MANAGER_INSTANCE(resource_manager);
        MMPLAYER_CHECK_CONNECTION_RESOURCE_MANAGER(resource_manager);
 
-       if (resource_manager->rset == NULL)
-       {
+       if (resource_manager->rset == NULL) {
                LOGE("- could not acquire resource, resource set is null\n");
                ret = MM_ERROR_RESOURCE_INVALID_STATE;
-       }
-       else
-       {
+       } else {
                ret = set_resource_release_cb(resource_manager);
-               if (ret)
-               {
+               if (ret) {
                        LOGE("- could not set resource release cb, ret(%d)\n", ret);
                        ret = MM_ERROR_RESOURCE_INTERNAL;
-               }
-               else
-               {
+               } else {
                        MMPLAYER_RESOURCE_LOCK(resource_manager);
 
                        ret = mrp_res_acquire_resource_set(resource_manager->rset);
-                       if (ret)
-                       {
+                       if (ret) {
                                LOGE("- could not acquire resource, ret(%d)\n", ret);
                                ret = MM_ERROR_RESOURCE_INTERNAL;
-                       }
-                       else
-                       {
+                       } else {
                                gint64 end_time = g_get_monotonic_time() + MMPLAYER_RESOURCE_TIMEOUT*G_TIME_SPAN_SECOND;
 
                                LOGD("- acquire resource waiting..%p till %lld\n", resource_manager, end_time);
-                               if (!MMPLAYER_RESOURCE_WAIT_UNTIL(resource_manager, end_time))
-                               {
+                               if (!MMPLAYER_RESOURCE_WAIT_UNTIL(resource_manager, end_time)) {
                                        LOGE("- could not acquire resource\n");
                                        ret = MM_ERROR_RESOURCE_INTERNAL;
                                } else {
@@ -448,34 +400,24 @@ int _mmplayer_resource_manager_release(MMPlayerResourceManager *resource_manager
        MMPLAYER_CHECK_RESOURCE_MANAGER_INSTANCE(resource_manager);
        MMPLAYER_CHECK_CONNECTION_RESOURCE_MANAGER(resource_manager);
 
-       if (resource_manager->rset == NULL)
-       {
+       if (resource_manager->rset == NULL) {
                LOGE("- could not release resource, resource set is null\n");
                ret = MM_ERROR_RESOURCE_INVALID_STATE;
-       }
-       else
-       {
-               if (resource_manager->rset->state != MRP_RES_RESOURCE_ACQUIRED)
-               {
+       } else {
+               if (resource_manager->rset->state != MRP_RES_RESOURCE_ACQUIRED) {
                        LOGE("- could not release resource, resource set state is [%s]\n", state_to_str(resource_manager->rset->state));
                        ret = MM_ERROR_RESOURCE_INVALID_STATE;
-               }
-               else
-               {
+               } else {
                        MMPLAYER_RESOURCE_LOCK(resource_manager);
                        ret = mrp_res_release_resource_set(resource_manager->rset);
-                       if (ret)
-                       {
+                       if (ret) {
                                LOGE("- could not release resource, ret(%d)\n", ret);
                                ret = MM_ERROR_RESOURCE_INTERNAL;
-                       }
-                       else
-                       {
+                       } else {
                                gint64 end_time = g_get_monotonic_time() + MMPLAYER_RESOURCE_TIMEOUT*G_TIME_SPAN_SECOND;
 
                                LOGD("- release resource waiting..%p till %lld\n", resource_manager, end_time);
-                               if (!MMPLAYER_RESOURCE_WAIT_UNTIL(resource_manager, end_time))
-                               {
+                               if (!MMPLAYER_RESOURCE_WAIT_UNTIL(resource_manager, end_time)) {
                                        LOGW("- could not release resource in time\n");
                                        /* ret = MM_ERROR_RESOURCE_INTERNAL */
                                } else {
@@ -498,13 +440,10 @@ int _mmplayer_resource_manager_unprepare(MMPlayerResourceManager *resource_manag
        MMPLAYER_CHECK_RESOURCE_MANAGER_INSTANCE(resource_manager);
        MMPLAYER_CHECK_CONNECTION_RESOURCE_MANAGER(resource_manager);
 
-       if (resource_manager->rset == NULL)
-       {
+       if (resource_manager->rset == NULL) {
                LOGE("- could not unprepare for resource_manager, _mmplayer_resource_manager_prepare() first\n");
                ret = MM_ERROR_RESOURCE_INVALID_STATE;
-       }
-       else
-       {
+       } else {
                MMPLAYER_RESOURCE_LOCK(resource_manager);
                mrp_res_delete_resource_set(resource_manager->rset);
                resource_manager->rset = NULL;
@@ -524,23 +463,19 @@ int _mmplayer_resource_manager_deinit(MMPlayerResourceManager *resource_manager)
        MMPLAYER_CHECK_RESOURCE_MANAGER_INSTANCE(resource_manager);
        MMPLAYER_CHECK_CONNECTION_RESOURCE_MANAGER(resource_manager);
 
-       if (resource_manager->rset)
-       {
-               if (resource_manager->rset->state == MRP_RES_RESOURCE_ACQUIRED)
-               {
+       if (resource_manager->rset) {
+               if (resource_manager->rset->state == MRP_RES_RESOURCE_ACQUIRED) {
                        if (mrp_res_release_resource_set(resource_manager->rset))
                                LOGE("- could not release resource\n");
                }
                mrp_res_delete_resource_set(resource_manager->rset);
                resource_manager->rset = NULL;
        }
-       if (resource_manager->context)
-       {
+       if (resource_manager->context) {
                mrp_res_destroy(resource_manager->context);
                resource_manager->context = NULL;
        }
-       if (resource_manager->mloop)
-       {
+       if (resource_manager->mloop) {
                mrp_mainloop_destroy(resource_manager->mloop);
                resource_manager->mloop = NULL;
        }
index 88eed87..54a4603 100644 (file)
 #include "mm_player_sound_focus.h"
 
 #define MMPLAYER_CHECK_SOUND_FOCUS_INSTANCE(x_player_sound_focus) \
-do \
-{ \
-       if (!x_player_sound_focus) \
-       { \
+do { \
+       if (!x_player_sound_focus) { \
                LOGD("no sound focus instance");\
                return MM_ERROR_SOUND_NOT_INITIALIZED; \
        } \
-}while(0);
+} while (0);
 
-void __mmplayer_sound_signal_callback (mm_sound_signal_name_t signal, int value, void *user_data)
+void __mmplayer_sound_signal_callback(mm_sound_signal_name_t signal, int value, void *user_data)
 {
        MMPlayerSoundFocus *sound_focus = (MMPlayerSoundFocus*)user_data;
        int ret = MM_ERROR_NONE;
 
        LOGD("sound signal callback %d / %d", signal, value);
 
-       if (signal == MM_SOUND_SIGNAL_RELEASE_INTERNAL_FOCUS)
-       {
-               if (value == 1)
-               {
+       if (signal == MM_SOUND_SIGNAL_RELEASE_INTERNAL_FOCUS) {
+               if (value == 1) {
                        /* unregister watch callback */
-                       if (sound_focus->watch_id > 0)
-                       {
+                       if (sound_focus->watch_id > 0) {
                                LOGD("unset the focus watch cb %d", sound_focus->watch_id);
 
                                ret = mm_sound_unset_focus_watch_callback(sound_focus->watch_id);
@@ -66,16 +61,14 @@ void __mmplayer_sound_signal_callback (mm_sound_signal_name_t signal, int value,
                                */
                        }
                        /* unregister focus callback */
-                       if (sound_focus->focus_id > 0)
-                       {
+                       if (sound_focus->focus_id > 0) {
                                ret = mm_sound_unregister_focus(sound_focus->focus_id);
                                sound_focus->focus_id = 0;
                                if (ret != MM_ERROR_NONE)
                                        LOGE("failed to mm_sound_unregister_focus() %d", sound_focus->focus_id);
                        }
                        /* unregister device connected callback */
-                       if (sound_focus->connected_id > 0)
-                       {
+                       if (sound_focus->connected_id > 0) {
                                LOGD("unset the device connected cb %d", sound_focus->connected_id);
                                ret = mm_sound_remove_device_connected_callback(sound_focus->connected_id);
                                sound_focus->connected_id = 0;
@@ -90,7 +83,7 @@ static void
 __mmplayer_sound_device_connected_cb_func(MMSoundDevice_t device_h, bool is_connected, void *user_data)
 {
        mm_player_t* player = (mm_player_t*) user_data;
-       MMPLAYER_RETURN_IF_FAIL( player );
+       MMPLAYER_RETURN_IF_FAIL(player);
 
        mm_sound_device_type_e device_type;
        int ret;
@@ -102,54 +95,50 @@ __mmplayer_sound_device_connected_cb_func(MMSoundDevice_t device_h, bool is_conn
        ret = mm_sound_get_device_type(device_h, &device_type);
 
        if (!is_connected && MMPLAYER_CURRENT_STATE(player) == MM_PLAYER_STATE_PLAYING
-               && (player->sound_focus.focus_id > 0 || player->sound_focus.watch_id > 0))
-       {
-               switch (device_type)
+               && (player->sound_focus.focus_id > 0 || player->sound_focus.watch_id > 0)) {
+               switch (device_type) {
+               case MM_SOUND_DEVICE_TYPE_AUDIOJACK:
+               case MM_SOUND_DEVICE_TYPE_BLUETOOTH:
+               case MM_SOUND_DEVICE_TYPE_HDMI:
+               case MM_SOUND_DEVICE_TYPE_USB_AUDIO:
                {
-                       case MM_SOUND_DEVICE_TYPE_AUDIOJACK:
-                       case MM_SOUND_DEVICE_TYPE_BLUETOOTH:
-                       case MM_SOUND_DEVICE_TYPE_HDMI:
-                       case MM_SOUND_DEVICE_TYPE_USB_AUDIO:
-                       {
-                               ret = gst_element_set_state(player->pipeline->mainbin[MMPLAYER_M_PIPE].gst, GST_STATE_PAUSED);
-                               if (ret != GST_STATE_CHANGE_SUCCESS)
-                               {
-                                       LOGE("focus_id [%d], watch_id [%d], connected_id [%d], change_state result[%d]",
-                                               player->sound_focus.focus_id, player->sound_focus.watch_id,
-                                               player->sound_focus.connected_id, ret);
-                               }
-                               msg.union_type = MM_MSG_UNION_CODE;
-                               msg.code = MM_MSG_CODE_INTERRUPTED_BY_EARJACK_UNPLUG;
-                               MMPLAYER_POST_MSG( player, MM_MESSAGE_STATE_INTERRUPTED, &msg );
+                       ret = gst_element_set_state(player->pipeline->mainbin[MMPLAYER_M_PIPE].gst, GST_STATE_PAUSED);
+                       if (ret != GST_STATE_CHANGE_SUCCESS) {
+                               LOGE("focus_id [%d], watch_id [%d], connected_id [%d], change_state result[%d]",
+                                       player->sound_focus.focus_id, player->sound_focus.watch_id,
+                                       player->sound_focus.connected_id, ret);
                        }
-                       break;
-
-                       default:
-                               LOGD("do nothing");
+                       msg.union_type = MM_MSG_UNION_CODE;
+                       msg.code = MM_MSG_CODE_INTERRUPTED_BY_EARJACK_UNPLUG;
+                       MMPLAYER_POST_MSG(player, MM_MESSAGE_STATE_INTERRUPTED, &msg);
                }
+               break;
+
+               default:
+                       LOGD("do nothing");
+       }
        }
 }
 
 const gchar *
 __mmplayer_sound_get_stream_type(gint type)
 {
-       switch ( type )
-       {
-               case MM_SESSION_TYPE_CALL:
-               case MM_SESSION_TYPE_VIDEOCALL:
-               case MM_SESSION_TYPE_VOIP:
-                       return "ringtone-voip";
-               case MM_SESSION_TYPE_MEDIA:
-                       return "media";
-               case MM_SESSION_TYPE_NOTIFY:
-                       return "notification";
-               case MM_SESSION_TYPE_ALARM:
-                       return "alarm";
-               case MM_SESSION_TYPE_EMERGENCY:
-                       return "emergency";
-               default:
-                       LOGW("unexpected case!\n");
-                       return "media";
+       switch (type) {
+       case MM_SESSION_TYPE_CALL:
+       case MM_SESSION_TYPE_VIDEOCALL:
+       case MM_SESSION_TYPE_VOIP:
+               return "ringtone-voip";
+       case MM_SESSION_TYPE_MEDIA:
+               return "media";
+       case MM_SESSION_TYPE_NOTIFY:
+               return "notification";
+       case MM_SESSION_TYPE_ALARM:
+               return "alarm";
+       case MM_SESSION_TYPE_EMERGENCY:
+               return "emergency";
+       default:
+               LOGW("unexpected case!\n");
+               return "media";
        }
 
        return "media";
@@ -164,8 +153,7 @@ _mmplayer_sound_acquire_focus(MMPlayerSoundFocus* sound_focus)
        MMPLAYER_FENTER();
        MMPLAYER_CHECK_SOUND_FOCUS_INSTANCE(sound_focus);
 
-       if (sound_focus->acquired)
-       {
+       if (sound_focus->acquired) {
                LOGW("focus is already acquired. can't acquire again.");
                return MM_ERROR_NONE;
        }
@@ -173,12 +161,10 @@ _mmplayer_sound_acquire_focus(MMPlayerSoundFocus* sound_focus)
        stream_type = __mmplayer_sound_get_stream_type(sound_focus->session_type);
 
        if ((!strstr(stream_type, "media")) ||
-               (sound_focus->session_flags & MM_SESSION_OPTION_PAUSE_OTHERS))
-       {
+               (sound_focus->session_flags & MM_SESSION_OPTION_PAUSE_OTHERS)) {
 
                ret = mm_sound_acquire_focus(sound_focus->focus_id, FOCUS_FOR_BOTH, NULL);
-               if (ret != MM_ERROR_NONE)
-               {
+               if (ret != MM_ERROR_NONE) {
                        LOGE("failed to acquire sound focus\n");
                        return ret;
                }
@@ -199,8 +185,7 @@ _mmplayer_sound_release_focus(MMPlayerSoundFocus* sound_focus)
        MMPLAYER_FENTER();
        MMPLAYER_CHECK_SOUND_FOCUS_INSTANCE(sound_focus);
 
-       if (!sound_focus->acquired)
-       {
+       if (!sound_focus->acquired) {
                LOGW("focus is not acquired. no need to release.");
                return MM_ERROR_NONE;
        }
@@ -208,11 +193,9 @@ _mmplayer_sound_release_focus(MMPlayerSoundFocus* sound_focus)
        stream_type = __mmplayer_sound_get_stream_type(sound_focus->session_type);
 
        if ((!strstr(stream_type, "media")) ||
-               (sound_focus->session_flags & MM_SESSION_OPTION_PAUSE_OTHERS))
-       {
+               (sound_focus->session_flags & MM_SESSION_OPTION_PAUSE_OTHERS)) {
                ret = mm_sound_release_focus(sound_focus->focus_id, FOCUS_FOR_BOTH, NULL);
-               if (ret != MM_ERROR_NONE)
-               {
+               if (ret != MM_ERROR_NONE) {
                        LOGE("failed to release sound focus\n");
                        return ret;
                }
@@ -246,17 +229,14 @@ _mmplayer_sound_register(MMPlayerSoundFocus* sound_focus,
        ret = _mm_session_util_read_information(pid, &sound_focus->session_type, &sound_focus->session_flags);
        LOGW("Read Session Type -> ret:0x%X \n", ret);
 
-       /* case 1. if there is no session */
-       if (ret == MM_ERROR_INVALID_HANDLE)
-       {
+       if (ret == MM_ERROR_INVALID_HANDLE) {
+               /* case 1. if there is no session */
                LOGW("subscribe_id=%d\n", sound_focus->subscribe_id);
 
-               if (sound_focus->subscribe_id == 0)
-               {
+               if (sound_focus->subscribe_id == 0) {
                        ret = mm_sound_subscribe_signal_for_daemon(MM_SOUND_SIGNAL_RELEASE_INTERNAL_FOCUS, pid, &sound_focus->subscribe_id,
                                                                        (mm_sound_signal_callback)__mmplayer_sound_signal_callback, (void*)sound_focus);
-                       if (ret != MM_ERROR_NONE)
-                       {
+                       if (ret != MM_ERROR_NONE) {
                                LOGE("mm_sound_subscribe_signal is failed\n");
                                return MM_ERROR_POLICY_BLOCKED;
                        }
@@ -265,45 +245,36 @@ _mmplayer_sound_register(MMPlayerSoundFocus* sound_focus,
                        /* register watch callback */
                        ret = mm_sound_set_focus_watch_callback_for_session(pid ,
                                        FOCUS_FOR_BOTH, watch_cb, (void*)param, &sound_focus->watch_id);
-                       if (ret != MM_ERROR_NONE)
-                       {
+                       if (ret != MM_ERROR_NONE) {
                                LOGE("mm_sound_set_focus_watch_callback is failed\n");
                                return MM_ERROR_POLICY_BLOCKED;
                        }
                        /* register device connected callback */
                        ret = mm_sound_add_device_connected_callback(MM_SOUND_DEVICE_TYPE_EXTERNAL_FLAG,
                                        (mm_sound_device_connected_cb)__mmplayer_sound_device_connected_cb_func, (void*)param, &sound_focus->connected_id);
-                       if (ret != MM_ERROR_NONE)
-                       {
+                       if (ret != MM_ERROR_NONE) {
                                LOGE("mm_sound_add_device_connected_callback is failed\n");
                                return MM_ERROR_POLICY_BLOCKED;
                        }
                        LOGD("register device connected callback for the value is 0, sub_cb id %d\n", sound_focus->connected_id);
                }
                ret = MM_ERROR_NONE;
-       }
-       /* case 2. if sessoin exists */
-       else if (ret == MM_ERROR_NONE)
-       {
+       } else if (ret == MM_ERROR_NONE) {
+               /* case 2. if sessoin exists */
                /* in this case, this process is using stream info created by using sound-manager,
                 * we're going to skip working on backward compatibility of session. */
-               if (sound_focus->session_type == MM_SESSION_TYPE_REPLACED_BY_STREAM)
-               {
+               if (sound_focus->session_type == MM_SESSION_TYPE_REPLACED_BY_STREAM) {
                        LOGW("this process is using stream info. skip it..");
-               }
-               else
-               {
+               } else {
                        /* interpret session information */
                        stream_type = __mmplayer_sound_get_stream_type(sound_focus->session_type);
                        LOGD("fid [%d] wid [%d] type[%s], flags[0x%02X]\n",
                                sound_focus->focus_id, sound_focus->watch_id, stream_type, sound_focus->session_flags);
 
-                       if (sound_focus->focus_id == 0)
-                       {
+                       if (sound_focus->focus_id == 0) {
                                /* get unique id */
                                ret = mm_sound_focus_get_id(&sound_focus->focus_id);
-                               if (ret != MM_ERROR_NONE)
-                               {
+                               if (ret != MM_ERROR_NONE) {
                                        LOGE("failed to get unique focus id\n");
                                        return MM_ERROR_POLICY_BLOCKED;
                                }
@@ -311,8 +282,7 @@ _mmplayer_sound_register(MMPlayerSoundFocus* sound_focus,
                                /* register sound focus callback */
                                ret = mm_sound_register_focus_for_session(sound_focus->focus_id, pid,
                                                stream_type, focus_cb, (void*)param);
-                               if (ret != MM_ERROR_NONE)
-                               {
+                               if (ret != MM_ERROR_NONE) {
                                        LOGE("mm_sound_register_focus is failed\n");
                                        return MM_ERROR_POLICY_BLOCKED;
                                }
@@ -321,26 +291,22 @@ _mmplayer_sound_register(MMPlayerSoundFocus* sound_focus,
                        if ((sound_focus->watch_id == 0) &&
                                (strstr(stream_type, "media")) &&
                                !(sound_focus->session_flags & MM_SESSION_OPTION_PAUSE_OTHERS) &&
-                               !(sound_focus->session_flags & MM_SESSION_OPTION_UNINTERRUPTIBLE))
-                       {
+                               !(sound_focus->session_flags & MM_SESSION_OPTION_UNINTERRUPTIBLE)) {
                                LOGD("register focus watch callback\n");
                                /* register watch callback */
                                ret = mm_sound_set_focus_watch_callback_for_session(pid,
                                                FOCUS_FOR_BOTH, watch_cb, (void*)param, &sound_focus->watch_id);
-                               if (ret != MM_ERROR_NONE)
-                               {
+                               if (ret != MM_ERROR_NONE) {
                                        LOGE("mm_sound_set_focus_watch_callback is failed\n");
                                        return MM_ERROR_POLICY_BLOCKED;
                                }
                        }
 
-                       if(sound_focus->connected_id == 0)
-                       {
+                       if (sound_focus->connected_id == 0) {
                                /* register device connected callback */
                                ret = mm_sound_add_device_connected_callback(MM_SOUND_DEVICE_TYPE_EXTERNAL_FLAG,
                                                (mm_sound_device_connected_cb)__mmplayer_sound_device_connected_cb_func, (void*)param, &sound_focus->connected_id);
-                               if (ret != MM_ERROR_NONE)
-                               {
+                               if (ret != MM_ERROR_NONE) {
                                        LOGE("mm_sound_add_device_connected_callback is failed\n");
                                        return MM_ERROR_POLICY_BLOCKED;
                                }
@@ -348,9 +314,7 @@ _mmplayer_sound_register(MMPlayerSoundFocus* sound_focus,
                        }
                }
                ret = MM_ERROR_NONE;
-       }
-       else
-       {
+       } else {
                LOGE("_mm_session_util_read_information is failed");
                ret =  MM_ERROR_POLICY_BLOCKED;
        }
@@ -370,31 +334,27 @@ _mmplayer_sound_unregister(MMPlayerSoundFocus* sound_focus)
 
        LOGD("unregister sound focus callback\n");
 
-       if (sound_focus->focus_id > 0)
-       {
+       if (sound_focus->focus_id > 0) {
                ret = mm_sound_unregister_focus(sound_focus->focus_id);
-               if(ret != MM_ERROR_NONE)
+               if (ret != MM_ERROR_NONE)
                        LOGE("failed to mm_sound_unregister_focus() %d", sound_focus->focus_id);
                sound_focus->focus_id = 0;
        }
 
-       if (sound_focus->watch_id > 0)
-       {
+       if (sound_focus->watch_id > 0) {
                ret = mm_sound_unset_focus_watch_callback(sound_focus->watch_id);
-               if(ret != MM_ERROR_NONE)
+               if (ret != MM_ERROR_NONE)
                        LOGE("failed to mm_sound_unset_focus_watch_callback() %d", sound_focus->watch_id);
                sound_focus->watch_id = 0;
        }
 
-       if (sound_focus->subscribe_id > 0)
-       {
+       if (sound_focus->subscribe_id > 0) {
                mm_sound_unsubscribe_signal(sound_focus->subscribe_id);
                sound_focus->subscribe_id = 0;
        }
-       if( sound_focus->connected_id > 0 )
-       {
+       if (sound_focus->connected_id > 0) {
                ret = mm_sound_remove_device_connected_callback(sound_focus->connected_id);
-               if(ret != MM_ERROR_NONE)
+               if (ret != MM_ERROR_NONE)
                        LOGE("failed to mm_sound_remove_device_connected_callback() %d", sound_focus->connected_id);
                sound_focus->connected_id = 0;
        }
index b6b433f..ef33a96 100644 (file)
@@ -46,38 +46,35 @@ int _mmplayer_get_track_count(MMHandleType hplayer,  MMPlayerTrackType type, int
        MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
        MMPLAYER_RETURN_VAL_IF_FAIL(count, MM_ERROR_COMMON_INVALID_ARGUMENT);
        MMPLAYER_RETURN_VAL_IF_FAIL((MMPLAYER_CURRENT_STATE(player) != MM_PLAYER_STATE_PAUSED)
-                ||(MMPLAYER_CURRENT_STATE(player) != MM_PLAYER_STATE_PLAYING),
+                || (MMPLAYER_CURRENT_STATE(player) != MM_PLAYER_STATE_PLAYING),
                MM_ERROR_PLAYER_INVALID_STATE);
 
        attrs = MMPLAYER_GET_ATTRS(player);
-       if ( !attrs )
-       {
+       if (!attrs) {
                LOGE("cannot get content attribute");
                return MM_ERROR_PLAYER_INTERNAL;
        }
 
-       switch (type)
-       {
-               case MM_PLAYER_TRACK_TYPE_AUDIO:
+       switch (type) {
+       case MM_PLAYER_TRACK_TYPE_AUDIO:
                        {
                                /*if function called for normal file [no multi audio] */
-                               if(player->selector[MM_PLAYER_TRACK_TYPE_AUDIO].total_track_num <= 0)
-                               {
+                               if (player->selector[MM_PLAYER_TRACK_TYPE_AUDIO].total_track_num <= 0) {
                                        *count = 0;
                                        break;
                                }
                                ret = mm_attrs_get_int_by_name(attrs, "content_audio_track_num", count);
                        }
-                       break;
-               case MM_PLAYER_TRACK_TYPE_TEXT:
+               break;
+       case MM_PLAYER_TRACK_TYPE_TEXT:
                        ret = mm_attrs_get_int_by_name(attrs, "content_text_track_num", count);
-                       break;
-               default:
+               break;
+       default:
                        ret = MM_ERROR_COMMON_INVALID_ARGUMENT;
-                       break;
+               break;
        }
 
-       LOGD ("%d track num : %d\n", type, *count);
+       LOGD("%d track num : %d\n", type, *count);
 
        MMPLAYER_FLEAVE();
 
@@ -92,46 +89,39 @@ int _mmplayer_select_track(MMHandleType hplayer, MMPlayerTrackType type, int ind
        MMPLAYER_FENTER();
 
 
-       if (type == MM_PLAYER_TRACK_TYPE_TEXT && player->subtitle_language_list)
-       {
+       if (type == MM_PLAYER_TRACK_TYPE_TEXT && player->subtitle_language_list) {
                GstElement *subparse = NULL;
                MMPlayerLangStruct *temp = NULL;
                unsigned long cur_time = 0;
                guint num_of_list = 0;
 
-               if(!player->pipeline || !player->pipeline->textbin[MMPLAYER_T_FAKE_SINK].gst)
-               {
+               if (!player->pipeline || !player->pipeline->textbin[MMPLAYER_T_FAKE_SINK].gst) {
                        ret = MM_ERROR_PLAYER_NOT_INITIALIZED;
                        goto EXIT;
                }
 
                num_of_list = g_list_length(player->subtitle_language_list);
-               if (index < 0 || index >= num_of_list)
-               {
+               if (index < 0 || index >= num_of_list) {
                        LOGE("req track index is wrong");
                        ret = MM_ERROR_INVALID_ARGUMENT;
                        goto EXIT;
                }
 
-               _mmplayer_get_position (hplayer, MM_PLAYER_POS_FORMAT_TIME, &cur_time);
-               temp = g_list_nth_data (player->subtitle_language_list, index);
-               if (!temp)
-               {
+               _mmplayer_get_position(hplayer, MM_PLAYER_POS_FORMAT_TIME, &cur_time);
+               temp = g_list_nth_data(player->subtitle_language_list, index);
+               if (!temp) {
                        LOGE("fail to get lang from list");
                        ret = MM_ERROR_PLAYER_INTERNAL;
                        goto EXIT;
                }
                subparse = player->pipeline->mainbin[MMPLAYER_M_SUBPARSE].gst;
                LOGD("setting to language %s", temp->language_code);
-               g_object_set (G_OBJECT (subparse), "current-language", temp->language_key, NULL);
+               g_object_set(G_OBJECT(subparse), "current-language", temp->language_key, NULL);
 
                _mmplayer_sync_subtitle_pipeline(player);
 
-       }
-       else
-       {
-               ret = _mmplayer_change_track_language (hplayer, type, index);
-       }
+       } else
+               ret = _mmplayer_change_track_language(hplayer, type, index);
 
 EXIT:
        MMPLAYER_FLEAVE();
@@ -146,20 +136,17 @@ int _mmplayer_track_add_subtitle_language(MMHandleType hplayer, int index)
        MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
        MMPLAYER_FENTER();
 
-       if(!player->pipeline || !player->pipeline->mainbin[MMPLAYER_M_T_SUBMUX_EXTERNAL].gst)
-       {
+       if (!player->pipeline || !player->pipeline->mainbin[MMPLAYER_M_T_SUBMUX_EXTERNAL].gst) {
                ret = MM_ERROR_PLAYER_NOT_INITIALIZED;
                goto EXIT;
        }
 
-       if (player->subtitle_language_list)
-       {
+       if (player->subtitle_language_list) {
                GstElement *subparse = NULL;
                MMPlayerLangStruct *temp = NULL;
 
-               temp = g_list_nth_data (player->subtitle_language_list, index);
-               if (!temp)
-               {
+               temp = g_list_nth_data(player->subtitle_language_list, index);
+               if (!temp) {
                        LOGE("fail to get lang from list");
                        ret = MM_ERROR_PLAYER_INTERNAL;
                        goto EXIT;
@@ -168,13 +155,11 @@ int _mmplayer_track_add_subtitle_language(MMHandleType hplayer, int index)
 
                subparse = player->pipeline->mainbin[MMPLAYER_M_T_SUBMUX_EXTERNAL].gst;
                LOGD("adding to language %s", temp->language_code);
-               g_object_set (G_OBJECT (subparse), "current-language", temp->language_key, NULL);
-               g_object_set (G_OBJECT (subparse), "lang-list", player->subtitle_language_list, NULL);
+               g_object_set(G_OBJECT(subparse), "current-language", temp->language_key, NULL);
+               g_object_set(G_OBJECT(subparse), "lang-list", player->subtitle_language_list, NULL);
 
                _mmplayer_sync_subtitle_pipeline(player);
-       }
-       else
-       {
+       } else {
                LOGW("It is for just subtitle track");
                ret = MM_ERROR_PLAYER_NO_OP;
                goto EXIT;
@@ -192,20 +177,17 @@ int _mmplayer_track_remove_subtitle_language(MMHandleType hplayer, int index)
        MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
        MMPLAYER_FENTER();
 
-       if(!player->pipeline || !player->pipeline->mainbin[MMPLAYER_M_T_SUBMUX_EXTERNAL].gst)
-       {
+       if (!player->pipeline || !player->pipeline->mainbin[MMPLAYER_M_T_SUBMUX_EXTERNAL].gst) {
                ret = MM_ERROR_PLAYER_NOT_INITIALIZED;
                goto EXIT;
        }
 
-       if (player->subtitle_language_list)
-       {
+       if (player->subtitle_language_list) {
                GstElement *subparse = NULL;
                MMPlayerLangStruct *temp = NULL;
 
-               temp = g_list_nth_data (player->subtitle_language_list, index);
-               if (!temp)
-               {
+               temp = g_list_nth_data(player->subtitle_language_list, index);
+               if (!temp) {
                        LOGE("fail to get lang from list");
                        ret = MM_ERROR_PLAYER_INTERNAL;
                        goto EXIT;
@@ -214,13 +196,11 @@ int _mmplayer_track_remove_subtitle_language(MMHandleType hplayer, int index)
 
                subparse = player->pipeline->mainbin[MMPLAYER_M_T_SUBMUX_EXTERNAL].gst;
                LOGD("removing to language %s", temp->language_code);
-               g_object_set (G_OBJECT (subparse), "current-language", temp->language_key, NULL);
-               g_object_set (G_OBJECT (subparse), "lang-list", player->subtitle_language_list, NULL);
+               g_object_set(G_OBJECT(subparse), "current-language", temp->language_key, NULL);
+               g_object_set(G_OBJECT(subparse), "lang-list", player->subtitle_language_list, NULL);
 
                _mmplayer_sync_subtitle_pipeline(player);
-       }
-       else
-       {
+       } else {
                LOGW("It is for just subtitle track");
                ret = MM_ERROR_PLAYER_NO_OP;
                goto EXIT;
@@ -238,15 +218,13 @@ int _mmplayer_get_current_track(MMHandleType hplayer, MMPlayerTrackType type, in
        MMPLAYER_RETURN_VAL_IF_FAIL(player, MM_ERROR_PLAYER_NOT_INITIALIZED);
        MMPLAYER_FENTER();
 
-       if (type >= MM_PLAYER_TRACK_TYPE_MAX)
-       {
+       if (type >= MM_PLAYER_TRACK_TYPE_MAX) {
                ret = MM_ERROR_INVALID_ARGUMENT;
                LOGD("Not a proper type [type:%d] \n", type);
                goto EXIT;
        }
 
-       if (type == MM_PLAYER_TRACK_TYPE_TEXT && player->subtitle_language_list)
-       {
+       if (type == MM_PLAYER_TRACK_TYPE_TEXT && player->subtitle_language_list) {
                GstElement *subparse = NULL;
                int total_track_count = 0;
                gchar* current_language = NULL;
@@ -254,8 +232,7 @@ int _mmplayer_get_current_track(MMHandleType hplayer, MMPlayerTrackType type, in
                MMHandleType attrs = 0;
 
                attrs = MMPLAYER_GET_ATTRS(player);
-               if (!attrs)
-               {
+               if (!attrs) {
                        LOGE("cannot get content attribute");
                        ret = MM_ERROR_PLAYER_INTERNAL;
                        goto EXIT;
@@ -264,16 +241,13 @@ int _mmplayer_get_current_track(MMHandleType hplayer, MMPlayerTrackType type, in
                mm_attrs_get_int_by_name(attrs, "content_text_track_num", &total_track_count);
 
                subparse = player->pipeline->mainbin[MMPLAYER_M_SUBPARSE].gst;
-               g_object_get (G_OBJECT (subparse), "current-language", &current_language, NULL);
-               LOGD("current language is %s ",current_language);
-               while (total_track_count)
-               {
-                       temp = g_list_nth_data (player->subtitle_language_list, total_track_count - 1);
-                       if (temp)
-                       {
+               g_object_get(G_OBJECT(subparse), "current-language", &current_language, NULL);
+               LOGD("current language is %s ", current_language);
+               while (total_track_count) {
+                       temp = g_list_nth_data(player->subtitle_language_list, total_track_count - 1);
+                       if (temp) {
                                LOGD("find the list");
-                               if (!strcmp(temp->language_key, current_language))
-                               {
+                               if (!strcmp(temp->language_key, current_language)) {
                                        *index = total_track_count - 1;
                                        LOGD("current lang index  is %d", *index);
                                        break;
@@ -281,16 +255,12 @@ int _mmplayer_get_current_track(MMHandleType hplayer, MMPlayerTrackType type, in
                        }
                        total_track_count--;
                }
-       }
-       else
-       {
-               if (player->selector[type].total_track_num <= 0)
-               {
+       } else {
+               if (player->selector[type].total_track_num <= 0) {
                        ret = MM_ERROR_PLAYER_NO_OP;
                        LOGD("there is no track information [type:%d] \n", type);
                        goto EXIT;
                }
-
                *index = player->selector[type].active_pad_index;
        }
 
@@ -307,38 +277,31 @@ int _mmplayer_get_track_language_code(MMHandleType hplayer, MMPlayerTrackType ty
        mm_player_t* player = (mm_player_t*) hplayer;
        MMPLAYER_FENTER();
 
-       if (type == MM_PLAYER_TRACK_TYPE_TEXT && player->subtitle_language_list)
-       {
+       if (type == MM_PLAYER_TRACK_TYPE_TEXT && player->subtitle_language_list) {
                int language_code_size = 3;/*Size of ISO-639-1*/
                MMPlayerLangStruct *language_list = NULL;
 
                *code = (char*)malloc(language_code_size * sizeof(char));
-               if (*code == NULL)
-               {
+               if (*code == NULL) {
                        ret = MM_ERROR_PLAYER_INTERNAL;
                        goto EXIT;
                }
                memset(*code, 0, language_code_size * sizeof(char));
 
-               language_list = g_list_nth_data (player->subtitle_language_list, index);
-               if (language_list == NULL)
-               {
-                       LOGD ("%d is not a proper index \n", index);
+               language_list = g_list_nth_data(player->subtitle_language_list, index);
+               if (language_list == NULL) {
+                       LOGD("%d is not a proper index \n", index);
                        goto EXIT;
                }
                strncpy(*code, language_list->language_code, language_code_size);
-       }
-       else
-       {
-               if (player->selector[type].total_track_num <= 0)
-               {
+       } else {
+               if (player->selector[type].total_track_num <= 0) {
                        ret = MM_ERROR_PLAYER_NO_OP;
                        LOGD("language list is not available. [type:%d] \n", type);
                        goto EXIT;
                }
 
-               if(index < 0 || index >= player->selector[type].total_track_num)
-               {
+               if (index < 0 || index >= player->selector[type].total_track_num) {
                        ret = MM_ERROR_INVALID_ARGUMENT;
                        LOGD("Not a proper index : %d \n", index);
                        goto EXIT;
@@ -358,8 +321,7 @@ void _mmplayer_track_initialize(mm_player_t* player)
 
        MMPLAYER_FENTER();
 
-       for (;type<MM_PLAYER_TRACK_TYPE_MAX ; type++)
-       {
+       for (; type < MM_PLAYER_TRACK_TYPE_MAX ; type++) {
                /* active_pad_index is initialized when player is created or destroyed.
                   and the value can be set by calling _mmplayer_change_track_language()
                   before pipeline is created.*/
@@ -375,23 +337,21 @@ void _mmplayer_track_destroy(mm_player_t* player)
        MMPLAYER_FENTER();
 
        attrs = MMPLAYER_GET_ATTRS(player);
-       if (attrs)
-       {
+       if (attrs) {
                mm_attrs_set_int_by_name(attrs, "content_audio_track_num", 0);
                mm_attrs_set_int_by_name(attrs, "content_video_track_num", 0);
                mm_attrs_set_int_by_name(attrs, "content_text_track_num", 0);
 
-               if (mmf_attrs_commit (attrs))
+               if (mmf_attrs_commit(attrs))
                        LOGE("failed to commit.\n");
        }
 
-       for (;type<MM_PLAYER_TRACK_TYPE_MAX ; type++)
-       {
+       for (; type < MM_PLAYER_TRACK_TYPE_MAX ; type++) {
                player->selector[type].active_pad_index = 0;
                player->selector[type].total_track_num = 0;
 
                if (player->selector[type].channels)
-                       g_ptr_array_free (player->selector[type].channels, TRUE);
+                       g_ptr_array_free(player->selector[type].channels, TRUE);
                player->selector[type].channels = NULL;
        }
 }
@@ -401,9 +361,9 @@ void _mmplayer_track_update_info(mm_player_t* player, MMPlayerTrackType type, Gs
        MMPLAYER_FENTER();
 
        player->selector[type].total_track_num++;
-       g_ptr_array_add (player->selector[type].channels, sinkpad);
+       g_ptr_array_add(player->selector[type].channels, sinkpad);
 
-       LOGD ("type:%d, total track:%d\n", type, player->selector[type].total_track_num);
+       LOGD("type:%d, total track:%d\n", type, player->selector[type].total_track_num);
 }
 
 static int __mmplayer_track_get_language(mm_player_t* player, MMPlayerTrackType type, gint stream_index, gchar **code)
@@ -418,51 +378,44 @@ static int __mmplayer_track_get_language(mm_player_t* player, MMPlayerTrackType
        MMPLAYER_FENTER();
 
        *code = (char *)malloc(language_code_size*sizeof(char));
-       if(*code == NULL)
-       {
+       if (*code == NULL) {
                ret = MM_ERROR_PLAYER_INTERNAL;
                goto EXIT;
        }
-       memset(*code,0,language_code_size*sizeof(char));
+       memset(*code, 0, language_code_size*sizeof(char));
 
-       LOGD ("total track num : %d , req idx : %d\n", player->selector[type].total_track_num, stream_index);
+       LOGD("total track num : %d , req idx : %d\n", player->selector[type].total_track_num, stream_index);
 
-       if (stream_index < player->selector[type].total_track_num)
-       {
-               sinkpad = g_ptr_array_index (player->selector[type].channels, stream_index);
-       }
-       else
-       {
+       if (stream_index < player->selector[type].total_track_num) {
+               sinkpad = g_ptr_array_index(player->selector[type].channels, stream_index);
+       } else {
                ret = MM_ERROR_INVALID_ARGUMENT;
                goto EXIT;
        }
 
-       g_object_get (sinkpad, "tags", &tag_list, NULL);
+       g_object_get(sinkpad, "tags", &tag_list, NULL);
        //SECURE_LOGD ("[%s]\n", gst_tag_list_to_string(tag_list));
 
-       gst_tag_list_get_string (tag_list, GST_TAG_LANGUAGE_CODE, &tag);
+       gst_tag_list_get_string(tag_list, GST_TAG_LANGUAGE_CODE, &tag);
 
-       if(!tag)
-       {
+       if (!tag) {
                LOGD("there is no lang info - und\n");
                strncpy(*code, "und", language_code_size);
-       }
-       else
-       {
+       } else {
                LOGD("language information[%d] code: %s, len: %d \n", type, tag, strlen(tag));
                strncpy(*code, tag, /*strlen(tag)*/language_code_size);
-               g_free (tag);
+               g_free(tag);
        }
 
        if (tag_list)
-               gst_tag_list_free (tag_list);
+               gst_tag_list_free(tag_list);
 
 EXIT:
        MMPLAYER_FLEAVE();
        return ret;
 }
 #ifdef _MULTI_TRACK
-int _mmplayer_track_foreach_selected_subtitle_language(MMHandleType hplayer,_mmplayer_track_selected_subtitle_language_cb foreach_cb, void *user_data)
+int _mmplayer_track_foreach_selected_subtitle_language(MMHandleType hplayer, _mmplayer_track_selected_subtitle_language_cb foreach_cb, void *user_data)
 {
        int ret = MM_ERROR_NONE;
        mm_player_t* player = (mm_player_t*) hplayer;
@@ -471,40 +424,33 @@ int _mmplayer_track_foreach_selected_subtitle_language(MMHandleType hplayer,_mmp
 
        int index = -1;
 
-       if (player->subtitle_language_list)
-       {
+       if (player->subtitle_language_list) {
                int total_track_count = 0;
                MMPlayerLangStruct *temp = NULL;
                MMHandleType attrs = 0;
 
                attrs = MMPLAYER_GET_ATTRS(player);
-               if (!attrs)
-               {
+               if (!attrs) {
                        LOGE("cannot get content attribute");
                        ret = MM_ERROR_PLAYER_INTERNAL;
                        goto EXIT;
                }
                mm_attrs_get_int_by_name(attrs, "content_text_track_num", &total_track_count);
 
-               if(!total_track_count)
-               {
+               if (!total_track_count) {
                        LOGW("There are no subtitle track selected.");
                        ret = MM_ERROR_PLAYER_NO_OP;
                        goto EXIT;
                }
 
-               while (total_track_count)
-               {
-                       temp = g_list_nth_data (player->subtitle_language_list, total_track_count - 1);
-                       if (temp)
-                       {
+               while (total_track_count) {
+                       temp = g_list_nth_data(player->subtitle_language_list, total_track_count - 1);
+                       if (temp) {
                                LOGD("find the list");
-                               if (temp->active)
-                               {
+                               if (temp->active) {
                                        index = total_track_count - 1;
                                        LOGD("active subtitle track index is %d", index);
-                                       if (!foreach_cb(index, user_data))
-                                       {
+                                       if (!foreach_cb(index, user_data)) {
                                                ret = MM_ERROR_PLAYER_INTERNAL;
                                                goto CALLBACK_ERROR;
                                        }
@@ -516,8 +462,7 @@ int _mmplayer_track_foreach_selected_subtitle_language(MMHandleType hplayer,_mmp
                LOGD("we will return -1 for notifying the end to user");
 
                /* After returning all selected indexs, we will return -1 for notifying the end to user */
-               if (!foreach_cb(-1, user_data))
-               {
+               if (!foreach_cb(-1, user_data)) {
                        ret = MM_ERROR_PLAYER_INTERNAL;
                        goto CALLBACK_ERROR;
                }
index 5207981..99fdab7 100644 (file)
@@ -41,10 +41,9 @@ int util_exist_file_path(const char *file_path)
        if (!file_path || !strlen(file_path))
                return MM_ERROR_PLAYER_FILE_NOT_FOUND;
 
-       fd = open (file_path, O_RDONLY);
+       fd = open(file_path, O_RDONLY);
 
-       if (fd < 0)
-       {
+       if (fd < 0) {
                char str_error[256];
                strerror_r(errno, str_error, sizeof(str_error));
                LOGE("failed to open file by %s (%d)", str_error, errno);
@@ -55,20 +54,14 @@ int util_exist_file_path(const char *file_path)
                return MM_ERROR_PLAYER_FILE_NOT_FOUND;
        }
 
-       if (fstat(fd, &stat_results) < 0)
-       {
+       if (fstat(fd, &stat_results) < 0) {
                LOGE("failed to get file status");
-       }
-       else if (stat_results.st_size == 0)
-       {
+       } else if (stat_results.st_size == 0) {
                LOGE("file size is zero");
                close(fd);
                return MM_ERROR_PLAYER_FILE_NOT_FOUND;
-       }
-       else
-       {
+       } else
                LOGW("file size : %lld bytes", (long long)stat_results.st_size);
-       }
 
        close(fd);
 
@@ -106,8 +99,7 @@ bool util_remove_file_backup(const char *backup_path)
                return FALSE;
 
        int res = access(backup_path, R_OK);
-       if (!res)
-       {
+       if (!res) {
                if (remove(backup_path) == -1)
                        return FALSE;
        }
@@ -131,12 +123,12 @@ int util_is_midi_type_by_mem(void *mem, int size)
 
        /* midi file detection */
        if (p[0] == 'M' && p[1] == 'T' && p[2] == 'h' && p[3] == 'd') {
-               LOGD ("MM_AUDIO_CODEC_MIDI, %d\n", MM_AUDIO_CODEC_MIDI);
+               LOGD("MM_AUDIO_CODEC_MIDI, %d\n", MM_AUDIO_CODEC_MIDI);
                return MM_AUDIO_CODEC_MIDI;
        }
        /* mxmf file detection */
        if (p[0] == 'X' && p[1] == 'M' && p[2] == 'F' && p[3] == '_') {
-               LOGD ("MM_AUDIO_CODEC_MXMF\n");
+               LOGD("MM_AUDIO_CODEC_MXMF\n");
                return MM_AUDIO_CODEC_MXMF;
        }
 
@@ -144,13 +136,12 @@ int util_is_midi_type_by_mem(void *mem, int size)
        if (p[0] == 'R' && p[1] == 'I' && p[2] == 'F' && p[3] == 'F' &&
                p[8] == 'W' && p[9] == 'A' && p[10] == 'V' && p[11] == 'E' &&
                p[12] == 'f' && p[13] == 'm' && p[14] == 't') {
-               LOGD ("MM_AUDIO_CODEC_WAVE\n");
+               LOGD("MM_AUDIO_CODEC_WAVE\n");
                return MM_AUDIO_CODEC_WAVE;
        }
        /* i-melody file detection */
-       if (memcmp(p, "BEGIN:IMELODY", 13) == 0)
-       {
-               LOGD ("MM_AUDIO_CODEC_IMELODY\n");
+       if (memcmp(p, "BEGIN:IMELODY", 13) == 0) {
+               LOGD("MM_AUDIO_CODEC_IMELODY\n");
                return MM_AUDIO_CODEC_IMELODY;
        }
 
@@ -174,16 +165,14 @@ int util_is_midi_type_by_file(const char *file_path)
 
        memset(&file_attrib, 0, sizeof(file_attrib));
 
-       if (stat(file_path, &file_attrib) != 0)
-       {
+       if (stat(file_path, &file_attrib) != 0) {
                fclose(fp);
                return FALSE;
        }
 
        size = (int) file_attrib.st_size;
 
-       if (size < DETECTION_PREFIX_SIZE)
-       {
+       if (size < DETECTION_PREFIX_SIZE) {
                fclose(fp);
                return FALSE;
        }
@@ -196,13 +185,13 @@ int util_is_midi_type_by_file(const char *file_path)
 }
 
 char**
-util_get_cookie_list ( const char *cookies )
+util_get_cookie_list(const char *cookies)
 {
        char **cookie_list = NULL;
        char *temp = NULL;
        gint i = 0;
 
-       if ( !cookies || !strlen(cookies) )
+       if (!cookies || !strlen(cookies))
                return NULL;
 
        SECURE_LOGD("cookies : %d[bytes] - %s \n", strlen(cookies), cookies);
@@ -215,39 +204,32 @@ util_get_cookie_list ( const char *cookies )
        /* split */
        cookie_list = g_strsplit(temp, ";", 100);
 
-       for ( i = 0; i < g_strv_length(cookie_list); i++ )
-       {
-               if (cookie_list[i])
-               {
-                       if (strlen(cookie_list[i]))
-                       {
+       for (i = 0; i < g_strv_length(cookie_list); i++) {
+               if (cookie_list[i]) {
+                       if (strlen(cookie_list[i])) {
                                g_strstrip(cookie_list[i]);
                                SECURE_LOGD("cookie_list[%d] : %d[bytes] - %s \n", i, strlen(cookie_list[i]), cookie_list[i]);
-                       }
-                       else
-                       {
-                               cookie_list[i][0]='\0';
-                       }
+                       } else
+                               cookie_list[i][0] = '\0';
                }
        }
 
        if (temp)
-               g_free (temp);
-       temp=NULL;
+               g_free(temp);
+       temp = NULL;
 
        return cookie_list;
 }
 
-bool util_check_valid_url ( const char *proxy )
+bool util_check_valid_url(const char *proxy)
 {
        struct in_addr proxy_addr;
        bool ret = TRUE;
 
-       MMPLAYER_RETURN_VAL_IF_FAIL ( proxy, FALSE );
-       MMPLAYER_RETURN_VAL_IF_FAIL ( strlen(proxy), FALSE );
+       MMPLAYER_RETURN_VAL_IF_FAIL(proxy, FALSE);
+       MMPLAYER_RETURN_VAL_IF_FAIL(strlen(proxy), FALSE);
 
-       if ( inet_aton(proxy, &proxy_addr) != 0 )
-       {
+       if (inet_aton(proxy, &proxy_addr) != 0) {
                LOGW("invalid proxy is set. \n");
                ret = FALSE;
        }
@@ -257,67 +239,63 @@ bool util_check_valid_url ( const char *proxy )
 
 /* check the given path is indicating sdp file */
 bool
-util_is_sdp_file ( const char *path )
+util_is_sdp_file(const char *path)
 {
        gboolean ret = FALSE;
        gchar* uri = NULL;
 
        MMPLAYER_FENTER();
 
-       MMPLAYER_RETURN_VAL_IF_FAIL ( path, FALSE );
+       MMPLAYER_RETURN_VAL_IF_FAIL(path, FALSE);
 
-       uri = g_ascii_strdown ( path, -1 );
+       uri = g_ascii_strdown(path, -1);
 
-       if ( uri == NULL)
-       {
+       if (uri == NULL)
                return FALSE;
-       }
 
        /* trimming */
-       g_strstrip( uri );
+       g_strstrip(uri);
 
        /* strlen(".sdp") == 4 */
-       if ( strlen( uri ) <= 4 )
-       {
-               LOGW ( "path is too short.\n" );
+       if (strlen(uri) <= 4) {
+               LOGW("path is too short.\n");
                return ret;
        }
 
        /* first, check extension name */
-       ret = g_str_has_suffix ( uri, "sdp" );
+       ret = g_str_has_suffix(uri, "sdp");
 
        /* second, if no suffix is there, check it's contents */
-       if ( ! ret )
-       {
+       if (!ret)
                /* FIXIT : do it soon */
-       }
+               LOGD("no suffix");
 
-       g_free( uri);
+       g_free(uri);
        uri = NULL;
 
        return ret;
 }
 
 int64_t
-util_get_time ( void )
+util_get_time(void)
 {
        struct timeval tv;
-       gettimeofday(&tv,NULL);
+       gettimeofday(&tv, NULL);
        return (int64_t)tv.tv_sec * 1000000 + tv.tv_usec;
 }
 
 int
-util_get_rank_increase ( const char *factory_class )
+util_get_rank_increase(const char *factory_class)
 {
        gint rank_pri_inc = 20;
        gint rank_sec_inc = 10;
        gint ret = 0;
 
-       if ( g_strrstr(factory_class,"Dsp") )
+       if (g_strrstr(factory_class, "Dsp"))
                ret = rank_pri_inc;
-       else if ( g_strrstr(factory_class,"HW") )
+       else if (g_strrstr(factory_class, "HW"))
                ret = rank_pri_inc;
-       else if ( g_strrstr(factory_class,"Arm") )
+       else if (g_strrstr(factory_class, "Arm"))
                ret = rank_sec_inc;
 
        return ret;
@@ -327,15 +305,15 @@ int
 util_factory_rank_compare(GstPluginFeature *f1, GstPluginFeature *f2)
 {
        const gchar *klass;
-       int f1_rank_inc=0, f2_rank_inc=0;
+       int f1_rank_inc = 0, f2_rank_inc = 0;
 
        klass = gst_element_factory_get_klass(GST_ELEMENT_FACTORY(f1));
-       f1_rank_inc = util_get_rank_increase ( klass );
+       f1_rank_inc = util_get_rank_increase(klass);
 
        klass = gst_element_factory_get_klass(GST_ELEMENT_FACTORY(f2));
-       f2_rank_inc = util_get_rank_increase ( klass );
+       f2_rank_inc = util_get_rank_increase(klass);
 
-       return (gst_plugin_feature_get_rank(f2)+f2_rank_inc) - (gst_plugin_feature_get_rank(f1)+f1_rank_inc );
+       return (gst_plugin_feature_get_rank(f2)+f2_rank_inc) - (gst_plugin_feature_get_rank(f1)+f1_rank_inc);
 }
 
 const char*
@@ -347,65 +325,62 @@ util_get_charset(const char *file_path)
 
        const char* charset = NULL;
        char *buf = NULL;
-       FILE* fin =0;
+       FILE* fin = 0;
        size_t n_size = 0;
 
        fin = fopen(file_path, "r");
-       if (!fin)
-       {
+       if (!fin) {
                SECURE_LOGE("fail to open file %s\n", file_path);
                return NULL;
        }
 
-       ucsd = ucsdet_open( &status );
-       if( U_FAILURE(status) ) {
+       ucsd = ucsdet_open(&status);
+       if (U_FAILURE(status)) {
                LOGE("fail to ucsdet_open\n");
                goto done;
        }
 
-       ucsdet_enableInputFilter( ucsd, TRUE );
+       ucsdet_enableInputFilter(ucsd, TRUE);
 
        buf = g_malloc(1024*1024);
-       if (!buf)
-       {
+       if (!buf) {
                LOGE("fail to alloc\n");
                goto done;
        }
 
-       n_size = fread( buf, 1, 1024*1024, fin );
+       n_size = fread(buf, 1, 1024*1024, fin);
 
        if (!n_size)
                goto done;
 
-       ucsdet_setText( ucsd, buf, strlen(buf), &status );
-       if( U_FAILURE(status) ) {
+       ucsdet_setText(ucsd, buf, strlen(buf), &status);
+       if (U_FAILURE(status)) {
                LOGE("fail to ucsdet_setText\n");
                goto done;
        }
 
-       ucm = ucsdet_detect( ucsd, &status );
-       if( U_FAILURE(status) ) {
+       ucm = ucsdet_detect(ucsd, &status);
+       if (U_FAILURE(status)) {
                LOGE("fail to ucsdet_detect\n");
                goto done;
        }
 
-       charset = ucsdet_getName( ucm, &status );
-       if( U_FAILURE(status) ) {
+       charset = ucsdet_getName(ucm, &status);
+       if (U_FAILURE(status)) {
                LOGE("fail to ucsdet_getName\n");
                goto done;
        }
 
        /* CP949 encoding is an extension of the EUC-KR and it is backwards compatible.*/
-       if(charset && !strcmp(charset, "EUC-KR")) {
+       if (charset && !strcmp(charset, "EUC-KR"))
                charset = "CP949";
-       }
 
 done:
-       if(fin)
+       if (fin)
                fclose(fin);
 
-       if(ucsd)
-               ucsdet_close( ucsd );
+       if (ucsd)
+               ucsdet_close(ucsd);
 
        if (buf)
                g_free(buf);
@@ -421,65 +396,65 @@ int util_get_pixtype(unsigned int fourcc)
        char *pfourcc = (char*)&fourcc;
 
        LOGD("fourcc(%c%c%c%c)",
-                        pfourcc[0], pfourcc[1], pfourcc[2], pfourcc[3]);
+               pfourcc[0], pfourcc[1], pfourcc[2], pfourcc[3]);
     */
 
        switch (fourcc) {
-       case GST_MAKE_FOURCC ('S', 'N', '1', '2'):
-       case GST_MAKE_FOURCC ('N', 'V', '1', '2'):
+       case GST_MAKE_FOURCC('S', 'N', '1', '2'):
+       case GST_MAKE_FOURCC('N', 'V', '1', '2'):
                pixtype = MM_PIXEL_FORMAT_NV12;
                break;
-       case GST_MAKE_FOURCC ('S', 'T', '1', '2'):
+       case GST_MAKE_FOURCC('S', 'T', '1', '2'):
                pixtype = MM_PIXEL_FORMAT_NV12T;
                break;
-       case GST_MAKE_FOURCC ('S', 'N', '2', '1'):
-       case GST_MAKE_FOURCC ('N', 'V', '2', '1'):
+       case GST_MAKE_FOURCC('S', 'N', '2', '1'):
+       case GST_MAKE_FOURCC('N', 'V', '2', '1'):
                pixtype = MM_PIXEL_FORMAT_NV21;
                break;
-       case GST_MAKE_FOURCC ('S', 'U', 'Y', 'V'):
-       case GST_MAKE_FOURCC ('Y', 'U', 'Y', 'V'):
-       case GST_MAKE_FOURCC ('Y', 'U', 'Y', '2'):
+       case GST_MAKE_FOURCC('S', 'U', 'Y', 'V'):
+       case GST_MAKE_FOURCC('Y', 'U', 'Y', 'V'):
+       case GST_MAKE_FOURCC('Y', 'U', 'Y', '2'):
                pixtype = MM_PIXEL_FORMAT_YUYV;
                break;
-       case GST_MAKE_FOURCC ('S', 'Y', 'V', 'Y'):
-       case GST_MAKE_FOURCC ('U', 'Y', 'V', 'Y'):
+       case GST_MAKE_FOURCC('S', 'Y', 'V', 'Y'):
+       case GST_MAKE_FOURCC('U', 'Y', 'V', 'Y'):
                pixtype = MM_PIXEL_FORMAT_UYVY;
                break;
-       case GST_MAKE_FOURCC ('S', '4', '2', '0'):
-       case GST_MAKE_FOURCC ('I', '4', '2', '0'):
+       case GST_MAKE_FOURCC('S', '4', '2', '0'):
+       case GST_MAKE_FOURCC('I', '4', '2', '0'):
                pixtype = MM_PIXEL_FORMAT_I420;
                break;
-       case GST_MAKE_FOURCC ('Y', 'V', '1', '2'):
+       case GST_MAKE_FOURCC('Y', 'V', '1', '2'):
                pixtype = MM_PIXEL_FORMAT_YV12;
                break;
-       case GST_MAKE_FOURCC ('4', '2', '2', 'P'):
+       case GST_MAKE_FOURCC('4', '2', '2', 'P'):
                pixtype = MM_PIXEL_FORMAT_422P;
                break;
-       case GST_MAKE_FOURCC ('R', 'G', 'B', 'P'):
+       case GST_MAKE_FOURCC('R', 'G', 'B', 'P'):
                pixtype = MM_PIXEL_FORMAT_RGB565;
                break;
-       case GST_MAKE_FOURCC ('R', 'G', 'B', '3'):
+       case GST_MAKE_FOURCC('R', 'G', 'B', '3'):
                pixtype = MM_PIXEL_FORMAT_RGB888;
                break;
-       case GST_MAKE_FOURCC ('A', 'R', 'G', 'B'):
-       case GST_MAKE_FOURCC ('x', 'R', 'G', 'B'):
+       case GST_MAKE_FOURCC('A', 'R', 'G', 'B'):
+       case GST_MAKE_FOURCC('x', 'R', 'G', 'B'):
                pixtype = MM_PIXEL_FORMAT_ARGB;
                break;
-       case GST_MAKE_FOURCC ('B', 'G', 'R', 'A'):
-       case GST_MAKE_FOURCC ('B', 'G', 'R', 'x'):
-       case GST_MAKE_FOURCC ('S', 'R', '3', '2'):
+       case GST_MAKE_FOURCC('B', 'G', 'R', 'A'):
+       case GST_MAKE_FOURCC('B', 'G', 'R', 'x'):
+       case GST_MAKE_FOURCC('S', 'R', '3', '2'):
                pixtype = MM_PIXEL_FORMAT_RGBA;
                break;
-       case GST_MAKE_FOURCC ('J', 'P', 'E', 'G'):
-       case GST_MAKE_FOURCC ('P', 'N', 'G', ' '):
+       case GST_MAKE_FOURCC('J', 'P', 'E', 'G'):
+       case GST_MAKE_FOURCC('P', 'N', 'G', ' '):
                pixtype = MM_PIXEL_FORMAT_ENCODED;
                break;
-       case GST_MAKE_FOURCC ('I', 'T', 'L', 'V'):
+       case GST_MAKE_FOURCC('I', 'T', 'L', 'V'):
                pixtype = MM_PIXEL_FORMAT_ITLV_JPEG_UYVY;
                break;
        default:
                LOGE("Not supported fourcc type(%c%c%c%c)",
-                              fourcc, fourcc>>8, fourcc>>16, fourcc>>24);
+                       fourcc, fourcc>>8, fourcc>>16, fourcc>>24);
                pixtype = MM_PIXEL_FORMAT_INVALID;
                break;
        }