Changeset 876f5561 in mainline


Ignore:
Timestamp:
2013-04-10T23:06:52Z (11 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f0a647c
Parents:
eb0ef51
Message:

libhound: doxygen

Location:
uspace/lib/hound
Files:
4 edited

Legend:

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

    reb0ef51 r876f5561  
    5454void hound_context_destroy(hound_context_t *hound);
    5555
    56 int hound_context_set_main_stream_format(hound_context_t *hound,
    57     unsigned channels, unsigned rate, pcm_sample_format_t format);
     56int hound_context_set_main_stream_params(hound_context_t *hound,
     57    pcm_format_t format, size_t bsize);
    5858
    5959int hound_context_get_available_targets(hound_context_t *hound,
  • uspace/lib/hound/include/hound/protocol.h

    reb0ef51 r876f5561  
    4141#include <pcm/format.h>
    4242
    43 const char *HOUND_SERVICE;
     43extern const char *HOUND_SERVICE;
    4444
    45 enum {
     45typedef enum {
    4646        HOUND_SINK_APPS = 0x1,
    4747        HOUND_SINK_DEVS = 0x2,
     
    5353        HOUND_STREAM_IGNORE_UNDERFLOW = 0x2,
    5454        HOUND_STREAM_IGNORE_OVERFLOW = 0x4,
    55 };
     55} hound_flags_t;
    5656
    5757typedef async_sess_t hound_sess_t;
    5858typedef intptr_t hound_context_id_t;
    5959
     60/**
     61 * Check context id for errors.
     62 * @param id Context id
     63 * @return Error code.
     64 */
    6065static inline int hound_context_id_err(hound_context_id_t id)
    6166{
     
    7277int hound_service_get_list(hound_sess_t *sess, const char ***ids, size_t *count,
    7378    int flags, const char *connection);
     79
     80/**
     81 * Wrapper for list queries with no connection parameter.
     82 * @param[in] sess hound daemon session.
     83 * @param[out] ids list of string identifiers
     84 * @param[out] count Number of elements in @p ids
     85 * @param[in] flags Flags limiting the query.
     86 * @return Error code.
     87 */
    7488static inline int hound_service_get_list_all(hound_sess_t *sess,
    7589    const char ***ids, size_t *count, int flags)
     
    92106
    93107/* Server */
     108
     109/** Hound server interace structure */
    94110typedef struct hound_server_iface {
     111        /** Create new context */
    95112        int (*add_context)(void *, hound_context_id_t *, const char *, bool);
     113        /** Destroy existing context */
    96114        int (*rem_context)(void *, hound_context_id_t);
     115        /** Query context direction */
    97116        bool (*is_record_context)(void *, hound_context_id_t);
     117        /** Get string identifiers of specified objects */
    98118        int (*get_list)(void *, const char ***, size_t *, const char *, int);
     119        /** Create connection between source and sink */
    99120        int (*connect)(void *, const char *, const char *);
     121        /** Destroy connection between source and sink */
    100122        int (*disconnect)(void *, const char *, const char *);
     123        /** Create new stream tied to the context */
    101124        int (*add_stream)(void *, hound_context_id_t, int, pcm_format_t, size_t,
    102125            void **);
     126        /** Destroy existing stream */
    103127        int (*rem_stream)(void *, void *);
     128        /** Block until the stream buffer is empty */
    104129        int (*drain_stream)(void *);
     130        /** Write new data to the stream */
    105131        int (*stream_data_write)(void *, const void *, size_t);
     132        /** Read data from the stream */
    106133        int (*stream_data_read)(void *, void *, size_t);
    107134        void *server;
  • uspace/lib/hound/src/client.c

    reb0ef51 r876f5561  
    4545#include "client.h"
    4646
    47 /***
    48  * CLIENT SIDE
    49  ***/
    50 
     47/** Stream structure */
    5148typedef struct hound_stream {
     49        /** link in context's list */
    5250        link_t link;
     51        /** audio data format fo the stream */
    5352        pcm_format_t format;
     53        /** IPC exchange representing the stream (in STREAM MODE) */
    5454        async_exch_t *exch;
     55        /** parent context */
    5556        hound_context_t *context;
     57        /** Stream flags */
    5658        int flags;
    5759} hound_stream_t;
    5860
     61/**
     62 * Linked list isntacen helper function.
     63 * @param l link
     64 * @return hound stream isntance.
     65 */
    5966static inline hound_stream_t * hound_stream_from_link(link_t *l)
    6067{
     
    6269}
    6370
     71/** Hound client context structure */
    6472typedef struct hound_context {
     73        /** Audio session */
    6574        hound_sess_t *session;
     75        /** context name, reported to the daemon */
    6676        const char *name;
     77        /** True if the instance is record context */
    6778        bool record;
     79        /** List of associated streams */
    6880        list_t stream_list;
     81        /** Main stream helper structure */
    6982        struct {
    7083                hound_stream_t *stream;
     
    7285                size_t bsize;
    7386        } main;
     87        /** Assigned context id */
    7488        hound_context_id_t id;
    7589} hound_context_t;
    7690
    77 
     91/**
     92 * Alloc and initialize context structure.
     93 * @param name Base for the real context name, will add task id.
     94 * @param record True if the new context should capture audio data.
     95 * @param format PCM format of the main pipe.
     96 * @param bsize Server size buffer size of the main stream.
     97 * @return valid pointer to initialized structure on success, NULL on failure
     98 */
    7899static hound_context_t *hound_context_create(const char *name, bool record,
    79100    pcm_format_t format, size_t bsize)
     
    111132}
    112133
     134/**
     135 * Playback context helper function.
     136 * @param name Base for the real context name, will add task id.
     137 * @param format PCM format of the main pipe.
     138 * @param bsize Server size buffer size of the main stream.
     139 * @return valid pointer to initialized structure on success, NULL on failure
     140 */
    113141hound_context_t * hound_context_create_playback(const char *name,
    114142    pcm_format_t format, size_t bsize)
     
    117145}
    118146
     147/**
     148 * Record context helper function.
     149 * @param name Base for the real context name, will add task id.
     150 * @param format PCM format of the main pipe.
     151 * @param bsize Server size buffer size of the main stream.
     152 * @return valid pointer to initialized structure on success, NULL on failure
     153 */
    119154hound_context_t * hound_context_create_capture(const char *name,
    120155    pcm_format_t format, size_t bsize)
     
    123158}
    124159
     160/**
     161 * Correctly dispose of the hound context structure.
     162 * @param hound context to remove.
     163 *
     164 * The function will destroy all associated streams first. Pointers
     165 * to these structures will become invalid and the function will block
     166 * if any of these stream needs to be drained first.
     167 */
    125168void hound_context_destroy(hound_context_t *hound)
    126169{
     
    139182}
    140183
     184/**
     185 * Get a list of possible connection targets.
     186 * @param[in] hound Hound context.
     187 * @param[out] names list of target string ids.
     188 * @param[out] count Number of elements in @p names list
     189 * @return Error code.
     190 *
     191 * The function will return deice sinks or source based on the context type.
     192 */
    141193int hound_context_get_available_targets(hound_context_t *hound,
    142194    const char ***names, size_t *count)
     
    149201}
    150202
     203/**
     204 * Get a list of targets connected to the context.
     205 * @param[in] hound Hound context.
     206 * @param[out] names list of target string ids.
     207 * @param[out] count Number of elements in @p names list
     208 * @return Error code.
     209 */
    151210int hound_context_get_connected_targets(hound_context_t *hound,
    152211    const char ***names, size_t *count)
     
    160219}
    161220
     221/**
     222 * Create a new connection to the target.
     223 * @param hound Hound context.
     224 * @param target String identifier of the desired target.
     225 * @return Error code.
     226 *
     227 * The function recognizes special 'HOUND_DEFAULT_TARGET' and will
     228 * connect to the first possible target if it is passed this value.
     229 */
    162230int hound_context_connect_target(hound_context_t *hound, const char* target)
    163231{
     
    189257}
    190258
     259/**
     260 * Destroy a connection to the target.
     261 * @param hound Hound context.
     262 * @param target String identifier of the desired target.
     263 * @return Error code.
     264 */
    191265int hound_context_disconnect_target(hound_context_t *hound, const char* target)
    192266{
     
    203277}
    204278
     279/**
     280 * Create a new stream associated with the context.
     281 * @param hound Hound context.
     282 * @param flags new stream flags.
     283 * @param format new stream PCM format.
     284 * @param bzise new stream server side buffer size (in bytes)
     285 * @return Valid pointer to a stream instance, NULL on failure.
     286 */
    205287hound_stream_t *hound_stream_create(hound_context_t *hound, unsigned flags,
    206288    pcm_format_t format, size_t bsize)
     
    229311}
    230312
     313/**
     314 * Destroy existing stream
     315 * @param stream The stream to destroy.
     316 *
     317 * Function will wait until the server side buffer is empty if the
     318 * HOUND_STREAM_DRAIN_ON_EXIT flag was set on creation.
     319 */
    231320void hound_stream_destroy(hound_stream_t *stream)
    232321{
     
    241330}
    242331
     332/**
     333 * Send new data to a stream.
     334 * @param stream The target stream
     335 * @param data data buffer
     336 * @param size size of the @p data buffer.
     337 * @return error code.
     338 */
    243339int hound_stream_write(hound_stream_t *stream, const void *data, size_t size)
    244340{
     
    249345}
    250346
     347/**
     348 * Get data from a stream.
     349 * @param stream The target stream.
     350 * @param data data buffer.
     351 * @param size size of the @p data buffer.
     352 * @return error code.
     353 */
    251354int hound_stream_read(hound_stream_t *stream, void *data, size_t size)
    252355{
     
    257360}
    258361
     362/**
     363 * Main stream getter function.
     364 * @param hound Houndcontext.
     365 * @return Valid stream pointer, NULL on failure.
     366 *
     367 * The function will create new stream, or return a pointer to the exiting one
     368 * if it exists.
     369 */
    259370static hound_stream_t * hound_get_main_stream(hound_context_t *hound)
    260371{
     
    267378}
    268379
     380/**
     381 * Send new data to the main stream.
     382 * @param stream The target stream
     383 * @param data data buffer
     384 * @param size size of the @p data buffer.
     385 * @return error code.
     386 */
    269387int hound_write_main_stream(hound_context_t *hound,
    270388    const void *data, size_t size)
    271389{
    272390        assert(hound);
     391        if (hound->record)
     392                return EINVAL;
     393
    273394        hound_stream_t *mstream = hound_get_main_stream(hound);
    274395        if (!mstream)
     
    277398}
    278399
     400/**
     401 * Get data from the main stream.
     402 * @param stream The target stream
     403 * @param data data buffer
     404 * @param size size of the @p data buffer.
     405 * @return error code.
     406 */
    279407int hound_read_main_stream(hound_context_t *hound, void *data, size_t size)
    280408{
    281409        assert(hound);
     410        if (!hound->record)
     411                return EINVAL;
    282412        hound_stream_t *mstream = hound_get_main_stream(hound);
    283413        if (!mstream)
     
    286416}
    287417
     418/**
     419 * Destroy the old main stream and replace it with a new one with fresh data.
     420 * @param hound Hound context.
     421 * @param data data buffer.
     422 * @param size size of the @p data buffer.
     423 * @return error code.
     424 *
     425 * NOT IMPLEMENTED
     426 */
    288427int hound_write_replace_main_stream(hound_context_t *hound,
    289428    const void *data, size_t size)
     
    296435}
    297436
    298 int hound_context_set_main_stream_format(hound_context_t *hound,
    299     unsigned channels, unsigned rate, pcm_sample_format_t format)
     437/**
     438 * Destroy the old main stream and replace it with a new one using new params.
     439 * @param hound Hound context.
     440 * @param channels
     441 * @return error code.
     442 *
     443 * NOT IMPLEMENTED
     444 */
     445int hound_context_set_main_stream_params(hound_context_t *hound,
     446    pcm_format_t format, size_t bsize)
    300447{
    301448        assert(hound);
     
    304451}
    305452
     453/**
     454 * Write data immediately to a new stream, and wait for it to drain.
     455 * @param hound Hound context.
     456 * @param format pcm data format.
     457 * @param data data buffer
     458 * @param size @p data buffer size
     459 * @return Error code.
     460 *
     461 * This functnion creates a new stream writes the data, ti waits for the stream
     462 * to drain and destroys it before returning.
     463 */
    306464int hound_write_immediate(hound_context_t *hound, pcm_format_t format,
    307465    const void *data, size_t size)
    308466{
    309467        assert(hound);
     468        if (hound->record)
     469                return EINVAL;
    310470        hound_stream_t *tmpstream = hound_stream_create(hound, 0, format, size);
    311471        if (!tmpstream)
     
    319479        return ret;
    320480}
    321 
    322 
    323481/**
    324482 * @}
  • uspace/lib/hound/src/protocol.c

    reb0ef51 r876f5561  
    4848
    4949enum ipc_methods {
     50        /** Create new context representation on the server side */
    5051        IPC_M_HOUND_CONTEXT_REGISTER = IPC_FIRST_USER_METHOD,
     52        /** Release existing context representation on the server side */
    5153        IPC_M_HOUND_CONTEXT_UNREGISTER,
     54        /** Request list of objects */
    5255        IPC_M_HOUND_GET_LIST,
     56        /** Create new connection */
    5357        IPC_M_HOUND_CONNECT,
     58        /** Destroy connection */
    5459        IPC_M_HOUND_DISCONNECT,
     60        /** Switch IPC pipe to stream mode */
    5561        IPC_M_HOUND_STREAM_ENTER,
     62        /** Switch IPC pipe back to general mode */
    5663        IPC_M_HOUND_STREAM_EXIT,
     64        /** Wait until there is no data in the stream */
    5765        IPC_M_HOUND_STREAM_DRAIN,
    5866};
    5967
     68
     69/** PCM format conversion helper structure */
    6070typedef union {
    6171        struct {
     
    7282 ****/
    7383
     84/** Well defined service name */
    7485const char *HOUND_SERVICE = "audio/hound";
    7586
     87/**
     88 * Start a new audio session.
     89 * @param service Named service typically 'HOUND_SERVICE' constant.
     90 * @return Valid session on success, NULL on failure.
     91 */
    7692hound_sess_t *hound_service_connect(const char *service)
    7793{
     
    84100}
    85101
     102/**
     103 * End an existing audio session.
     104 * @param sess The session.
     105 */
    86106void hound_service_disconnect(hound_sess_t *sess)
    87107{
     
    90110}
    91111
     112/**
     113 * Register a named application context to the audio server.
     114 * @param sess Valid audio session.
     115 * @param name Valid string identifier
     116 * @param record True if the application context wishes to receive data.
     117 * @return Valid ID on success, Error code on failure.
     118 */
    92119hound_context_id_t hound_service_register_context(hound_sess_t *sess,
    93120    const char *name, bool record)
     
    113140}
    114141
     142/**
     143 * Remove application context from the server's list.
     144 * @param sess Valid audio session.
     145 * @param id Valid context id.
     146 * @return Error code.
     147 */
    115148int hound_service_unregister_context(hound_sess_t *sess, hound_context_id_t id)
    116149{
     
    123156}
    124157
     158/**
     159 * Retrieve a list of server side actors.
     160 * @param[in] sess Valid audio session.
     161 * @param[out] ids list of string identifiers.
     162 * @param[out] count Number of elements int the @p ids list.
     163 * @param[in] flags list requirements.
     164 * @param[in] connection name of target actor. Used only if the list should
     165 *            contain connected actors.
     166 * @retval Error code.
     167 */
    125168int hound_service_get_list(hound_sess_t *sess, const char ***ids, size_t *count,
    126169    int flags, const char *connection)
     
    190233}
    191234
     235/**
     236 * Create a new connection between a source and a sink.
     237 * @param sess Valid audio session.
     238 * @param source Source name, valid string.
     239 * @param sink Sink name, valid string.
     240 * @return Error code.
     241 */
    192242int hound_service_connect_source_sink(hound_sess_t *sess, const char *source,
    193243    const char *sink)
     
    212262}
    213263
     264/**
     265 * Destroy an existing connection between a source and a sink.
     266 * @param sess Valid audio session.
     267 * @param source Source name, valid string.
     268 * @param sink Sink name, valid string.
     269 * @return Error code.
     270 */
    214271int hound_service_disconnect_source_sink(hound_sess_t *sess, const char *source,
    215272    const char *sink)
     
    231288}
    232289
     290/**
     291 * Switch IPC exchange to a STREAM mode.
     292 * @param exch IPC exchange.
     293 * @param id context id this stream should be associated with
     294 * @param flags set stream properties
     295 * @param format format of the new stream.
     296 * @param bsize size of the server side buffer.
     297 * @return Error code.
     298 */
    233299int hound_service_stream_enter(async_exch_t *exch, hound_context_id_t id,
    234300    int flags, pcm_format_t format, size_t bsize)
     
    243309}
    244310
     311/**
     312 * Destroy existing stream and return IPC exchange to general mode.
     313 * @param exch IPC exchange.
     314 * @return Error code.
     315 */
    245316int hound_service_stream_exit(async_exch_t *exch)
    246317{
     
    248319}
    249320
     321/**
     322 * Wait until the server side buffer is empty.
     323 * @param exch IPC exchange.
     324 * @return Error code.
     325 */
    250326int hound_service_stream_drain(async_exch_t *exch)
    251327{
     
    253329}
    254330
     331/**
     332 * Write audio data to a stream.
     333 * @param exch IPC exchange in STREAM MODE.
     334 * @param data Audio data buffer.
     335 * @size size of the buffer
     336 * @return Error code.
     337 */
    255338int hound_service_stream_write(async_exch_t *exch, const void *data, size_t size)
    256339{
     
    258341}
    259342
     343/**
     344 * Read data from a stream.
     345 * @param exch IPC exchange in STREAM MODE.
     346 * @param data Audio data buffer.
     347 * @size size of the buffer
     348 * @return Error code.
     349 */
    260350int hound_service_stream_read(async_exch_t *exch, void *data, size_t size)
    261351{
     
    271361static const hound_server_iface_t *server_iface;
    272362
     363/**
     364 * Set hound server interface implementation.
     365 * @param iface Initialized Hound server interface.
     366 */
    273367void hound_service_set_server_iface(const hound_server_iface_t *iface)
    274368{
     
    276370}
    277371
     372/**
     373 * Server side implementation of the hound protocol. IPC connection handler.
     374 * @param iid initial call id
     375 * @param icall pointer to initial call structure.
     376 * @param arg (unused)
     377 */
    278378void hound_connection_handler(ipc_callid_t iid, ipc_call_t *icall, void *arg)
    279379{
     
    291391                switch (IPC_GET_IMETHOD(call)) {
    292392                case IPC_M_HOUND_CONTEXT_REGISTER: {
     393                        /* check interface functions */
    293394                        if (!server_iface || !server_iface->add_context) {
    294395                                async_answer_0(callid, ENOTSUP);
     
    297398                        bool record = IPC_GET_ARG1(call);
    298399                        void *name;
     400
     401                        /* Get context name */
    299402                        int ret =
    300403                            async_data_write_accept(&name, true, 0, 0, 0, 0);
     
    306409                        ret = server_iface->add_context(server_iface->server,
    307410                            &id, name, record);
     411                        /** new context should create a copy */
     412                        free(name);
    308413                        if (ret != EOK) {
    309                                 free(name);
    310414                                async_answer_0(callid, ret);
    311415                        } else {
     
    315419                }
    316420                case IPC_M_HOUND_CONTEXT_UNREGISTER: {
     421                        /* check interface functions */
    317422                        if (!server_iface || !server_iface->rem_context) {
    318423                                async_answer_0(callid, ENOTSUP);
    319424                                break;
    320425                        }
     426
     427                        /* get id, 1st param */
    321428                        hound_context_id_t id = IPC_GET_ARG1(call);
    322429                        const int ret =
     
    326433                }
    327434                case IPC_M_HOUND_GET_LIST: {
     435                        /* check interface functions */
    328436                        if (!server_iface || !server_iface->get_list) {
    329437                                async_answer_0(callid, ENOTSUP);
    330438                                break;
    331439                        }
     440
    332441                        const char **list = NULL;
    333442                        const int flags = IPC_GET_ARG1(call);
     
    336445                        char *conn_name = NULL;
    337446                        int ret = EOK;
     447
     448                        /* get connected actor name if provided */
    338449                        if (conn)
    339450                                ret = async_data_write_accept(
     
    345456                                    conn_name, flags);
    346457                        free(conn_name);
     458
     459                        /* Alloc string sizes array */
    347460                        size_t *sizes = NULL;
    348461                        if (count)
     
    383496                }
    384497                case IPC_M_HOUND_CONNECT: {
     498                        /* check interface functions */
    385499                        if (!server_iface || !server_iface->connect) {
    386500                                async_answer_0(callid, ENOTSUP);
    387501                                break;
    388502                        }
     503
    389504                        void *source = NULL;
    390505                        void *sink = NULL;
     506
     507                        /* read source name */
    391508                        int ret =
    392509                            async_data_write_accept(&source, true, 0, 0, 0, 0);
     510                        /* read sink name */
     511                        if (ret == EOK)
     512                                ret = async_data_write_accept(&sink,
     513                                    true, 0, 0, 0, 0);
     514
     515                        if (ret == EOK)
     516                                ret = server_iface->connect(
     517                                    server_iface->server, source, sink);
     518                        free(source);
     519                        free(sink);
     520                        async_answer_0(callid, ret);
     521                        break;
     522                }
     523                case IPC_M_HOUND_DISCONNECT: {
     524                        /* check interface functions */
     525                        if (!server_iface || !server_iface->disconnect) {
     526                                async_answer_0(callid, ENOTSUP);
     527                                break;
     528                        }
     529
     530                        void *source = NULL;
     531                        void *sink = NULL;
     532
     533                        /* read source name */
     534                        int ret =
     535                            async_data_write_accept(&source, true, 0, 0, 0, 0);
     536                        /*read sink name */
    393537                        if (ret == EOK)
    394538                                ret = async_data_write_accept(&sink,
     
    402546                        break;
    403547                }
    404                 case IPC_M_HOUND_DISCONNECT: {
    405                         if (!server_iface || !server_iface->disconnect) {
    406                                 async_answer_0(callid, ENOTSUP);
    407                                 break;
    408                         }
    409                         void *source = NULL;
    410                         void *sink = NULL;
    411                         int ret =
    412                             async_data_write_accept(&source, true, 0, 0, 0, 0);
    413                         if (ret == EOK)
    414                                 ret = async_data_write_accept(&sink,
    415                                     true, 0, 0, 0, 0);
    416                         if (ret == EOK)
    417                                 ret = server_iface->connect(
    418                                     server_iface->server, source, sink);
    419                         free(source);
    420                         free(sink);
    421                         async_answer_0(callid, ret);
    422                         break;
    423                 }
    424548                case IPC_M_HOUND_STREAM_ENTER: {
     549                        /* check interface functions */
    425550                        if (!server_iface || !server_iface->is_record_context
    426551                            || !server_iface->add_stream
     
    430555                        }
    431556
     557                        /* get parameters */
    432558                        hound_context_id_t id = IPC_GET_ARG1(call);
    433559                        const int flags = IPC_GET_ARG2(call);
     
    439565                        };
    440566                        size_t bsize = IPC_GET_ARG4(call);
     567
    441568                        void *stream;
    442569                        int ret = server_iface->add_stream(server_iface->server,
     
    451578                                if(server_iface->stream_data_read) {
    452579                                        async_answer_0(callid, EOK);
     580                                        /* start answering read calls */
    453581                                        hound_server_write_data(stream);
    454582                                        server_iface->rem_stream(
     
    460588                                if (server_iface->stream_data_write) {
    461589                                        async_answer_0(callid, EOK);
     590                                        /* accept write calls */
    462591                                        hound_server_read_data(stream);
    463592                                        server_iface->rem_stream(
     
    481610}
    482611
     612/**
     613 * Read data and push it to the stream.
     614 * @param stream target stream, will push data there.
     615 */
    483616static void hound_server_read_data(void *stream)
    484617{
     
    487620        size_t size = 0;
    488621        int ret_answer = EOK;
     622        /* accept data write or drain */
    489623        while (async_data_write_receive_call(&callid, &call, &size)
    490624            || (IPC_GET_IMETHOD(call) == IPC_M_HOUND_STREAM_DRAIN)) {
     625                /* check drain first */
    491626                if (IPC_GET_IMETHOD(call) == IPC_M_HOUND_STREAM_DRAIN) {
    492627                        int ret = ENOTSUP;
     
    496631                        continue;
    497632                }
     633
     634                /* there was an error last time */
    498635                if (ret_answer != EOK) {
    499636                        async_answer_0(callid, ret_answer);
    500637                        continue;
    501638                }
     639
    502640                char *buffer = malloc(size);
    503641                if (!buffer) {
     
    507645                const int ret = async_data_write_finalize(callid, buffer, size);
    508646                if (ret == EOK) {
     647                        /* push data to stream */
    509648                        ret_answer = server_iface->stream_data_write(
    510649                            stream, buffer, size);
     
    517656}
    518657
     658/**
     659 * Accept reads and pull data from the stream.
     660 * @param stream target stream, will pull data from there.
     661 */
    519662static void hound_server_write_data(void *stream)
    520663{
     
    524667        size_t size = 0;
    525668        int ret_answer = EOK;
     669        /* accept data read and drain */
    526670        while (async_data_read_receive_call(&callid, &call, &size)
    527671            || (IPC_GET_IMETHOD(call) == IPC_M_HOUND_STREAM_DRAIN)) {
     672                /* drain does not make much sense but it is allowed */
    528673                if (IPC_GET_IMETHOD(call) == IPC_M_HOUND_STREAM_DRAIN) {
    529674                        int ret = ENOTSUP;
     
    533678                        continue;
    534679                }
     680                /* there was an error last time */
    535681                if (ret_answer != EOK) {
    536682                        async_answer_0(callid, ret_answer);
     
    559705 ***/
    560706
     707/**
     708 * Register new hound service to the location service.
     709 * @param[in] name server name
     710 * @param[out] id assigned service id.
     711 * @return Error code.
     712 */
    561713int hound_server_register(const char *name, service_id_t *id)
    562714{
     
    571723}
    572724
     725/**
     726 * Unregister server from the location service.
     727 * @param id previously assigned service id.
     728 */
    573729void hound_server_unregister(service_id_t id)
    574730{
     
    576732}
    577733
     734/**
     735 * Set callback on device category change event.
     736 * @param cb Callback function.
     737 * @return Error code.
     738 */
    578739int hound_server_set_device_change_callback(dev_change_callback_t cb)
    579740{
     
    581742}
    582743
    583 
     744/**
     745 * Walk through all device in the audio-pcm category.
     746 * @param callback Function to call on every device.
     747 * @return Error code.
     748 */
    584749int hound_server_devices_iterate(device_callback_t callback)
    585750{
Note: See TracChangeset for help on using the changeset viewer.