OSDN Git Service

Allow multiple output audio tracks from a single DVD audio track.
authoreddyg <eddyg@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Fri, 15 Feb 2008 23:37:54 +0000 (23:37 +0000)
committereddyg <eddyg@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Fri, 15 Feb 2008 23:37:54 +0000 (23:37 +0000)
git-svn-id: svn://localhost/HandBrake/trunk@1266 b64f7644-9d1e-0410-96f1-a4d463321fa5

libhb/reader.c
macosx/Controller.mm

index 1d89c4f..0c45133 100644 (file)
@@ -24,7 +24,7 @@ typedef struct
  * Local prototypes
  **********************************************************************/
 static void        ReaderFunc( void * );
  * Local prototypes
  **********************************************************************/
 static void        ReaderFunc( void * );
-static hb_fifo_t * GetFifoForId( hb_job_t * job, int id );
+static hb_fifo_t ** GetFifoForId( hb_job_t * job, int id );
 
 /***********************************************************************
  * hb_reader_init
 
 /***********************************************************************
  * hb_reader_init
@@ -54,9 +54,11 @@ hb_thread_t * hb_reader_init( hb_job_t * job )
 static void ReaderFunc( void * _r )
 {
     hb_reader_t  * r = _r;
 static void ReaderFunc( void * _r )
 {
     hb_reader_t  * r = _r;
-    hb_fifo_t    * fifo;
+    hb_fifo_t   ** fifos;
     hb_buffer_t  * buf;
     hb_buffer_t  * buf;
+    hb_buffer_t  * buf_old;
     hb_list_t    * list;
     hb_list_t    * list;
+    int            n;
     int            chapter = -1;
     int            chapter_end = r->job->chapter_end;
 
     int            chapter = -1;
     int            chapter_end = r->job->chapter_end;
 
@@ -160,16 +162,36 @@ static void ReaderFunc( void * _r )
         while( ( buf = hb_list_item( list, 0 ) ) )
         {
             hb_list_rem( list, buf );
         while( ( buf = hb_list_item( list, 0 ) ) )
         {
             hb_list_rem( list, buf );
-            fifo = GetFifoForId( r->job, buf->id );
-            if( fifo )
-            {
-                while( !*r->die && !r->job->done &&
-                       hb_fifo_is_full( fifo ) )
+            fifos = GetFifoForId( r->job, buf->id );
+            if( fifos )
+            {  
+                buf->sequence = r->sequence++;
+                for( n = 0; fifos[n] != NULL; n++) 
                 {
                 {
-                    hb_snooze( 50 );
+                    if( n != 0 )
+                    {
+                        /*
+                         * Replace the buffer with a new copy of itself for when
+                         * it is being sent down multiple fifos.
+                         */
+                        buf_old = buf;
+                        buf = hb_buffer_init(buf_old->size);
+                        memcpy( buf->data, buf_old->data, buf->size );
+                        hb_buffer_copy_settings( buf, buf_old );
+                    }
+
+                    while( !*r->die && !r->job->done &&
+                           hb_fifo_is_full( fifos[n] ) )
+                    {
+                        /*
+                         * Loop until the incoming fifo is reaqdy to receive 
+                         * this buffer.
+                         */
+                        hb_snooze( 50 );
+                    }
+
+                    hb_fifo_push( fifos[n], buf );
                 }
                 }
-                buf->sequence = r->sequence++;
-                hb_fifo_push( fifo, buf );
             }
             else
             {
             }
             else
             {
@@ -201,12 +223,15 @@ static void ReaderFunc( void * _r )
  ***********************************************************************
  *
  **********************************************************************/
  ***********************************************************************
  *
  **********************************************************************/
-static hb_fifo_t * GetFifoForId( hb_job_t * job, int id )
+static hb_fifo_t ** GetFifoForId( hb_job_t * job, int id )
 {
     hb_title_t    * title = job->title;
     hb_audio_t    * audio;
     hb_subtitle_t * subtitle;
 {
     hb_title_t    * title = job->title;
     hb_audio_t    * audio;
     hb_subtitle_t * subtitle;
-    int             i;
+    int             i, n;
+    static hb_fifo_t * fifos[8];
+
+    memset(fifos, 0, sizeof(fifos));
 
     if( id == 0xE0 )
     {
 
     if( id == 0xE0 )
     {
@@ -220,7 +245,8 @@ static hb_fifo_t * GetFifoForId( hb_job_t * job, int id )
         } 
         else 
         {
         } 
         else 
         {
-            return job->fifo_mpeg2;
+            fifos[0] = job->fifo_mpeg2;
+            return fifos;
         }
     }
 
         }
     }
 
@@ -240,7 +266,9 @@ static hb_fifo_t * GetFifoForId( hb_job_t * job, int id )
                 subtitle->hits++;
                 if( job->subtitle_force )
                 {
                 subtitle->hits++;
                 if( job->subtitle_force )
                 {
-                    return subtitle->fifo_in;
+                    
+                    fifos[0] = subtitle->fifo_in;
+                    return fifos;
                 }
                 break;
             }
                 }
                 break;
             }
@@ -249,19 +277,26 @@ static hb_fifo_t * GetFifoForId( hb_job_t * job, int id )
         if( ( subtitle = hb_list_item( title->list_subtitle, 0 ) ) &&
             id == subtitle->id )
         {
         if( ( subtitle = hb_list_item( title->list_subtitle, 0 ) ) &&
             id == subtitle->id )
         {
-            return subtitle->fifo_in;
+            fifos[0] = subtitle->fifo_in;
+            return fifos;
         }
     }
     if( !job->indepth_scan ) 
     {
         }
     }
     if( !job->indepth_scan ) 
     {
+        n = 0;
         for( i = 0; i < hb_list_count( title->list_audio ); i++ )
         {
             audio = hb_list_item( title->list_audio, i );
             if( id == audio->id )
             {
         for( i = 0; i < hb_list_count( title->list_audio ); i++ )
         {
             audio = hb_list_item( title->list_audio, i );
             if( id == audio->id )
             {
-                return audio->fifo_in;
+                fifos[n++] = audio->fifo_in;
             }
         }
             }
         }
+
+        if( n != 0 )
+        {
+            return fifos;
+        }
     }
 
     return NULL;
     }
 
     return NULL;
index 279678c..8ef13d7 100644 (file)
@@ -2786,6 +2786,7 @@ the user is using "Custom" settings by determining the sender*/
     /* get the index of the selected audio */
     int thisAudioIndex = [sender indexOfSelectedItem] - 1;
 
     /* get the index of the selected audio */
     int thisAudioIndex = [sender indexOfSelectedItem] - 1;
 
+#if 0
     /* Handbrake can't currently cope with ripping the same source track twice */
     /* So, if this audio is also selected in the other audio track popup, set that popup's selection to "none" */
     /* get a reference to the two audio track popups */
     /* Handbrake can't currently cope with ripping the same source track twice */
     /* So, if this audio is also selected in the other audio track popup, set that popup's selection to "none" */
     /* get a reference to the two audio track popups */
@@ -2797,6 +2798,7 @@ the user is using "Custom" settings by determining the sender*/
         [otherAudioPopUp selectItemAtIndex: 0];
         [self audioTrackPopUpChanged: otherAudioPopUp];
     }
         [otherAudioPopUp selectItemAtIndex: 0];
         [self audioTrackPopUpChanged: otherAudioPopUp];
     }
+#endif
 
     /* pointer for the hb_audio_s struct we will use later on */
     hb_audio_t * audio;
 
     /* pointer for the hb_audio_s struct we will use later on */
     hb_audio_t * audio;