summaryrefslogtreecommitdiffstats
path: root/audio/filter/af_pan.c
diff options
context:
space:
mode:
Diffstat (limited to 'audio/filter/af_pan.c')
-rw-r--r--audio/filter/af_pan.c20
1 files changed, 6 insertions, 14 deletions
diff --git a/audio/filter/af_pan.c b/audio/filter/af_pan.c
index b3e31dab98..3d8c6045d0 100644
--- a/audio/filter/af_pan.c
+++ b/audio/filter/af_pan.c
@@ -57,7 +57,6 @@ 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, AF_FORMAT_FLOAT_NE);
set_channels(af->data, s->nch ? s->nch: ((struct mp_audio*)arg)->nch);
- af->mul = (double)af->data->nch / ((struct mp_audio*)arg)->nch;
if((af->data->format != ((struct mp_audio*)arg)->format) ||
(af->data->bps != ((struct mp_audio*)arg)->bps)){
@@ -146,9 +145,6 @@ static int control(struct af_instance* af, int cmd, void* arg)
// Deallocate memory
static void uninit(struct af_instance* af)
{
- if(af->data)
- free(af->data->audio);
- free(af->data);
free(af->setup);
}
@@ -158,17 +154,16 @@ static struct mp_audio* play(struct af_instance* af, struct mp_audio* data)
struct mp_audio* c = data; // Current working data
struct mp_audio* l = af->data; // Local data
af_pan_t* s = af->setup; // Setup for this instance
- float* in = c->audio; // Input audio data
+ float* in = c->planes[0]; // Input audio data
float* out = NULL; // Output audio data
- float* end = in+c->len/4; // End of loop
+ float* end = in+c->samples*c->nch; // End of loop
int nchi = c->nch; // Number of input channels
int ncho = l->nch; // Number of output channels
register int j,k;
- if(AF_OK != RESIZE_LOCAL_BUFFER(af,data))
- return NULL;
+ mp_audio_realloc_min(af->data, data->samples);
- out = l->audio;
+ out = l->planes[0];
// Execute panning
// FIXME: Too slow
while(in < end){
@@ -184,8 +179,7 @@ static struct mp_audio* play(struct af_instance* af, struct mp_audio* data)
}
// Set output data
- c->audio = l->audio;
- c->len = c->len / c->nch * l->nch;
+ c->planes[0] = l->planes[0];
set_channels(c, l->nch);
return c;
@@ -196,10 +190,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_pan_t));
- if(af->data == NULL || af->setup == NULL)
+ if(af->setup == NULL)
return AF_ERROR;
return AF_OK;
}