1. Split audiobin/videobin into decodebin/sinkbin
[platform/core/multimedia/libmm-wfd.git] / sink / include / mm_wfd_sink_manager.h
1 /*
2  * libmm-wfd
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: JongHyuk Choi <jhchoi.choi@samsung.com>, YeJin Cho <cho.yejin@samsung.com>,
7  * Seungbae Shin <seungbae.shin@samsung.com>, YoungHwan An <younghwan_.an@samsung.com>
8  *
9  * Licensed under the Apache License, Version 2.0 (the "License");
10  * you may not use this file except in compliance with the License.
11  * You may obtain a copy of the License at
12  *
13  * http://www.apache.org/licenses/LICENSE-2.0
14  *
15  * Unless required by applicable law or agreed to in writing, software
16  * distributed under the License is distributed on an "AS IS" BASIS,
17  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18  * See the License for the specific language governing permissions and
19  * limitations under the License.
20  *
21  */
22
23 #ifndef __MM_WFD_SINK_MANAGER_H__
24 #define __MM_WFD_SINK_MANAGER_H__
25
26 /*=======================================================================================
27 | INCLUDE FILES                                                                         |
28 ========================================================================================*/
29 #include "mm_wfd_sink_priv.h"
30 #include "mm_wfd_sink_util.h"
31
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35
36 #define WFD_SINK_MANAGER_LOCK(wfd_sink) \
37         do {\
38                 if (wfd_sink) {\
39                         g_mutex_lock(&((wfd_sink)->manager_thread_mutex));\
40                 }\
41         } while (0);
42
43 #define WFD_SINK_MANAGER_UNLOCK(wfd_sink) \
44         do {\
45                 if (wfd_sink) {\
46                         g_mutex_unlock(&((wfd_sink)->manager_thread_mutex));\
47                 }\
48         } while (0);
49
50 #define WFD_SINK_MANAGER_WAIT_CMD(wfd_sink) \
51         do {\
52                 wfd_sink_debug("manager thread is waiting for command signal\n");\
53                 wfd_sink->waiting_cmd = TRUE; \
54                 g_cond_wait(&((wfd_sink)->manager_thread_cond), &((wfd_sink)->manager_thread_mutex)); \
55                 wfd_sink->waiting_cmd = FALSE; \
56         } while (0);
57
58 #define WFD_SINK_MANAGER_APPEND_CMD(wfd_sink, cmd) \
59         do {\
60                 WFD_SINK_MANAGER_LOCK(wfd_sink);\
61                 if (cmd == WFD_SINK_MANAGER_CMD_EXIT) {\
62                         g_list_free(wfd_sink->manager_thread_cmd);\
63                 }\
64                 wfd_sink->manager_thread_cmd = g_list_append(wfd_sink->manager_thread_cmd, GINT_TO_POINTER(cmd)); \
65                 WFD_SINK_MANAGER_UNLOCK(wfd_sink);\
66         } while (0);
67
68 #define WFD_SINK_MANAGER_SIGNAL_CMD(wfd_sink) \
69         do {\
70                 WFD_SINK_MANAGER_LOCK(wfd_sink);\
71                 if (wfd_sink->waiting_cmd) {\
72                         if (wfd_sink->manager_thread_cmd) {\
73                                 wfd_sink_debug("send command signal to manager thread \n");\
74                                 g_cond_signal(&((wfd_sink)->manager_thread_cond));\
75                         }\
76                 }\
77                 WFD_SINK_MANAGER_UNLOCK(wfd_sink);\
78         } while (0);
79
80 /**
81  * This function is to initialize manager
82  *
83  * @param[in]   handle          Handle of wfd_sink.
84  * @return      This function returns zero on success, or negative value with errors.
85  * @remarks
86  * @see
87  *
88  */
89 int _mm_wfd_sink_init_manager(mm_wfd_sink_t *wfd_sink);
90 /**
91  * This function is to release manager
92  *
93  * @param[in]   handle          Handle of wfd_sink.
94  * @return      This function returns zero on success, or negative value with errors.
95  * @remarks
96  * @see
97  *
98  */
99 int _mm_wfd_sink_release_manager(mm_wfd_sink_t *wfd_sink);
100
101
102 #ifdef __cplusplus
103 }
104 #endif
105
106 #endif