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 /* If this is sco device, this can be used to */
65 /* Devices are contained in this list */
68 pa_communicator *comm;
69 pa_dbus_connection *dbus_conn;
72 struct pa_tz_device_new_data {
75 /* for multi-device type(bt, usb) */
81 dm_device_direction_t direction;
82 bool use_internal_codec;
83 pa_hashmap *playback_pcms;
84 pa_hashmap *capture_pcms;
87 pa_communicator *comm;
88 pa_dbus_connection *dbus_conn;
91 typedef struct _hook_call_data_for_conn_changed {
95 } pa_tz_device_hook_data_for_conn_changed;
97 typedef struct _hook_call_data_for_state_changed {
100 pa_tz_device *device;
101 } pa_tz_device_hook_data_for_state_changed;
103 typedef struct _hook_call_data_for_running_changed {
106 pa_tz_device *device;
107 } pa_tz_device_hook_data_for_running_changed;
109 /*** For device manager ***/
110 void pa_tz_device_dump_info(pa_tz_device *device, pa_log_level_t log_level);
111 void pa_tz_device_new_data_init(pa_tz_device_new_data *data, pa_idxset *list, pa_communicator *comm, pa_dbus_connection *conn);
112 void pa_tz_device_new_data_set_type(pa_tz_device_new_data *data, const char *type);
113 void pa_tz_device_new_data_set_name(pa_tz_device_new_data *data, const char *name);
114 void pa_tz_device_new_data_set_direction(pa_tz_device_new_data *data, dm_device_direction_t direction);
115 /* deivce which is multi-device type should have system_id */
116 void pa_tz_device_new_data_set_system_id(pa_tz_device_new_data *data, const char *system_id);
117 void pa_tz_device_new_data_set_vendor_id(pa_tz_device_new_data *data, int vendor_id);
118 void pa_tz_device_new_data_set_product_id(pa_tz_device_new_data *data, int product_id);
119 void pa_tz_device_new_data_set_use_internal_codec(pa_tz_device_new_data *data, bool use_internal_codec);
120 void pa_tz_device_new_data_add_sink(pa_tz_device_new_data *data, const char *role, pa_sink *sink);
121 void pa_tz_device_new_data_add_source(pa_tz_device_new_data *data, const char *role, pa_source *source);
122 void pa_tz_device_new_data_done(pa_tz_device_new_data *data);
124 /* Create tizen device instance,
125 * device connected hook will be fired */
126 pa_tz_device* pa_tz_device_new(pa_tz_device_new_data *data);
127 /* Destroy tizen device instance,
128 * device disconnected hook will be fired */
129 void pa_tz_device_free(pa_tz_device *device);
130 /* Can be used add/remove sink/source in runtime */
131 int pa_tz_device_add_sink(pa_tz_device *device, const char *role, pa_sink *sink);
132 int pa_tz_device_add_source(pa_tz_device *device, const char *role, pa_source *source);
133 int pa_tz_device_remove_sink(pa_tz_device *device, pa_sink *sink);
134 int pa_tz_device_remove_source(pa_tz_device *device, pa_source *source);
135 int pa_tz_device_remove_sink_with_role(pa_tz_device *device, const char *role);
136 int pa_tz_device_remove_source_with_role(pa_tz_device *device, const char *role);
138 /* Exported API for other modules */
139 pa_sink* pa_tz_device_get_sink(pa_tz_device *device, const char *role);
140 pa_source* pa_tz_device_get_source(pa_tz_device *device, const char *role);
141 void pa_tz_device_set_state(pa_tz_device *device, dm_device_state_t state);
142 dm_device_state_t pa_tz_device_get_state(pa_tz_device *device);
143 void pa_tz_device_set_running_and_notify(pa_tz_device *device, bool running);
144 bool pa_tz_device_is_running(pa_tz_device *device);
145 uint32_t pa_tz_device_get_id(pa_tz_device *device);
146 char* pa_tz_device_get_type(pa_tz_device *device);
147 char* pa_tz_device_get_name(pa_tz_device *device);
148 char* pa_tz_device_get_system_id(pa_tz_device *device);
149 dm_device_direction_t pa_tz_device_get_direction(pa_tz_device *device);
150 pa_usec_t pa_tz_device_get_creation_time(pa_tz_device *device);
151 bool pa_tz_device_is_use_internal_codec(pa_tz_device *device);
152 bool pa_tz_device_is_all_suspended(pa_tz_device *device);
153 pa_intset* pa_tz_device_get_stream_list(pa_tz_device *device);
155 /* Only for BT SCO device */
156 int pa_tz_device_sco_enable_pcm(pa_tz_device *device, bool enable);
157 int pa_tz_device_sco_open(pa_tz_device *device);
158 int pa_tz_device_sco_close(pa_tz_device *device);
159 int pa_tz_device_sco_get_property(pa_tz_device *device, bool *is_wide_band, bool *nrec);
160 int pa_tz_device_sco_get_status(pa_tz_device *device, dm_device_bt_sco_status_t *status);
162 /* Only for USB device */
163 int pa_tz_device_get_vendor_id(pa_tz_device *device);
164 int pa_tz_device_get_product_id(pa_tz_device *device);
165 char* pa_tz_device_get_specified_stream_role(pa_tz_device *device);
167 void pa_intset_free(pa_intset *s);
168 int pa_intset_first(pa_intset *s, int *val);
169 int pa_intset_next(pa_intset *s, int *val);
171 #define PA_INTSET_FOREACH(i, s, r) \
172 for ((r) = pa_intset_first((s), &(i)); (r == 0); (r) = pa_intset_next((s), &(i)))