Changeset 13318d1 in mainline
- Timestamp:
- 2013-03-24T03:44:11Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 7294b5b
- Parents:
- fd7c98b
- Location:
- uspace/lib/hound
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/hound/include/hound/protocol.h
rfd7c98b r13318d1 42 42 const char *HOUND_SERVICE; 43 43 44 enum { 45 HOUND_SINK_APPS = 0x1, 46 HOUND_SINK_DEVS = 0x2, 47 HOUND_SOURCE_APPS = 0x4, 48 HOUND_SOURCE_DEVS = 0x8, 49 HOUND_CONNECTED = 0x10, 50 51 HOUND_STREAM_DRAIN_ON_EXIT = 0x1, 52 HOUND_STREAM_IGNORE_UNDERFLOW = 0x2, 53 HOUND_STREAM_IGNORE_OVERFLOW = 0x4, 54 }; 55 44 56 typedef async_sess_t hound_sess_t; 45 57 typedef int hound_context_id_t; 58 59 static inline int hound_context_id_err(hound_context_id_t id) 60 { 61 return id > 0 ? EOK : (id == 0 ? ENOENT : id); 62 } 46 63 47 64 hound_sess_t *hound_service_connect(const char *service); … … 51 68 const char *name, bool record); 52 69 int hound_service_unregister_context(hound_sess_t *sess, hound_context_id_t id); 70 71 int hound_service_get_list(hound_sess_t *sess, const char ***ids, size_t *count, 72 int flags, const char *connection); 73 static inline int hound_service_get_list_all(hound_sess_t *sess, 74 const char ***ids, size_t *count, int flags) 75 { 76 return hound_service_get_list(sess, ids, count, flags, NULL); 77 } 78 79 int hound_service_connect_source_sink(hound_sess_t *sess, const char *source, 80 const char *sink); 81 int hound_service_disconnect_source_sink(hound_sess_t *sess, const char *source, 82 const char *sink); 53 83 54 84 int hound_service_stream_enter(async_exch_t *exch, hound_context_id_t id, … … 65 95 int (*rem_context)(void *, hound_context_id_t); 66 96 bool (*is_record_context)(void *, hound_context_id_t); 97 int (*connect)(void *, const char *, const char *); 98 int (*disconnect)(void *, const char *, const char *); 67 99 int (*add_stream)(void *, hound_context_id_t, int, pcm_format_t, size_t, 68 100 void **); -
uspace/lib/hound/src/protocol.c
rfd7c98b r13318d1 49 49 IPC_M_HOUND_CONTEXT_REGISTER = IPC_FIRST_USER_METHOD, 50 50 IPC_M_HOUND_CONTEXT_UNREGISTER, 51 IPC_M_HOUND_GET_LIST, 52 IPC_M_HOUND_CONNECT, 53 IPC_M_HOUND_DISCONNECT, 51 54 IPC_M_HOUND_STREAM_ENTER, 52 55 IPC_M_HOUND_STREAM_EXIT, … … 99 102 async_exchange_end(exch); 100 103 return ret; 104 } 105 106 int hound_service_get_list(hound_sess_t *sess, const char ***ids, size_t *count, 107 int flags, const char *connection) 108 { 109 assert(sess); 110 assert(ids); 111 assert(count); 112 113 if (connection && !(flags & HOUND_CONNECTED)) 114 return EINVAL; 115 116 async_exch_t *exch = async_exchange_begin(sess); 117 if (!exch) 118 return ENOMEM; 119 120 ipc_call_t res_call; 121 aid_t mid = async_send_3(exch, IPC_M_HOUND_GET_LIST, flags, *count, 122 (bool)connection, &res_call); 123 124 int ret = EOK; 125 if (mid && connection) 126 ret = async_data_write_start(exch, connection, 127 str_size(connection)); 128 129 if (ret == EOK) 130 async_wait_for(mid, (sysarg_t*)&ret); 131 132 if (ret != EOK) { 133 async_exchange_end(exch); 134 return ret; 135 } 136 unsigned name_count = IPC_GET_ARG1(res_call); 137 size_t max_length = IPC_GET_ARG2(res_call); 138 139 /* Start receiving names */ 140 const char ** names = NULL; 141 if (name_count) { 142 names = calloc(name_count, sizeof(char *)); 143 char *tmp_name = malloc(max_length + 1); 144 if (!names || !tmp_name) { 145 async_exchange_end(exch); 146 return ENOMEM; 147 } 148 for (unsigned i = 0; i < name_count; ++i) { 149 bzero(tmp_name, max_length + 1); 150 ret = async_data_read_start(exch, tmp_name, max_length); 151 if (ret == EOK) { 152 names[i] = str_dup(tmp_name); 153 ret = names[i] ? EOK : ENOMEM; 154 } 155 if (ret != EOK) 156 break; 157 } 158 free(tmp_name); 159 } 160 async_exchange_end(exch); 161 if (ret != EOK) { 162 for (unsigned i = 0; i < name_count; ++i) 163 free(names[i]); 164 free(names); 165 } else { 166 *ids = names; 167 *count = name_count; 168 } 169 return ret; 170 } 171 172 int hound_service_connect_source_sink(hound_sess_t *sess, const char *source, 173 const char *sink) 174 { 175 assert(sess); 176 assert(source); 177 assert(sink); 178 179 async_exch_t *exch = async_exchange_begin(sess); 180 if (!exch) 181 return ENOMEM; 182 int ret = async_req_0_0(exch, IPC_M_HOUND_CONNECT); 183 if (ret == EOK) 184 ret = async_data_write_start(exch, source, str_size(source)); 185 if (ret == EOK) 186 ret = async_data_write_start(exch, sink, str_size(sink)); 187 async_exchange_end(exch); 188 return ret; 189 } 190 191 int hound_service_disconnect_source_sink(hound_sess_t *sess, const char *source, 192 const char *sink) 193 { 194 assert(sess); 195 async_exch_t *exch = async_exchange_begin(sess); 196 if (!exch) 197 return ENOMEM; 198 int ret = async_req_0_0(exch, IPC_M_HOUND_DISCONNECT); 199 if (ret == EOK) 200 ret = async_data_write_start(exch, source, str_size(source)); 201 if (ret == EOK) 202 ret = async_data_write_start(exch, sink, str_size(sink)); 203 async_exchange_end(exch); 204 return ENOTSUP; 101 205 } 102 206
Note:
See TracChangeset
for help on using the changeset viewer.