Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/hound/src/protocol.c

    rcf13b17 r33b8d024  
    9393{
    9494        service_id_t id = 0;
    95         const int ret =
     95        const errno_t ret =
    9696            loc_service_get_id(service, &id, IPC_FLAG_BLOCKING);
    9797        if (ret != EOK)
     
    115115 * @param name Valid string identifier
    116116 * @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 */
     122errno_t hound_service_register_context(hound_sess_t *sess,
     123    const char *name, bool record, hound_context_id_t *id)
    121124{
    122125        assert(sess);
     
    126129        aid_t mid =
    127130            async_send_1(exch, IPC_M_HOUND_CONTEXT_REGISTER, record, &call);
    128         int ret = mid ? EOK : EPARTY;
     131        errno_t ret = mid ? EOK : EPARTY;
    129132
    130133        if (ret == EOK)
     
    134137
    135138        if (ret == EOK)
    136                 async_wait_for(mid, (sysarg_t *)&ret);
     139                async_wait_for(mid, &ret);
    137140
    138141        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;
    140147}
    141148
     
    146153 * @return Error code.
    147154 */
    148 int hound_service_unregister_context(hound_sess_t *sess, hound_context_id_t id)
     155errno_t hound_service_unregister_context(hound_sess_t *sess, hound_context_id_t id)
    149156{
    150157        assert(sess);
    151158        async_exch_t *exch = async_exchange_begin(sess);
    152         const int ret =
     159        const errno_t ret =
    153160            async_req_1_0(exch, IPC_M_HOUND_CONTEXT_UNREGISTER, id);
    154161        async_exchange_end(exch);
     
    166173 * @retval Error code.
    167174 */
    168 int hound_service_get_list(hound_sess_t *sess, const char ***ids, size_t *count,
     175errno_t hound_service_get_list(hound_sess_t *sess, char ***ids, size_t *count,
    169176    int flags, const char *connection)
    170177{
     
    182189        ipc_call_t res_call;
    183190        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;
    187194        if (mid && connection)
    188195                ret = async_data_write_start(exch, connection,
     
    190197
    191198        if (ret == EOK)
    192                 async_wait_for(mid, (sysarg_t*)&ret);
     199                async_wait_for(mid, &ret);
    193200
    194201        if (ret != EOK) {
     
    199206
    200207        /* Start receiving names */
    201         const char **names = NULL;
     208        char **names = NULL;
    202209        if (name_count) {
    203210                size_t *sizes = calloc(name_count, sizeof(size_t));
     
    240247 * @return Error code.
    241248 */
    242 int hound_service_connect_source_sink(hound_sess_t *sess, const char *source,
     249errno_t hound_service_connect_source_sink(hound_sess_t *sess, const char *source,
    243250    const char *sink)
    244251{
     
    252259        ipc_call_t call;
    253260        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;
    255262        if (ret == EOK)
    256263                ret = async_data_write_start(exch, source, str_size(source));
    257264        if (ret == EOK)
    258265                ret = async_data_write_start(exch, sink, str_size(sink));
    259         async_wait_for(id, (sysarg_t*)&ret);
     266        async_wait_for(id, &ret);
    260267        async_exchange_end(exch);
    261268        return ret;
     
    269276 * @return Error code.
    270277 */
    271 int hound_service_disconnect_source_sink(hound_sess_t *sess, const char *source,
     278errno_t hound_service_disconnect_source_sink(hound_sess_t *sess, const char *source,
    272279    const char *sink)
    273280{
     
    278285        ipc_call_t call;
    279286        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;
    281288        if (ret == EOK)
    282289                ret = async_data_write_start(exch, source, str_size(source));
    283290        if (ret == EOK)
    284291                ret = async_data_write_start(exch, sink, str_size(sink));
    285         async_wait_for(id, (sysarg_t*)&ret);
     292        async_wait_for(id, &ret);
    286293        async_exchange_end(exch);
    287294        return ENOTSUP;
     
    297304 * @return Error code.
    298305 */
    299 int hound_service_stream_enter(async_exch_t *exch, hound_context_id_t id,
     306errno_t hound_service_stream_enter(async_exch_t *exch, hound_context_id_t id,
    300307    int flags, pcm_format_t format, size_t bsize)
    301308{
     
    314321 * @return Error code.
    315322 */
    316 int hound_service_stream_exit(async_exch_t *exch)
     323errno_t hound_service_stream_exit(async_exch_t *exch)
    317324{
    318325        return async_req_0_0(exch, IPC_M_HOUND_STREAM_EXIT);
     
    324331 * @return Error code.
    325332 */
    326 int hound_service_stream_drain(async_exch_t *exch)
     333errno_t hound_service_stream_drain(async_exch_t *exch)
    327334{
    328335        return async_req_0_0(exch, IPC_M_HOUND_STREAM_DRAIN);
     
    336343 * @return Error code.
    337344 */
    338 int hound_service_stream_write(async_exch_t *exch, const void *data, size_t size)
     345errno_t hound_service_stream_write(async_exch_t *exch, const void *data, size_t size)
    339346{
    340347        return async_data_write_start(exch, data, size);
     
    348355 * @return Error code.
    349356 */
    350 int hound_service_stream_read(async_exch_t *exch, void *data, size_t size)
     357errno_t hound_service_stream_read(async_exch_t *exch, void *data, size_t size)
    351358{
    352359        return async_data_read_start(exch, data, size);
     
    400407
    401408                        /* Get context name */
    402                         int ret =
     409                        errno_t ret =
    403410                            async_data_write_accept(&name, true, 0, 0, 0, 0);
    404411                        if (ret != EOK) {
     
    427434                        /* get id, 1st param */
    428435                        hound_context_id_t id = IPC_GET_ARG1(call);
    429                         const int ret =
     436                        const errno_t ret =
    430437                            server_iface->rem_context(server_iface->server, id);
    431438                        async_answer_0(callid, ret);
     
    439446                        }
    440447
    441                         const char **list = NULL;
     448                        char **list = NULL;
    442449                        const int flags = IPC_GET_ARG1(call);
    443450                        size_t count = IPC_GET_ARG2(call);
    444451                        const bool conn = IPC_GET_ARG3(call);
    445452                        char *conn_name = NULL;
    446                         int ret = EOK;
     453                        errno_t ret = EOK;
    447454
    448455                        /* get connected actor name if provided */
     
    506513
    507514                        /* read source name */
    508                         int ret =
     515                        errno_t ret =
    509516                            async_data_write_accept(&source, true, 0, 0, 0, 0);
    510517                        /* read sink name */
     
    532539
    533540                        /* read source name */
    534                         int ret =
     541                        errno_t ret =
    535542                            async_data_write_accept(&source, true, 0, 0, 0, 0);
    536543                        /*read sink name */
     
    567574
    568575                        void *stream;
    569                         int ret = server_iface->add_stream(server_iface->server,
     576                        errno_t ret = server_iface->add_stream(server_iface->server,
    570577                            id, flags, f, bsize, &stream);
    571578                        if (ret != EOK) {
     
    619626        ipc_call_t call;
    620627        size_t size = 0;
    621         int ret_answer = EOK;
     628        errno_t ret_answer = EOK;
    622629        /* accept data write or drain */
    623630        while (async_data_write_receive_call(&callid, &call, &size)
     
    625632                /* check drain first */
    626633                if (IPC_GET_IMETHOD(call) == IPC_M_HOUND_STREAM_DRAIN) {
    627                         int ret = ENOTSUP;
     634                        errno_t ret = ENOTSUP;
    628635                        if (server_iface->drain_stream)
    629636                                ret = server_iface->drain_stream(stream);
     
    643650                        continue;
    644651                }
    645                 const int ret = async_data_write_finalize(callid, buffer, size);
     652                const errno_t ret = async_data_write_finalize(callid, buffer, size);
    646653                if (ret == EOK) {
    647654                        /* push data to stream */
     
    650657                }
    651658        }
    652         const int ret = IPC_GET_IMETHOD(call) == IPC_M_HOUND_STREAM_EXIT
     659        const errno_t ret = IPC_GET_IMETHOD(call) == IPC_M_HOUND_STREAM_EXIT
    653660            ? EOK : EINVAL;
    654661
     
    666673        ipc_call_t call;
    667674        size_t size = 0;
    668         int ret_answer = EOK;
     675        errno_t ret_answer = EOK;
    669676        /* accept data read and drain */
    670677        while (async_data_read_receive_call(&callid, &call, &size)
     
    672679                /* drain does not make much sense but it is allowed */
    673680                if (IPC_GET_IMETHOD(call) == IPC_M_HOUND_STREAM_DRAIN) {
    674                         int ret = ENOTSUP;
     681                        errno_t ret = ENOTSUP;
    675682                        if (server_iface->drain_stream)
    676683                                ret = server_iface->drain_stream(stream);
     
    688695                        continue;
    689696                }
    690                 int ret = server_iface->stream_data_read(stream, buffer, size);
     697                errno_t ret = server_iface->stream_data_read(stream, buffer, size);
    691698                if (ret == EOK) {
    692699                        ret_answer =
     
    694701                }
    695702        }
    696         const int ret = IPC_GET_IMETHOD(call) == IPC_M_HOUND_STREAM_EXIT
     703        const errno_t ret = IPC_GET_IMETHOD(call) == IPC_M_HOUND_STREAM_EXIT
    697704            ? EOK : EINVAL;
    698705
     
    711718 * @return Error code.
    712719 */
    713 int hound_server_register(const char *name, service_id_t *id)
     720errno_t hound_server_register(const char *name, service_id_t *id)
    714721{
    715722        if (!name || !id)
    716723                return EINVAL;
    717724
    718         int ret = loc_server_register(name);
     725        errno_t ret = loc_server_register(name);
    719726        if (ret != EOK)
    720727                return ret;
     
    737744 * @return Error code.
    738745 */
    739 int hound_server_set_device_change_callback(dev_change_callback_t cb)
     746errno_t hound_server_set_device_change_callback(dev_change_callback_t cb)
    740747{
    741748        return loc_register_cat_change_cb(cb);
     
    747754 * @return Error code.
    748755 */
    749 int hound_server_devices_iterate(device_callback_t callback)
     756errno_t hound_server_devices_iterate(device_callback_t callback)
    750757{
    751758        if (!callback)
     
    755762
    756763        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,
    758765                    IPC_FLAG_BLOCKING);
    759766                if (ret != EOK)
     
    764771        service_id_t *svcs = NULL;
    765772        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);
    767774        if (ret != EOK)
    768775                return ret;
Note: See TracChangeset for help on using the changeset viewer.