summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
d6e0177)
Similar to the previous commit for the flac decoder, this commit
removes the loop in wmadec_post_select(). This gives other tasks a
chance to run and simplifies the code.
Also, if the buffer was not filled completely, it is truncated to
the proper size to reduce memory usage of the decoder.
static void wmadec_post_select(__a_unused struct sched *s, struct task *t)
{
struct filter_node *fn = container_of(t, struct filter_node, task);
static void wmadec_post_select(__a_unused struct sched *s, struct task *t)
{
struct filter_node *fn = container_of(t, struct filter_node, task);
+ int ret, converted, out_size;
struct private_wmadec_data *pwd = fn->private_data;
struct btr_node *btrn = fn->btrn;
size_t len;
struct private_wmadec_data *pwd = fn->private_data;
struct btr_node *btrn = fn->btrn;
size_t len;
next_buffer:
converted = 0;
next_buffer:
converted = 0;
goto success;
}
fn->min_iqs = WMA_FRAME_SKIP + pwd->ahi.block_align;
goto success;
}
fn->min_iqs = WMA_FRAME_SKIP + pwd->ahi.block_align;
- for (;;) {
- char *out;
- int out_size = WMA_OUTPUT_BUFFER_SIZE;
- if (converted + fn->min_iqs > len)
- break;
- out = para_malloc(WMA_OUTPUT_BUFFER_SIZE);
- ret = wma_decode_superframe(pwd, out,
- &out_size, (uint8_t *)in + converted + WMA_FRAME_SKIP,
- len - WMA_FRAME_SKIP);
- if (ret < 0) {
- free(out);
- goto err;
- }
- btr_add_output(out, out_size, btrn);
- converted += ret + WMA_FRAME_SKIP;
+ if (fn->min_iqs > len)
+ goto success;
+ out_size = WMA_OUTPUT_BUFFER_SIZE;
+ out = para_malloc(out_size);
+ ret = wma_decode_superframe(pwd, out, &out_size,
+ (uint8_t *)in + WMA_FRAME_SKIP, len - WMA_FRAME_SKIP);
+ if (ret < 0) {
+ free(out);
+ goto err;
+ out = para_realloc(out, out_size);
+ if (out_size > 0)
+ btr_add_output(out, out_size, btrn);
+ converted += ret + WMA_FRAME_SKIP;
success:
btr_consume(btrn, converted);
return;
success:
btr_consume(btrn, converted);
return;