summaryrefslogtreecommitdiffstats
path: root/libaf
diff options
context:
space:
mode:
authoranders <anders@b3059339-0415-0410-9bf9-f77b7e298cf2>2002-10-08 10:20:36 +0000
committeranders <anders@b3059339-0415-0410-9bf9-f77b7e298cf2>2002-10-08 10:20:36 +0000
commit3e3a4733fbd6655c1fd81c64cf46fb64fd7ed736 (patch)
tree41186a2df2c7e4034df5ec95abc176a602733230 /libaf
parentf767a62a4291dd41ff68fe8e6277f24443ff827d (diff)
downloadmpv-3e3a4733fbd6655c1fd81c64cf46fb64fd7ed736.tar.bz2
mpv-3e3a4733fbd6655c1fd81c64cf46fb64fd7ed736.tar.xz
Adding function for calculating the delay caused by the filters
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@7666 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libaf')
-rw-r--r--libaf/af.c13
-rw-r--r--libaf/af.h3
-rw-r--r--libaf/af_delay.c2
-rw-r--r--libaf/af_resample.c3
4 files changed, 20 insertions, 1 deletions
diff --git a/libaf/af.c b/libaf/af.c
index e4d496464d..14b06624cd 100644
--- a/libaf/af.c
+++ b/libaf/af.c
@@ -487,6 +487,19 @@ int af_calc_insize_constrained(af_stream_t* s, int len,
return in;
}
+/* Calculate the total delay [ms] caused by the filters */
+double af_calc_delay(af_stream_t* s)
+{
+ af_instance_t* af=s->first;
+ register double delay = 0.0;
+ // Iterate through all filters
+ while(af){
+ delay += af->delay;
+ af=af->next;
+ }
+ return delay;
+}
+
/* Helper function called by the macro with the same name this
function should not be called directly */
inline int af_resize_local_buffer(af_instance_t* af, af_data_t* data)
diff --git a/libaf/af.h b/libaf/af.h
index 26309aaf1b..73c7eefe1c 100644
--- a/libaf/af.h
+++ b/libaf/af.h
@@ -48,6 +48,7 @@ typedef struct af_instance_s
af_data_t* data; // configuration for outgoing data stream
struct af_instance_s* next;
struct af_instance_s* prev;
+ double delay; // Delay caused by the filter [ms]
frac_t mul; /* length multiplier: how much does this instance change
the length of the buffer. */
}af_instance_t;
@@ -180,6 +181,8 @@ int af_inputlen(af_stream_t* s, int len);
int af_calc_insize_constrained(af_stream_t* s, int len,
int max_outsize,int max_insize);
+/* Calculate the total delay caused by the filters */
+double af_calc_delay(af_stream_t* s);
// Helper functions and macros used inside the audio filters
diff --git a/libaf/af_delay.c b/libaf/af_delay.c
index e3b00e0961..be7eab9a95 100644
--- a/libaf/af_delay.c
+++ b/libaf/af_delay.c
@@ -41,11 +41,13 @@ static int control(struct af_instance_s* af, int cmd, void* arg)
mp_msg(MSGT_AFILTER,MSGL_ERR,"Error setting delay length in af_delay. Delay must be between 0s and 30s\n");
s->len=0;
s->tlen=0.0;
+ af->delay=0.0;
return AF_ERROR;
}
// Set new len and allocate new buffer
s->tlen = *((float*)arg);
+ af->delay = s->tlen * 1000.0;
s->len = af->data->rate*af->data->bps*af->data->nch*(int)s->tlen;
s->buf = malloc(s->len);
mp_msg(MSGT_AFILTER,MSGL_DBG2,"[delay] Delaying audio output by %0.2fs\n",s->tlen);
diff --git a/libaf/af_resample.c b/libaf/af_resample.c
index 7230c42f21..3d706dce83 100644
--- a/libaf/af_resample.c
+++ b/libaf/af_resample.c
@@ -258,7 +258,8 @@ static int control(struct af_instance_s* af, int cmd, void* arg)
mp_msg(MSGT_AFILTER,MSGL_V,"[resample] New filter designed up: %i down: %i\n", s->up, s->dn);
}
- // Set multiplier
+ // Set multiplier and delay
+ af->delay = (double)(1000*L/2)/((double)n->rate);
af->mul.n = s->up;
af->mul.d = s->dn;
return rv;