]> git.pld-linux.org Git - packages/asterisk.git/commitdiff
- audiohook fixes from svn auto/th/asterisk-1_4_19-2
authorArkadiusz Miśkiewicz <arekm@maven.pl>
Wed, 9 Apr 2008 08:15:58 +0000 (08:15 +0000)
committercvs2git <feedback@pld-linux.org>
Sun, 24 Jun 2012 12:13:13 +0000 (12:13 +0000)
Changed files:
    asterisk-audiohook.patch -> 1.1

asterisk-audiohook.patch [new file with mode: 0644]

diff --git a/asterisk-audiohook.patch b/asterisk-audiohook.patch
new file mode 100644 (file)
index 0000000..f27d000
--- /dev/null
@@ -0,0 +1,70 @@
+Index: include/asterisk/slinfactory.h
+===================================================================
+--- include/asterisk/slinfactory.h     (wersja 113295)
++++ include/asterisk/slinfactory.h     (wersja 113296)
+@@ -48,6 +48,7 @@
+ int ast_slinfactory_feed(struct ast_slinfactory *sf, struct ast_frame *f);
+ int ast_slinfactory_read(struct ast_slinfactory *sf, short *buf, size_t samples);
+ unsigned int ast_slinfactory_available(const struct ast_slinfactory *sf);
++void ast_slinfactory_flush(struct ast_slinfactory *sf);
+ #if defined(__cplusplus) || defined(c_plusplus)
+ }
+Index: main/slinfactory.c
+===================================================================
+--- main/slinfactory.c (wersja 113295)
++++ main/slinfactory.c (wersja 113296)
+@@ -157,3 +157,21 @@
+ {
+       return sf->size;
+ }
++
++void ast_slinfactory_flush(struct ast_slinfactory *sf)
++{
++      struct ast_frame *fr = NULL;
++
++      if (sf->trans) {
++              ast_translator_free_path(sf->trans);
++              sf->trans = NULL;
++      }
++
++      while ((fr = AST_LIST_REMOVE_HEAD(&sf->queue, frame_list)))
++              ast_frfree(fr);
++
++      sf->size = sf->holdlen = 0;
++      sf->offset = sf->hold;
++
++      return;
++}
+Index: main/audiohook.c
+===================================================================
+--- main/audiohook.c   (wersja 113295)
++++ main/audiohook.c   (wersja 113296)
+@@ -128,14 +128,23 @@
+ int ast_audiohook_write_frame(struct ast_audiohook *audiohook, enum ast_audiohook_direction direction, struct ast_frame *frame)
+ {
+       struct ast_slinfactory *factory = (direction == AST_AUDIOHOOK_DIRECTION_READ ? &audiohook->read_factory : &audiohook->write_factory);
+-      struct timeval *time = (direction == AST_AUDIOHOOK_DIRECTION_READ ? &audiohook->read_time : &audiohook->write_time);
++      struct ast_slinfactory *other_factory = (direction == AST_AUDIOHOOK_DIRECTION_READ ? &audiohook->write_factory : &audiohook->read_factory);
++      struct timeval *time = (direction == AST_AUDIOHOOK_DIRECTION_READ ? &audiohook->read_time : &audiohook->write_time), previous_time = *time;
++      /* Update last feeding time to be current */
++      *time = ast_tvnow();
++
++      /* If we are using a sync trigger and this factory suddenly got audio fed in after a lapse, then flush both factories to ensure they remain in sync */
++      if (ast_test_flag(audiohook, AST_AUDIOHOOK_TRIGGER_SYNC) && ast_slinfactory_available(other_factory) && (ast_tvdiff_ms(*time, previous_time) > (ast_slinfactory_available(other_factory) / 8))) {
++              if (option_debug)
++                      ast_log(LOG_DEBUG, "Flushing audiohook %p so it remains in sync\n", audiohook);
++              ast_slinfactory_flush(factory);
++              ast_slinfactory_flush(other_factory);
++      }
++
+       /* Write frame out to respective factory */
+       ast_slinfactory_feed(factory, frame);
+-      /* Update last fed time for the above factory */
+-      *time = ast_tvnow();
+-
+       /* If we need to notify the respective handler of this audiohook, do so */
+       if ((ast_test_flag(audiohook, AST_AUDIOHOOK_TRIGGER_MODE) == AST_AUDIOHOOK_TRIGGER_READ) && (direction == AST_AUDIOHOOK_DIRECTION_READ)) {
+               ast_cond_signal(&audiohook->trigger);
This page took 0.047721 seconds and 4 git commands to generate.