All pastes #955393 Raw Edit

Anonymous

public text v1 · immutable
#955393 ·published 2008-03-24 16:25 UTC
rendered paste body
Index: include/asterisk/frame.h
===================================================================
--- include/asterisk/frame.h    (revision 110613)
+++ include/asterisk/frame.h    (working copy)
@@ -130,6 +130,9 @@
         *  The translator can not be free'd if the frame inside of it still has
         *  this flag set. */
        AST_FRFLAG_FROM_TRANSLATOR = (1 << 1),
+       /*! This is the last frame from the current source.  An example is when
+        *  reading from a file, we have reached the end of it. */
+       AST_FRFLAG_LAST =            (1 << 2),
 };
 
 /*! \brief Data structure associated with a single frame of data
Index: codecs/codec_resample.c
===================================================================
--- codecs/codec_resample.c     (revision 110613)
+++ codecs/codec_resample.c     (working copy)
@@ -117,7 +117,7 @@
 
                out_buf_used = resample_process(resampler, resample_factor,
                        &in_buf_f[total_in_buf_used], f->samples - total_in_buf_used,
-                       0, &in_buf_used,
+                       ast_test_flag(f, AST_FRFLAG_LAST), &in_buf_used,
                        &out_buf_f[total_out_buf_used], ARRAY_LEN(out_buf_f) - total_out_buf_used);
 
                if (out_buf_used < 0)
Index: formats/format_gsm.c
===================================================================
--- formats/format_gsm.c        (revision 110613)
+++ formats/format_gsm.c        (working copy)
@@ -61,6 +61,9 @@
                        ast_log(LOG_WARNING, "Short read (%d) (%s)!\n", res, strerror(errno));
                return NULL;
        }
+       if (feof(s->f)) {
+               ast_set_flag(&s->fr, AST_FRFLAG_LAST);
+       }
        *whennext = s->fr.samples = GSM_SAMPLES;
        return &s->fr;
 }
Index: formats/format_g729.c
===================================================================
--- formats/format_g729.c       (revision 110613)
+++ formats/format_g729.c       (working copy)
@@ -55,6 +55,9 @@
                        ast_log(LOG_WARNING, "Short read (%d) (%s)!\n", res, strerror(errno));
                return NULL;
        }
+       if (feof(s->f)) {
+               ast_set_flag(&s->fr, AST_FRFLAG_LAST);
+       }
        *whennext = s->fr.samples;
        return &s->fr;
 }
Index: formats/format_sln.c
===================================================================
--- formats/format_sln.c        (revision 110613)
+++ formats/format_sln.c        (working copy)
@@ -47,7 +47,10 @@
                        ast_log(LOG_WARNING, "Short read (%d) (%s)!\n", res, strerror(errno));
                return NULL;
        }
-       *whennext = s->fr.samples = res/2;
+       *whennext = s->fr.samples = res / 2;
+       if (feof(s->f)) {
+               ast_set_flag(&s->fr, AST_FRFLAG_LAST);
+       }
        s->fr.datalen = res;
        return &s->fr;
 }
Index: formats/format_wav.c
===================================================================
--- formats/format_wav.c        (revision 110613)
+++ formats/format_wav.c        (working copy)
@@ -362,6 +362,9 @@
                        ast_log(LOG_WARNING, "Short read (%d) (%s)!\n", res, strerror(errno));
                return NULL;
        }
+       if (feof(s->f)) {
+               ast_set_flag(&s->fr, AST_FRFLAG_LAST);
+       }
        s->fr.datalen = res;
        s->fr.samples = samples = res / 2;
 
Index: formats/format_ogg_vorbis.c
===================================================================
--- formats/format_ogg_vorbis.c (revision 110613)
+++ formats/format_ogg_vorbis.c (working copy)
@@ -483,6 +483,10 @@
                fs->fr.samples = samples_out;
                *whennext = samples_out;
 
+               if (feof(fs->f)) {
+                       ast_set_flag(&fs->fr, AST_FRFLAG_LAST);
+               }
+
                return &fs->fr;
        } else {
                return NULL;
Index: formats/format_sln16.c
===================================================================
--- formats/format_sln16.c      (revision 110613)
+++ formats/format_sln16.c      (working copy)
@@ -48,7 +48,10 @@
                        ast_log(LOG_WARNING, "Short read (%d) (%s)!\n", res, strerror(errno));
                return NULL;
        }
-       *whennext = s->fr.samples = res/2;
+       *whennext = s->fr.samples = res / 2;
+       if (feof(s->f)) {
+               ast_set_flag(&s->fr, AST_FRFLAG_LAST);
+       }
        s->fr.datalen = res;
        return &s->fr;
 }
Index: formats/format_wav_gsm.c
===================================================================
--- formats/format_wav_gsm.c    (revision 110613)
+++ formats/format_wav_gsm.c    (working copy)
@@ -413,6 +413,9 @@
                /* Just return a frame based on the second GSM frame */
                s->fr.data = (char *)s->fr.data + GSM_FRAME_SIZE;
                s->fr.offset += GSM_FRAME_SIZE;
