Changeset 37ea333 in mainline


Ignore:
Timestamp:
2013-03-23T13:56:35Z (11 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
fd7c98b
Parents:
d768d4c8
Message:

libhoud: Handle recording requests.

Location:
uspace/lib/hound
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/hound/include/hound/protocol.h

    rd768d4c8 r37ea333  
    6464        int (*add_context)(void *, hound_context_id_t *, const char *, bool);
    6565        int (*rem_context)(void *, hound_context_id_t);
     66        bool (*is_record_context)(void *, hound_context_id_t);
    6667        int (*add_stream)(void *, hound_context_id_t, int, pcm_format_t, size_t,
    6768            void **);
  • uspace/lib/hound/src/protocol.c

    rd768d4c8 r37ea333  
    139139
    140140static int hound_server_read_data(void *stream);
     141static int hound_server_write_data(void *stream);
    141142static const hound_server_iface_t *server_iface;
    142143
     
    194195                }
    195196                case IPC_M_HOUND_STREAM_ENTER: {
    196                         if (!server_iface || !server_iface->add_stream) {
     197                        if (!server_iface || !server_iface->add_stream
     198                            || !server_iface->is_record_context) {
    197199                                async_answer_0(callid, ENOTSUP);
    198200                                break;
     
    213215                                break;
    214216                        }
    215                         //TODO consider record context
    216                         hound_server_read_data(stream);
     217                        const bool rec = server_iface->is_record_context(
     218                            server_iface->server, id);
     219                        if (rec) {
     220                                hound_server_write_data(stream);
     221                        } else {
     222                                hound_server_read_data(stream);
     223                        }
    217224                        break;
    218225                }
     
    245252                int ret = async_data_write_finalize(callid, buffer, size);
    246253                if (ret == EOK) {
    247                         server_iface->stream_data_write(stream, buffer, size);
    248                 } else {
    249                         async_answer_0(callid, ret);
    250                 }
     254                        ret = server_iface->stream_data_write(stream, buffer, size);
     255                }
     256                async_answer_0(callid, ret);
    251257        }
    252258        //TODO drain?
     259        const int ret = IPC_GET_IMETHOD(call) == IPC_M_HOUND_STREAM_EXIT
     260            ? EOK : EINVAL;
     261
     262        async_answer_0(callid, ret);
     263        return ret;
     264}
     265
     266static int hound_server_write_data(void *stream)
     267{
     268        if (!server_iface || !server_iface->stream_data_read)
     269                return ENOTSUP;
     270
     271        ipc_callid_t callid;
     272        ipc_call_t call;
     273        size_t size = 0;
     274        while (async_data_read_receive_call(&callid, &call, &size)) {
     275                char *buffer = malloc(size);
     276                if (!buffer) {
     277                        async_answer_0(callid, ENOMEM);
     278                        continue;
     279                }
     280                int ret = server_iface->stream_data_read(stream, buffer, size);
     281                if (ret == EOK) {
     282                        ret = async_data_read_finalize(callid, buffer, size);
     283                }
     284                async_answer_0(callid, ret);
     285        }
    253286        const int ret = IPC_GET_IMETHOD(call) == IPC_M_HOUND_STREAM_EXIT
    254287            ? EOK : EINVAL;
Note: See TracChangeset for help on using the changeset viewer.