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


Ignore:
Timestamp:
2013-04-03T19:02:48Z (12 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
8f8ec69
Parents:
b893cd6
Message:

hound: initialize ctx source/sink

File:
1 edited

Legend:

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

    rb893cd6 raab8e3d3  
    3939#include "hound_ctx.h"
    4040
    41 static void hound_ctx_init_common(hound_ctx_t *ctx)
    42 {
    43         if (!ctx)
    44                 return;
    45         link_initialize(&ctx->link);
    46 }
    47 
    4841hound_ctx_t *hound_record_ctx_get(const char *name)
    4942{
     
    5447{
    5548        hound_ctx_t *ctx = malloc(sizeof(hound_ctx_t));
    56         hound_ctx_init_common(ctx);
     49        if (ctx) {
     50                link_initialize(&ctx->link);
     51                ctx->sink = NULL;
     52                ctx->source = malloc(sizeof(audio_source_t));
     53                if (!ctx->source) {
     54                        free(ctx);
     55                        return NULL;
     56                }
     57                const int ret = audio_source_init(ctx->source, name, ctx, NULL,
     58                    NULL, &AUDIO_FORMAT_ANY);
     59                if (ret != EOK) {
     60                        free(ctx->source);
     61                        free(ctx);
     62                        return NULL;
     63                }
     64        }
    5765        return ctx;
    5866}
     
    6270        assert(ctx);
    6371        assert(!link_in_use(&ctx->link));
     72        if (ctx->source)
     73                audio_source_fini(ctx->source);
     74        if (ctx->sink)
     75                audio_sink_fini(ctx->sink);
     76        free(ctx->source);
     77        free(ctx->sink);
    6478        free(ctx);
    6579}
Note: See TracChangeset for help on using the changeset viewer.