aboutsummaryrefslogtreecommitdiffstats
path: root/main/file.c
diff options
context:
space:
mode:
authorrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2008-06-13 12:45:50 +0000
committerrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2008-06-13 12:45:50 +0000
commita720d9e5c87511d93077f86d4fac2ed3d563bc06 (patch)
tree857ccefe1322ae0e28d63bf209482b762087b97d /main/file.c
parentfdd4115f4d6f5212f782b32d5fc5a5cd4dc3dd23 (diff)
Merge changes from timing branch
- Convert chan_iax2 to use the timing API - Convert usage of timing in the core to use the timing API instead of using DAHDI directly - Make a change to the timing API to add the set_rate() function - change the timing core to use a rwlock - merge a timing implementation, res_timing_dahdi Basic testing was successful using res_timing_dahdi git-svn-id: http://svn.digium.com/svn/asterisk/trunk@122523 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main/file.c')
-rw-r--r--main/file.c25
1 files changed, 9 insertions, 16 deletions
diff --git a/main/file.c b/main/file.c
index 15b6a5d88..8e27c58a0 100644
--- a/main/file.c
+++ b/main/file.c
@@ -29,6 +29,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include <dirent.h>
#include <sys/stat.h>
+#include <math.h>
#include "asterisk/_private.h" /* declare ast_file_init() */
#include "asterisk/paths.h" /* use ast_config_AST_DATA_DIR */
@@ -659,21 +660,17 @@ static enum fsread_res ast_readaudio_callback(struct ast_filestream *s)
}
}
if (whennext != s->lasttimeout) {
-#ifdef HAVE_DAHDI
if (s->owner->timingfd > -1) {
- int zap_timer_samples = whennext;
- int rate;
- /* whennext is in samples, but DAHDI timers operate in 8 kHz samples. */
- if ((rate = ast_format_rate(s->fmt->format)) != 8000) {
- float factor;
- factor = ((float) rate) / ((float) 8000.0);
- zap_timer_samples = (int) ( ((float) zap_timer_samples) / factor );
- }
- ast_settimeout(s->owner, zap_timer_samples, ast_fsread_audio, s);
- } else
-#endif
+ float samp_rate = (float) ast_format_rate(s->fmt->format);
+ unsigned int rate;
+
+ rate = (unsigned int) roundf(samp_rate / ((float) whennext));
+
+ ast_settimeout(s->owner, rate, ast_fsread_audio, s);
+ } else {
s->owner->streamid = ast_sched_add(s->owner->sched,
whennext / (ast_format_rate(s->fmt->format) / 1000), ast_fsread_audio, s);
+ }
s->lasttimeout = whennext;
return FSREAD_SUCCESS_NOSCHED;
}
@@ -681,9 +678,7 @@ static enum fsread_res ast_readaudio_callback(struct ast_filestream *s)
return_failure:
s->owner->streamid = -1;
-#ifdef HAVE_DAHDI
ast_settimeout(s->owner, 0, NULL, NULL);
-#endif
return FSREAD_FAILURE;
}
@@ -792,9 +787,7 @@ int ast_closestream(struct ast_filestream *f)
if (f->fmt->format & AST_FORMAT_AUDIO_MASK) {
f->owner->stream = NULL;
AST_SCHED_DEL(f->owner->sched, f->owner->streamid);
-#ifdef HAVE_DAHDI
ast_settimeout(f->owner, 0, NULL, NULL);
-#endif
} else {
f->owner->vstream = NULL;
AST_SCHED_DEL(f->owner->sched, f->owner->vstreamid);