+               if (feof(s->f)) {
+                       ast_set_flag(&s->fr, AST_FRFLAG_LAST);
+               }
        } else {
                /* read and convert */
                unsigned char msdata[MSGSM_FRAME_SIZE];
Index: formats/format_ilbc.c
===================================================================
--- formats/format_ilbc.c       (revision 110613)
+++ formats/format_ilbc.c       (working copy)
@@ -53,6 +53,9 @@
                        ast_log(LOG_WARNING, "Short read (%d) (%s)!\n", res, strerror(errno));
                return NULL;
        }
+       if (feof(s->f)) {
+               ast_set_flag(&s->fr, AST_FRFLAG_LAST);
+       }
        *whennext = s->fr.samples = ILBC_SAMPLES;
        return &s->fr;
 }
Index: formats/format_vox.c
===================================================================
--- formats/format_vox.c        (revision 110613)
+++ formats/format_vox.c        (working copy)
@@ -49,6 +49,9 @@
                        ast_log(LOG_WARNING, "Short read (%d) (%s)!\n", res, strerror(errno));
                return NULL;
        }
+       if (feof(s->f)) {
+               ast_set_flag(&s->fr, AST_FRFLAG_LAST);
+       }
        *whennext = s->fr.samples = res * 2;
        s->fr.datalen = res;
        return &s->fr;
Index: formats/format_pcm.c
===================================================================
--- formats/format_pcm.c        (revision 110613)
+++ formats/format_pcm.c        (working copy)
@@ -88,6 +88,9 @@
                        ast_log(LOG_WARNING, "Short read (%d) (%s)!\n", res, strerror(errno));
                return NULL;
        }
+       if (feof(s->f)) {
+               ast_set_flag(&s->fr, AST_FRFLAG_LAST);
+       }
        s->fr.datalen = res;
        if (s->fmt->format == AST_FORMAT_G722)
                *whennext = s->fr.samples = res * 2;
Index: formats/format_g723.c
===================================================================
--- formats/format_g723.c       (revision 110613)
+++ formats/format_g723.c       (working copy)
@@ -68,6 +68,9 @@
                ast_log(LOG_WARNING, "Short read (%d of %d bytes) (%s)!\n", res, size, strerror(errno));
                return NULL;
        }
+       if (feof(s->f)) {
+               ast_set_flag(&s->fr, AST_FRFLAG_LAST);
+       }
        *whennext = s->fr.samples = 240;
        return &s->fr;
 }
Index: formats/format_g726.c
===================================================================
--- formats/format_g726.c       (revision 110613)
+++ formats/format_g726.c       (working copy)
@@ -128,6 +128,9 @@
                        ast_log(LOG_WARNING, "Short read (%d) (%s)!\n", res, strerror(errno));
                return NULL;
        }
+       if (feof(s->f)) {
+               ast_set_flag(&s->fr, AST_FRFLAG_LAST);
+       }
        *whennext = s->fr.samples;
        return &s->fr;
 }