Apply to send pid of application and sound register 87/48187/4
authorHyongtaek Lim <hyongtaek.lim@samsung.com>
Tue, 15 Sep 2015 23:53:13 +0000 (08:53 +0900)
committerHyongtaek Lim <hyongtaek.lim@samsung.com>
Wed, 16 Sep 2015 04:47:49 +0000 (13:47 +0900)
Signed-off-by: Hyongtaek Lim <hyongtaek.lim@samsung.com>
Change-Id: I88df6405d9895e6308ee57950aec1a8c41fb20a7

client/src/player2.c
include/player2_private.h
include/player_msg_private.h
src/player_msg_dispatcher.c

index 309b3fc..4de0584 100644 (file)
@@ -17,6 +17,8 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <sys/types.h>
+#include <unistd.h>
 #include "glib.h"
 #include "tbm_bufmgr.h"
 #include "tbm_surface.h"
@@ -1037,6 +1039,7 @@ int player_create(player_h * player)
 
        int ret = PLAYER_ERROR_NONE;
        int sock_fd = -1;
+       int pid = getpid();
 
        mm_player_api_e api = MM_PLAYER_API_CREATE;
        mmsvc_api_client_e client = MMSVC_PLAYER;
@@ -1051,7 +1054,7 @@ int player_create(player_h * player)
                ret = PLAYER_ERROR_INVALID_OPERATION;
                goto ErrorExit;
        }
-       player_msg_send1_async(api, (intptr_t)player, sock_fd, INT, client);
+       player_msg_send2_async(api, (intptr_t)player, sock_fd, INT, client, INT, pid);
 
        pc = g_new0(player_cli_s, 1);
        if (pc == NULL) {
index 22ed77d..fc48fb1 100644 (file)
@@ -254,6 +254,8 @@ typedef struct _player_cli_s{
 /* external handle cast */
 #define EXT_HANDLE(h)          ((h)->remote_handle)
 
+int player_sound_register(player_h player, int pid);
+
 /**
  * @brief Called when the video sink bin is crated.
  * @since_tizen 3.0
index 11dc898..09432e8 100644 (file)
@@ -360,6 +360,34 @@ typedef struct {
        }while(0)
 
 /**
+ * @brief Create and send message. Does not wait server result.
+ * @remarks Does NOT guarantee thread safe.
+ * @param[in] api The enum of module API.
+ * @param[in] player The server side handle of media player.
+ * @param[in] fd socket fd
+ * @param[in] type The enum of parameter type. Muse be one of thease(INT, INT64, POINTER, DOUBLE, STRING, ARRAY)
+ * @param[in] param the name of param is key, must be local variable. never be pointer.
+ */
+#define player_msg_send2_async(api, player, fd, type1, param1, type2, param2) \
+       do{     \
+               char *__sndMsg__; \
+               int __len__; \
+               type1 __value1__ = (type1)param1; \
+               type2 __value2__ = (type2)param2; \
+               __sndMsg__ = mmsvc_core_msg_json_factory_new(api, PARAM_HANDLE, player, \
+                               MUSED_TYPE_##type1, #param1, __value1__, \
+                               MUSED_TYPE_##type2, #param2, __value2__, \
+                               0); \
+               __len__ = mmsvc_core_ipc_send_msg(fd, __sndMsg__); \
+               mmsvc_core_msg_json_factory_free(__sndMsg__); \
+               if (__len__ <= 0) { \
+                       LOGE("sending message failed"); \
+                       return PLAYER_ERROR_INVALID_OPERATION; \
+               } \
+       }while(0)
+
+
+/**
  * @brief Create and send message for callback. Does not wait server result.
  * @remarks Does NOT guarantee thread safe.
  * @param[in] api The enum of module API.
index e33e9f6..a0cd8a9 100644 (file)
@@ -577,10 +577,18 @@ static int player_disp_create(Client client)
        data_thread_info_t *thread_i;
        static guint stream_id = 0;
        char stream_path[STREAM_PATH_LENGTH];
+       int pid;
 
        ret = player_create(&player);
        LOGD("handle : %p, client : %p", player, client);
 
+       player_msg_get(pid, mmsvc_core_client_get_msg(client));
+
+       if(ret == PLAYER_ERROR_NONE)
+               ret = player_sound_register(player, pid);
+       else
+               player_msg_return(api, ret, client);
+
        if(ret == PLAYER_ERROR_NONE) {
                thread_i = g_new(data_thread_info_t, 1);
                thread_i->running = 1;
@@ -662,6 +670,7 @@ static int player_disp_prepare_async(Client client)
        prepare_data_t *prepare_data;
 
        player_msg_get_type(handle, mmsvc_core_client_get_msg(client), POINTER);
+
        player = (player_h) handle;
 
        prepare_data = g_new(prepare_data_t, 1);