Changes in uspace/lib/hound/src/protocol.c [cf13b17:33b8d024] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/hound/src/protocol.c
rcf13b17 r33b8d024 93 93 { 94 94 service_id_t id = 0; 95 const int ret =95 const errno_t ret = 96 96 loc_service_get_id(service, &id, IPC_FLAG_BLOCKING); 97 97 if (ret != EOK) … … 115 115 * @param name Valid string identifier 116 116 * @param record True if the application context wishes to receive data. 117 * @return Valid ID on success, Error code on failure. 118 */ 119 hound_context_id_t hound_service_register_context(hound_sess_t *sess, 120 const char *name, bool record) 117 * 118 * @param[out] id Return context ID. 119 * 120 * @return EOK on success, Error code on failure. 121 */ 122 errno_t hound_service_register_context(hound_sess_t *sess, 123 const char *name, bool record, hound_context_id_t *id) 121 124 { 122 125 assert(sess); … … 126 129 aid_t mid = 127 130 async_send_1(exch, IPC_M_HOUND_CONTEXT_REGISTER, record, &call); 128 int ret = mid ? EOK : EPARTY;131 errno_t ret = mid ? EOK : EPARTY; 129 132 130 133 if (ret == EOK) … … 134 137 135 138 if (ret == EOK) 136 async_wait_for(mid, (sysarg_t *)&ret);139 async_wait_for(mid, &ret); 137 140 138 141 async_exchange_end(exch); 139 return ret == EOK ? (hound_context_id_t)IPC_GET_ARG1(call) : ret; 142 if (ret == EOK) { 143 *id = (hound_context_id_t)IPC_GET_ARG1(call); 144 } 145 146 return ret; 140 147 } 141 148 … … 146 153 * @return Error code. 147 154 */ 148 int hound_service_unregister_context(hound_sess_t *sess, hound_context_id_t id)155 errno_t hound_service_unregister_context(hound_sess_t *sess, hound_context_id_t id) 149 156 { 150 157 assert(sess); 151 158 async_exch_t *exch = async_exchange_begin(sess); 152 const int ret =159 const errno_t ret = 153 160 async_req_1_0(exch, IPC_M_HOUND_CONTEXT_UNREGISTER, id); 154 161 async_exchange_end(exch); … … 166 173 * @retval Error code. 167 174 */ 168 int hound_service_get_list(hound_sess_t *sess, constchar ***ids, size_t *count,175 errno_t hound_service_get_list(hound_sess_t *sess, char ***ids, size_t *count, 169 176 int flags, const char *connection) 170 177 { … … 182 189 ipc_call_t res_call; 183 190 aid_t mid = async_send_3(exch, IPC_M_HOUND_GET_LIST, flags, *count, 184 (bool)connection, &res_call);185 186 int ret = EOK;191 connection != NULL, &res_call); 192 193 errno_t ret = EOK; 187 194 if (mid && connection) 188 195 ret = async_data_write_start(exch, connection, … … 190 197 191 198 if (ret == EOK) 192 async_wait_for(mid, (sysarg_t*)&ret);199 async_wait_for(mid, &ret); 193 200 194 201 if (ret != EOK) { … … 199 206 200 207 /* Start receiving names */ 201 c onst char **names = NULL;208 char **names = NULL; 202 209 if (name_count) { 203 210 size_t *sizes = calloc(name_count, sizeof(size_t)); … … 240 247 * @return Error code. 241 248 */ 242 int hound_service_connect_source_sink(hound_sess_t *sess, const char *source,249 errno_t hound_service_connect_source_sink(hound_sess_t *sess, const char *source, 243 250 const char *sink) 244 251 { … … 252 259 ipc_call_t call; 253 260 aid_t id = async_send_0(exch, IPC_M_HOUND_CONNECT, &call); 254 int ret = id ? EOK : EPARTY;261 errno_t ret = id ? EOK : EPARTY; 255 262 if (ret == EOK) 256 263 ret = async_data_write_start(exch, source, str_size(source)); 257 264 if (ret == EOK) 258 265 ret = async_data_write_start(exch, sink, str_size(sink)); 259 async_wait_for(id, (sysarg_t*)&ret);266 async_wait_for(id, &ret); 260 267 async_exchange_end(exch); 261 268 return ret; … … 269 276 * @return Error code. 270 277 */ 271 int hound_service_disconnect_source_sink(hound_sess_t *sess, const char *source,278 errno_t hound_service_disconnect_source_sink(hound_sess_t *sess, const char *source, 272 279 const char *sink) 273 280 { … … 278 285 ipc_call_t call; 279 286 aid_t id = async_send_0(exch, IPC_M_HOUND_DISCONNECT, &call); 280 int ret = id ? EOK : EPARTY;287 errno_t ret = id ? EOK : EPARTY; 281 288 if (ret == EOK) 282 289 ret = async_data_write_start(exch, source, str_size(source)); 283 290 if (ret == EOK) 284 291 ret = async_data_write_start(exch, sink, str_size(sink)); 285 async_wait_for(id, (sysarg_t*)&ret);292 async_wait_for(id, &ret); 286 293 async_exchange_end(exch); 287 294 return ENOTSUP; … … 297 304 * @return Error code. 298 305 */ 299 int hound_service_stream_enter(async_exch_t *exch, hound_context_id_t id,306 errno_t hound_service_stream_enter(async_exch_t *exch, hound_context_id_t id, 300 307 int flags, pcm_format_t format, size_t bsize) 301 308 { … … 314 321 * @return Error code. 315 322 */ 316 int hound_service_stream_exit(async_exch_t *exch)323 errno_t hound_service_stream_exit(async_exch_t *exch) 317 324 { 318 325 return async_req_0_0(exch, IPC_M_HOUND_STREAM_EXIT); … … 324 331 * @return Error code. 325 332 */ 326 int hound_service_stream_drain(async_exch_t *exch)333 errno_t hound_service_stream_drain(async_exch_t *exch) 327 334 { 328 335 return async_req_0_0(exch, IPC_M_HOUND_STREAM_DRAIN); … … 336 343 * @return Error code. 337 344 */ 338 int hound_service_stream_write(async_exch_t *exch, const void *data, size_t size)345 errno_t hound_service_stream_write(async_exch_t *exch, const void *data, size_t size) 339 346 { 340 347 return async_data_write_start(exch, data, size); … … 348 355 * @return Error code. 349 356 */ 350 int hound_service_stream_read(async_exch_t *exch, void *data, size_t size)357 errno_t hound_service_stream_read(async_exch_t *exch, void *data, size_t size) 351 358 { 352 359 return async_data_read_start(exch, data, size); … … 400 407 401 408 /* Get context name */ 402 int ret =409 errno_t ret = 403 410 async_data_write_accept(&name, true, 0, 0, 0, 0); 404 411 if (ret != EOK) { … … 427 434 /* get id, 1st param */ 428 435 hound_context_id_t id = IPC_GET_ARG1(call); 429 const int ret =436 const errno_t ret = 430 437 server_iface->rem_context(server_iface->server, id); 431 438 async_answer_0(callid, ret); … … 439 446 } 440 447 441 c onst char **list = NULL;448 char **list = NULL; 442 449 const int flags = IPC_GET_ARG1(call); 443 450 size_t count = IPC_GET_ARG2(call); 444 451 const bool conn = IPC_GET_ARG3(call); 445 452 char *conn_name = NULL; 446 int ret = EOK;453 errno_t ret = EOK; 447 454 448 455 /* get connected actor name if provided */ … … 506 513 507 514 /* read source name */ 508 int ret =515 errno_t ret = 509 516 async_data_write_accept(&source, true, 0, 0, 0, 0); 510 517 /* read sink name */ … … 532 539 533 540 /* read source name */ 534 int ret =541 errno_t ret = 535 542 async_data_write_accept(&source, true, 0, 0, 0, 0); 536 543 /*read sink name */ … … 567 574 568 575 void *stream; 569 int ret = server_iface->add_stream(server_iface->server,576 errno_t ret = server_iface->add_stream(server_iface->server, 570 577 id, flags, f, bsize, &stream); 571 578 if (ret != EOK) { … … 619 626 ipc_call_t call; 620 627 size_t size = 0; 621 int ret_answer = EOK;628 errno_t ret_answer = EOK; 622 629 /* accept data write or drain */ 623 630 while (async_data_write_receive_call(&callid, &call, &size) … … 625 632 /* check drain first */ 626 633 if (IPC_GET_IMETHOD(call) == IPC_M_HOUND_STREAM_DRAIN) { 627 int ret = ENOTSUP;634 errno_t ret = ENOTSUP; 628 635 if (server_iface->drain_stream) 629 636 ret = server_iface->drain_stream(stream); … … 643 650 continue; 644 651 } 645 const int ret = async_data_write_finalize(callid, buffer, size);652 const errno_t ret = async_data_write_finalize(callid, buffer, size); 646 653 if (ret == EOK) { 647 654 /* push data to stream */ … … 650 657 } 651 658 } 652 const int ret = IPC_GET_IMETHOD(call) == IPC_M_HOUND_STREAM_EXIT659 const errno_t ret = IPC_GET_IMETHOD(call) == IPC_M_HOUND_STREAM_EXIT 653 660 ? EOK : EINVAL; 654 661 … … 666 673 ipc_call_t call; 667 674 size_t size = 0; 668 int ret_answer = EOK;675 errno_t ret_answer = EOK; 669 676 /* accept data read and drain */ 670 677 while (async_data_read_receive_call(&callid, &call, &size) … … 672 679 /* drain does not make much sense but it is allowed */ 673 680 if (IPC_GET_IMETHOD(call) == IPC_M_HOUND_STREAM_DRAIN) { 674 int ret = ENOTSUP;681 errno_t ret = ENOTSUP; 675 682 if (server_iface->drain_stream) 676 683 ret = server_iface->drain_stream(stream); … … 688 695 continue; 689 696 } 690 int ret = server_iface->stream_data_read(stream, buffer, size);697 errno_t ret = server_iface->stream_data_read(stream, buffer, size); 691 698 if (ret == EOK) { 692 699 ret_answer = … … 694 701 } 695 702 } 696 const int ret = IPC_GET_IMETHOD(call) == IPC_M_HOUND_STREAM_EXIT703 const errno_t ret = IPC_GET_IMETHOD(call) == IPC_M_HOUND_STREAM_EXIT 697 704 ? EOK : EINVAL; 698 705 … … 711 718 * @return Error code. 712 719 */ 713 int hound_server_register(const char *name, service_id_t *id)720 errno_t hound_server_register(const char *name, service_id_t *id) 714 721 { 715 722 if (!name || !id) 716 723 return EINVAL; 717 724 718 int ret = loc_server_register(name);725 errno_t ret = loc_server_register(name); 719 726 if (ret != EOK) 720 727 return ret; … … 737 744 * @return Error code. 738 745 */ 739 int hound_server_set_device_change_callback(dev_change_callback_t cb)746 errno_t hound_server_set_device_change_callback(dev_change_callback_t cb) 740 747 { 741 748 return loc_register_cat_change_cb(cb); … … 747 754 * @return Error code. 748 755 */ 749 int hound_server_devices_iterate(device_callback_t callback)756 errno_t hound_server_devices_iterate(device_callback_t callback) 750 757 { 751 758 if (!callback) … … 755 762 756 763 if (!resolved) { 757 const int ret = loc_category_get_id("audio-pcm", &cat_id,764 const errno_t ret = loc_category_get_id("audio-pcm", &cat_id, 758 765 IPC_FLAG_BLOCKING); 759 766 if (ret != EOK) … … 764 771 service_id_t *svcs = NULL; 765 772 size_t count = 0; 766 const int ret = loc_category_get_svcs(cat_id, &svcs, &count);773 const errno_t ret = loc_category_get_svcs(cat_id, &svcs, &count); 767 774 if (ret != EOK) 768 775 return ret;
Note:
See TracChangeset
for help on using the changeset viewer.