-/*
- * Copyright (C) 2009-2014 Andre Noll <maan@systemlinux.org>
- *
- * Licensed under the GPL v2. For licencing details see COPYING.
- */
+/* Copyright (C) 2009 Andre Noll <maan@tuebingen.mpg.de>, see file COPYING. */
/** \file fecdec_filter.c A filter that fec-decodes an audio stream. */
#include "error.h"
#include "list.h"
#include "sched.h"
-#include "ggo.h"
#include "buffer_tree.h"
#include "filter.h"
#include "string.h"
uint16_t slice_bytes;
/** Non-zero if this group is the beginning of the stream. */
uint8_t bos;
- /** Non-zero if this stream embedds audio headers into fec groups. */
+ /** Non-zero if this stream embeds audio headers into fec groups. */
uint8_t header_stream;
};
oldest = fg;
}
if (!group_complete(oldest) && !group_empty(oldest))
- PARA_WARNING_LOG("Clearing incomplete group %d "
+ PARA_WARNING_LOG("Clearing incomplete group %u "
"(contains %d slices)\n", oldest->h.group_num,
oldest->num_received_slices);
if (oldest == pfd->first_complete_group)
uint8_t slice_num = fg->h.slice_num;
if (group_complete(fg)) {
- PARA_DEBUG_LOG("group %d complete, ignoring slice %d\n",
+ PARA_DEBUG_LOG("group %u complete, ignoring slice %d\n",
fg->h.group_num, slice_num);
return 0;
}
if (fg->num_slices == 0) {
fg->num_slices = fg->h.slices_per_group;
- fg->idx = para_malloc(fg->num_slices * sizeof(int));
- fg->data = para_calloc(fg->num_slices * sizeof(unsigned char *));
+ fg->idx = arr_alloc(fg->num_slices, sizeof(int));
+ fg->data = arr_zalloc(fg->num_slices, sizeof(unsigned char *));
}
r = fg->num_received_slices;
/* Check if we already have this slice. */
if (test_and_set_slice_bit(fg, slice_num)) {
- PARA_INFO_LOG("ignoring duplicate slice %d:%d\n", fg->h.group_num,
+ PARA_INFO_LOG("ignoring duplicate slice %u:%d\n", fg->h.group_num,
slice_num);
return 0;
}
fg->idx[r] = slice_num;
- fg->data[r] = para_malloc(fg->h.slice_bytes);
+ fg->data[r] = alloc(fg->h.slice_bytes);
memcpy(fg->data[r], buf, fg->h.slice_bytes);
fg->num_received_slices++;
return 1;
char *buf = NULL;
if (u == FEC_GROUP_UNUSABLE) {
- PARA_INFO_LOG("dropping unusable group %d\n", fg->h.group_num);
+ PARA_INFO_LOG("dropping unusable group %u\n", fg->h.group_num);
return 0;
}
- PARA_DEBUG_LOG("decoding group %d (%d slices)\n", fg->h.group_num,
+ PARA_DEBUG_LOG("decoding group %u (%d slices)\n", fg->h.group_num,
fg->h.data_slices_per_group);
ret = fec_decode(pfd->fec, fg->data, fg->idx, sb);
if (ret < 0)
i = DIV_ROUND_UP(fg->h.audio_header_size, fg->h.slice_bytes);
PARA_DEBUG_LOG("skipping %d header slices\n", i);
}
- PARA_DEBUG_LOG("writing group %d (%d/%d decoded data bytes)\n",
+ PARA_DEBUG_LOG("writing group %u (%u/%d decoded data bytes)\n",
fg->h.group_num, fg->h.group_bytes,
fg->h.data_slices_per_group * sb);
need = (fg->h.data_slices_per_group - i) * sb;
fn->private_data = NULL;
}
-static int fecdec_post_select(__a_unused struct sched *s, void *context)
+static int fecdec_post_monitor(__a_unused struct sched *s, void *context)
{
struct filter_node *fn = context;
struct btr_node *btrn = fn->btrn;
static void fecdec_open(struct filter_node *fn)
{
struct private_fecdec_data *pfd;
- pfd = para_calloc(sizeof(*pfd));
+ pfd = zalloc(sizeof(*pfd));
fn->private_data = pfd;
fn->min_iqs = FEC_HEADER_SIZE;
}
-/**
- * The init function of the fecdec filter.
- *
- * \param f Struct to initialize.
- */
-void fecdec_filter_init(struct filter *f)
-{
- f->close = fecdec_close;
- f->open = fecdec_open;
- f->pre_select = generic_filter_pre_select;
- f->post_select = fecdec_post_select;
-}
+const struct filter lsg_filter_cmd_com_fecdec_user_data = {
+ .open = fecdec_open,
+ .pre_monitor = generic_filter_pre_monitor,
+ .post_monitor = fecdec_post_monitor,
+ .close = fecdec_close,
+};