summaryrefslogtreecommitdiffstats
path: root/audio/filter/af_channels.c
diff options
context:
space:
mode:
Diffstat (limited to 'audio/filter/af_channels.c')
-rw-r--r--audio/filter/af_channels.c25
1 files changed, 11 insertions, 14 deletions
diff --git a/audio/filter/af_channels.c b/audio/filter/af_channels.c
index 27445aafe2..f77807a1af 100644
--- a/audio/filter/af_channels.c
+++ b/audio/filter/af_channels.c
@@ -168,7 +168,10 @@ static int control(struct af_instance* af, int cmd, void* arg)
af->data->rate = ((struct mp_audio*)arg)->rate;
mp_audio_set_format(af->data, ((struct mp_audio*)arg)->format);
- af->mul = (double)af->data->nch / ((struct mp_audio*)arg)->nch;
+ mp_audio_force_interleaved_format(af->data);
+ int r = af_test_output(af,(struct mp_audio*)arg);
+ if (r != AF_OK)
+ return r;
return check_routes(s,((struct mp_audio*)arg)->nch,af->data->nch);
case AF_CONTROL_COMMAND_LINE:{
int nch = 0;
@@ -218,9 +221,6 @@ static int control(struct af_instance* af, int cmd, void* arg)
static void uninit(struct af_instance* af)
{
free(af->setup);
- if (af->data)
- free(af->data->audio);
- free(af->data);
}
// Filter data through filter
@@ -231,20 +231,19 @@ static struct mp_audio* play(struct af_instance* af, struct mp_audio* data)
af_channels_t* s = af->setup;
int i;
- if(AF_OK != RESIZE_LOCAL_BUFFER(af,data))
- return NULL;
+ mp_audio_realloc_min(af->data, data->samples);
// Reset unused channels
- memset(l->audio,0,c->len / c->nch * l->nch);
+ memset(l->planes[0],0,mp_audio_psize(c) / c->nch * l->nch);
if(AF_OK == check_routes(s,c->nch,l->nch))
for(i=0;i<s->nr;i++)
- copy(c->audio,l->audio,c->nch,s->route[i][FR],
- l->nch,s->route[i][TO],c->len,c->bps);
+ copy(c->planes[0],l->planes[0],c->nch,s->route[i][FR],
+ l->nch,s->route[i][TO],mp_audio_psize(c),c->bps);
// Set output data
- c->audio = l->audio;
- c->len = c->len / c->nch * l->nch;
+ c->planes[0] = l->planes[0];
+ c->samples = c->samples / c->nch * l->nch;
mp_audio_set_channels(c, &l->channels);
return c;
@@ -255,10 +254,8 @@ static int af_open(struct af_instance* af){
af->control=control;
af->uninit=uninit;
af->play=play;
- af->mul=1;
- af->data=calloc(1,sizeof(struct mp_audio));
af->setup=calloc(1,sizeof(af_channels_t));
- if((af->data == NULL) || (af->setup == NULL))
+ if(af->setup == NULL)
return AF_ERROR;
return AF_OK;
}