Changeset 3b6c1d4 in mainline for uspace/srv/audio/hound/iface.c


Ignore:
Timestamp:
2013-04-02T15:13:12Z (11 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
62beb4b
Parents:
2d1fdcad
Message:

hound: implement context manipulation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/audio/hound/iface.c

    r2d1fdcad r3b6c1d4  
    3838#include <hound/protocol.h>
    3939#include <malloc.h>
     40
     41#include "hound.h"
     42#include "hound_ctx.h"
    4043#include "log.h"
    4144
     
    4346    const char *name, bool record)
    4447{
    45         log_info("%s: %p, %s, %s", __FUNCTION__, server, name, record ? "REC" : "PLAY");
    46         *id = 1;
    47         return EOK;
     48        assert(server);
     49        assert(id);
     50        assert(name);
     51
     52        hound_ctx_t *ctx = record ? hound_record_ctx_get(name) :
     53            hound_playback_ctx_get(name);
     54        if (!ctx)
     55                return ENOMEM;
     56
     57        const int ret = hound_add_ctx(server, ctx);
     58        if (ret != EOK)
     59                hound_ctx_destroy(ctx);
     60        else
     61                *id = hound_ctx_get_id(ctx);
     62        return ret;
    4863}
    4964
    5065static int iface_rem_context(void *server, hound_context_id_t id)
    5166{
     67        assert(server);
     68        hound_ctx_t *ctx = hound_get_ctx_by_id(server, id);
     69        if (!ctx)
     70                return EINVAL;
     71        hound_remove_ctx(server, ctx);
     72        hound_ctx_destroy(ctx);
    5273        log_info("%s: %p, %d", __FUNCTION__, server, id);
    53         return ENOTSUP;
     74        return EOK;
    5475}
    5576
    5677static bool iface_is_record_context(void *server, hound_context_id_t id)
    5778{
     79        assert(server);
     80        hound_ctx_t *ctx = hound_get_ctx_by_id(server, id);
     81        if (!ctx)
     82                return false;
    5883        log_info("%s: %p, %d", __FUNCTION__, server, id);
    59         return false;
     84        return hound_ctx_is_record(ctx);
    6085}
    6186
     
    7398{
    7499        log_info("%s: %p, %s -> %s", __FUNCTION__, server, source, sink);
    75         return EOK;
     100        return ENOTSUP;
    76101}
    77102
     
    89114            pcm_sample_format_str(format.sample_format));
    90115        *data = (void*)"TEST_STREAM";
    91         return EOK;
     116        return ENOTSUP;
    92117}
    93118
Note: See TracChangeset for help on using the changeset viewer.