media/liboggplay/bug520493.patch
author Jason Duell <jduell.mcbugs@gmail.com>
Sat, 17 Oct 2009 00:05:27 -0700
changeset 46662 a77022f7680c9486748abe5ddb55cb9af6686cea
parent 33825 4769862ade7f228613d64d9df1d716e196eba1bd
permissions -rw-r--r--
Add run_test_in_child() and do_load_child_test_harness() xpcshell functions (bug 521922). r=bent sr=ted Add necko 'unit_ipc' test directory under e10s, plus simple HTTP test.

diff --git a/media/liboggplay/src/liboggplay/oggplay.c b/media/liboggplay/src/liboggplay/oggplay.c
--- a/media/liboggplay/src/liboggplay/oggplay.c
+++ b/media/liboggplay/src/liboggplay/oggplay.c
@@ -638,16 +638,17 @@ OggPlayErrorCode
 oggplay_step_decoding(OggPlay *me) {
 
   OggPlayCallbackInfo  ** info;
   int                     num_records;
   int                     r;
   int                     i;
   int                     need_data  = 0;
   int                     chunk_count = 0;
+  int                     read_data = 0;
 
   if (me == NULL) {
     return E_OGGPLAY_BAD_OGGPLAY;
   }
   
   /* 
    * check whether the OggPlayDataCallback is set for the given
    * OggPlay handle. If not return with error as there's no callback 
@@ -686,17 +687,21 @@ read_more_data:
     if (me->active_tracks == 0) {
       int remaining = 0;
       for (i = 0; i < me->num_tracks; i++) {
         if (me->decode_data[i]->current_loc +
                      me->decode_data[i]->granuleperiod >= me->target + me->decode_data[i]->offset) {
           remaining++;
         }
       }
-      if (remaining == 0) {
+      if (remaining == 0 && !read_data) {
+        /*
+         * There's no more data to read, and we've not read any that needs 
+         * to be sent to the buffer list via a callback, so exit.
+         */
         return E_OGGPLAY_OK;
       }
     }
 
     /*
      * if any of the tracks have not yet met the target (modified by that
      * track's offset), then retrieve more data
      */
@@ -783,16 +788,21 @@ read_more_data:
          * e.g. some buffer overflow.
          */
       
       case OGGZ_ERR_OUT_OF_MEMORY:
         /* ran out of memory during decoding! */
         return E_OGGPLAY_OUT_OF_MEMORY;
                 
       default:
+        /*
+         * We read some data. Set a flag so that we're guaranteed to try to
+         * send it to the buffer list via a callback.
+         */
+        read_data = 1;
         break;
     }
   }
   /*
    * prepare a callback
    */
   num_records = oggplay_callback_info_prepare (me, &info);
   if (info != NULL) {