1 #ifndef footizendevicefoo
2 #define footizendevicefoo
4 #include <pulsecore/core.h>
5 #include "tizen-device-def.h"
6 #include "communicator.h"
8 #include <pulsecore/dbus-shared.h>
9 #include <pulsecore/dbus-util.h>
12 #define MAX_INTSET_NUM 32
14 typedef struct pa_tz_device pa_tz_device;
15 typedef struct pa_tz_device_new_data pa_tz_device_new_data;
16 typedef struct pa_intset pa_intset;
18 /* structures for represent device items which can be connected/disconnected */
21 If this is created or freed, device connected/disconnected
22 hook(for internal)/callback(for apps) will be called.
27 /* Decimal ID which is unique in device list
28 * This will be exported up to sound_manager_get_device_id */
30 /* String ID which will be used internally
31 * In multi-Device case(bt, usb), this will be used to classify
32 * each physicall device */
35 /* Additional information for USB device
36 * This comes from udev */
40 dm_device_direction_t direction;
42 /* Set by stream-manager
43 * If this is changed, will notify via callback.
44 * It will be replaced by is_running variable */
45 dm_device_state_t state;
47 char *specified_stream_role;
49 /* If it is changed, will notify via callback */
52 /* Can get proper sink/source in hashmaps with key(=device_role) */
53 pa_hashmap *playback_devices;
54 pa_hashmap *capture_devices;
57 pa_usec_t creation_time;
59 /* Will be true, if this device uses internal codec(card),
60 * false, if this device uses external card(bt-a2dp, usb */
61 bool use_internal_codec;
62 #ifndef __TIZEN_TV_EXTERNAL_BT_SCO__
63 /* If this is sco device, this can be used to */
67 /* mirrors to the corresponding sink/source sample spec */
68 const pa_sample_spec *sample_spec;
70 /* Devices are contained in this list */
73 pa_communicator *comm;
74 pa_dbus_connection *dbus_conn;
77 struct pa_tz_device_new_data {
80 /* for multi-device type(bt, usb) */
86 dm_device_direction_t direction;
87 bool use_internal_codec;
88 pa_hashmap *playback_pcms;
89 pa_hashmap *capture_pcms;
92 pa_communicator *comm;
93 pa_dbus_connection *dbus_conn;
96 typedef struct _hook_call_data_for_conn_changed {
100 } pa_tz_device_hook_data_for_conn_changed;
102 typedef struct _hook_call_data_for_state_changed {
105 pa_tz_device *device;
106 } pa_tz_device_hook_data_for_state_changed;
108 typedef struct _hook_call_data_for_running_changed {
111 pa_tz_device *device;
112 } pa_tz_device_hook_data_for_running_changed;
114 /*** For device manager ***/
115 void pa_tz_device_dump_info(pa_tz_device *device, pa_log_level_t log_level);
116 void pa_tz_device_new_data_init(pa_tz_device_new_data *data, pa_idxset *list, pa_communicator *comm, pa_dbus_connection *conn);
117 void pa_tz_device_new_data_set_type(pa_tz_device_new_data *data, const char *type);
118 void pa_tz_device_new_data_set_name(pa_tz_device_new_data *data, const char *name);
119 void pa_tz_device_new_data_set_direction(pa_tz_device_new_data *data, dm_device_direction_t direction);
120 /* deivce which is multi-device type should have system_id */
121 void pa_tz_device_new_data_set_system_id(pa_tz_device_new_data *data, const char *system_id);
122 void pa_tz_device_new_data_set_vendor_id(pa_tz_device_new_data *data, int vendor_id);
123 void pa_tz_device_new_data_set_product_id(pa_tz_device_new_data *data, int product_id);
124 void pa_tz_device_new_data_set_use_internal_codec(pa_tz_device_new_data *data, bool use_internal_codec);
125 void pa_tz_device_new_data_add_sink(pa_tz_device_new_data *data, const char *role, pa_sink *sink);
126 void pa_tz_device_new_data_add_source(pa_tz_device_new_data *data, const char *role, pa_source *source);
127 void pa_tz_device_new_data_done(pa_tz_device_new_data *data);
129 /* Create tizen device instance,
130 * device connected hook will be fired */
131 pa_tz_device* pa_tz_device_new(pa_tz_device_new_data *data);
132 /* Destroy tizen device instance,
133 * device disconnected hook will be fired */
134 void pa_tz_device_free(pa_tz_device *device);
135 /* Can be used add/remove sink/source in runtime */
136 int pa_tz_device_add_sink(pa_tz_device *device, const char *role, pa_sink *sink);
137 int pa_tz_device_add_source(pa_tz_device *device, const char *role, pa_source *source);
138 int pa_tz_device_remove_sink(pa_tz_device *device, pa_sink *sink);
139 int pa_tz_device_remove_source(pa_tz_device *device, pa_source *source);
140 int pa_tz_device_remove_sink_with_role(pa_tz_device *device, const char *role);
141 int pa_tz_device_remove_source_with_role(pa_tz_device *device, const char *role);
143 /* Exported API for other modules */
144 pa_sink* pa_tz_device_get_sink(pa_tz_device *device, const char *role);
145 pa_source* pa_tz_device_get_source(pa_tz_device *device, const char *role);
146 void pa_tz_device_set_state(pa_tz_device *device, dm_device_state_t state);
147 dm_device_state_t pa_tz_device_get_state(pa_tz_device *device);
148 void pa_tz_device_set_running_and_notify(pa_tz_device *device, bool running);
149 bool pa_tz_device_is_running(pa_tz_device *device);
150 uint32_t pa_tz_device_get_id(pa_tz_device *device);
151 char* pa_tz_device_get_type(pa_tz_device *device);
152 char* pa_tz_device_get_role(pa_tz_device *device, const char *preferred_role);
153 char* pa_tz_device_get_name(pa_tz_device *device);
154 char* pa_tz_device_get_system_id(pa_tz_device *device);
155 dm_device_direction_t pa_tz_device_get_direction(pa_tz_device *device);
156 pa_usec_t pa_tz_device_get_creation_time(pa_tz_device *device);
157 bool pa_tz_device_is_use_internal_codec(pa_tz_device *device);
158 const pa_sample_spec* pa_tz_device_get_sample_spec(pa_tz_device *device);
159 bool pa_tz_device_is_all_suspended(pa_tz_device *device);
160 pa_intset* pa_tz_device_get_stream_list(pa_tz_device *device);
162 #ifndef __TIZEN_TV_EXTERNAL_BT_SCO__
163 /* Only for BT SCO device */
164 int pa_tz_device_sco_enable_pcm(pa_tz_device *device, bool enable);
165 int pa_tz_device_sco_open(pa_tz_device *device);
166 int pa_tz_device_sco_close(pa_tz_device *device);
167 int pa_tz_device_sco_get_property(pa_tz_device *device, bool *is_wide_band, bool *nrec);
168 int pa_tz_device_sco_get_status(pa_tz_device *device, dm_device_bt_sco_status_t *status);
171 /* Only for USB device */
172 int pa_tz_device_get_vendor_id(pa_tz_device *device);
173 int pa_tz_device_get_product_id(pa_tz_device *device);
174 char* pa_tz_device_get_specified_stream_role(pa_tz_device *device);
176 void pa_intset_free(pa_intset *s);
177 int pa_intset_first(pa_intset *s, int *val);
178 int pa_intset_next(pa_intset *s, int *val);
180 #define PA_INTSET_FOREACH(i, s, r) \
181 for ((r) = pa_intset_first((s), &(i)); (r == 0); (r) = pa_intset_next((s), &(i)))