Changeset b266f9e in mainline for uspace/srv/audio/hound/hound_ctx.c


Ignore:
Timestamp:
2013-04-04T11:15:41Z (11 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
bf13c9a4
Parents:
6133470
Message:

hound: implement stream creation/destruction

File:
1 edited

Legend:

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

    r6133470 rb266f9e  
    3838
    3939#include "hound_ctx.h"
     40#include "log.h"
    4041
    4142hound_ctx_t *hound_record_ctx_get(const char *name)
     
    4950        if (ctx) {
    5051                link_initialize(&ctx->link);
     52                list_initialize(&ctx->streams);
    5153                ctx->sink = NULL;
    5254                ctx->source = malloc(sizeof(audio_source_t));
     
    7476        if (ctx->sink)
    7577                audio_sink_fini(ctx->sink);
     78        //TODO remove streams
    7679        free(ctx->source);
    7780        free(ctx->sink);
     
    8891{
    8992        assert(ctx);
    90         //TODO fix this
    91         return false;
     93        return ctx->source == NULL;
     94}
     95
     96hound_ctx_stream_t *hound_ctx_create_stream(hound_ctx_t *ctx, int flags,
     97        pcm_format_t format, size_t buffer_size)
     98{
     99        assert(ctx);
     100        hound_ctx_stream_t *stream = malloc(sizeof(hound_ctx_stream_t));
     101        if (stream) {
     102                link_initialize(&stream->link);
     103                stream->ctx = ctx;
     104                stream->flags = flags;
     105                stream->format = format;
     106                stream->allowed_size = buffer_size;
     107                list_append(&stream->link, &ctx->streams);
     108                log_verbose("CTX: %p added stream; flags:%#x ch: %u r:%u f:%s",
     109                    ctx, flags, format.channels, format.sampling_rate,
     110                    pcm_sample_format_str(format.sample_format));
     111        }
     112        return stream;
     113}
     114
     115void hound_ctx_destroy_stream(hound_ctx_stream_t *stream)
     116{
     117        if (stream) {
     118                list_remove(&stream->link);
     119                //TODO free used buffer space
     120                log_verbose("CTX: %p remove stream; flags:%#x ch: %u r:%u f:%s",
     121                    stream->ctx, stream->flags, stream->format.channels,
     122                    stream->format.sampling_rate,
     123                    pcm_sample_format_str(stream->format.sample_format));
     124                free(stream);
     125        }
    92126}
    93127
Note: See TracChangeset for help on using the changeset viewer.