OSDN Git Service

MacGui: Fix errant encode done growl alert and send to MetaX function when finishing...
[handbrake-jp/handbrake-jp-git.git] / macosx / HBQueueController.mm
index f2f18b6..555ba5c 100644 (file)
@@ -149,7 +149,7 @@ static NSDictionary* _shortHeightAttribute = NULL;
          anything.*/
         hb_audio_config_t * audio;
         NSString * thisJobAudioCodecs = [NSString stringWithFormat:@""];
-        NSString * thisJobAudioInfo = [NSString stringWithFormat:@""]; // Setup a simple way to start the string
+        NSString * thisJobAudioInfo = [NSString stringWithFormat:@""];
         for( int i = 0; i < hb_list_count(job->list_audio); i++ )
         {
            audio = (hb_audio_config_t *) hb_list_audio_config_item( job->list_audio, i );
@@ -177,19 +177,19 @@ static NSDictionary* _shortHeightAttribute = NULL;
             /* Detailed Job audio track info*/
             /* Track Number and Mixdown Info */
             if (audio->out.mixdown == HB_ACODEC_AC3)// Remember for ac3 passthru the mixdown uses the source codec
-                thisJobAudioInfo = [thisJobAudioInfo stringByAppendingString:[NSString stringWithFormat:@" - Track %d: Source: %@ Output: %@, Pass-Thru", i + 1, [NSString stringWithUTF8String:audio->lang.description], outputCodec]];
+                thisJobAudioInfo = [thisJobAudioInfo stringByAppendingString:[NSString stringWithFormat:@"Track %d: Source: %@ Output: %@, Pass-Thru", i + 1, [NSString stringWithUTF8String:audio->lang.description], outputCodec]];
             else if (audio->out.mixdown == HB_AMIXDOWN_MONO)
-                thisJobAudioInfo = [thisJobAudioInfo stringByAppendingString:[NSString stringWithFormat:@" - Track %d: Source: %@ Output: %@, Mono", i + 1, [NSString stringWithUTF8String:audio->lang.description], outputCodec]];
+                thisJobAudioInfo = [thisJobAudioInfo stringByAppendingString:[NSString stringWithFormat:@"Track %d: Source: %@ Output: %@, Mono", i + 1, [NSString stringWithUTF8String:audio->lang.description], outputCodec]];
             else if (audio->out.mixdown == HB_AMIXDOWN_STEREO)
-                thisJobAudioInfo = [thisJobAudioInfo stringByAppendingString:[NSString stringWithFormat:@" - Track %d: Source: %@ Output: %@, Stereo", i + 1, [NSString stringWithUTF8String:audio->lang.description], outputCodec]];
+                thisJobAudioInfo = [thisJobAudioInfo stringByAppendingString:[NSString stringWithFormat:@"Track %d: Source: %@ Output: %@, Stereo", i + 1, [NSString stringWithUTF8String:audio->lang.description], outputCodec]];
             else if (audio->out.mixdown == HB_AMIXDOWN_DOLBY)
-                thisJobAudioInfo = [thisJobAudioInfo stringByAppendingString:[NSString stringWithFormat:@" - Track %d: Source: %@ Output: %@, Dolby Surround", i + 1, [NSString stringWithUTF8String:audio->lang.description], outputCodec]];
+                thisJobAudioInfo = [thisJobAudioInfo stringByAppendingString:[NSString stringWithFormat:@"Track %d: Source: %@ Output: %@, Dolby Surround", i + 1, [NSString stringWithUTF8String:audio->lang.description], outputCodec]];
             else if (audio->out.mixdown == HB_AMIXDOWN_DOLBYPLII)
-                thisJobAudioInfo = [thisJobAudioInfo stringByAppendingString:[NSString stringWithFormat:@" - Track %d: Source: %@ Output: %@, Dolby Pro Logic II", i + 1, [NSString stringWithUTF8String:audio->lang.description], outputCodec]];
+                thisJobAudioInfo = [thisJobAudioInfo stringByAppendingString:[NSString stringWithFormat:@"Track %d: Source: %@ Output: %@, Dolby Pro Logic II", i + 1, [NSString stringWithUTF8String:audio->lang.description], outputCodec]];
             else if (audio->out.mixdown == HB_AMIXDOWN_6CH)
-                thisJobAudioInfo = [thisJobAudioInfo stringByAppendingString:[NSString stringWithFormat:@" - Track %d: Source: %@ Output: %@, 6 Channel Discreet", i + 1, [NSString stringWithUTF8String:audio->lang.description], outputCodec]];
+                thisJobAudioInfo = [thisJobAudioInfo stringByAppendingString:[NSString stringWithFormat:@"Track %d: Source: %@ Output: %@, 6 Channel Discreet", i + 1, [NSString stringWithUTF8String:audio->lang.description], outputCodec]];
             else
-                thisJobAudioInfo = [thisJobAudioInfo stringByAppendingString:[NSString stringWithFormat:@" - Track %d: Source: %@ Output: Unknown Codec Info", i + 1, [NSString stringWithUTF8String:audio->lang.description]]];
+                thisJobAudioInfo = [thisJobAudioInfo stringByAppendingString:[NSString stringWithFormat:@"Track %d: Source: %@ Output: Unknown Codec Info", i + 1, [NSString stringWithUTF8String:audio->lang.description]]];
             
             thisJobAudioInfo = [thisJobAudioInfo stringByAppendingString:[NSString stringWithFormat:@", %d kbps, %d Hz", audio->out.bitrate, audio->out.samplerate]];
             
@@ -1473,6 +1473,8 @@ static NSString*    HBQueuePauseResumeToolbarIdentifier       = @"HBQueuePauseRe
         [fProgressBar setIndeterminate:NO];
         [fProgressBar stopAnimation:nil];
         [fProgressBar setDoubleValue:0.0];
+        
+        
     }
     
     else
@@ -1571,9 +1573,12 @@ static NSString*    HBQueuePauseResumeToolbarIdentifier       = @"HBQueuePauseRe
                          withSubtitleInfo: YES]];
         }
     }
-    
     else
+    {
         [fJobDescTextField setStringValue: @"No encodes pending"];
+    
+    }
+    
 }
 
 //------------------------------------------------------------------------------------
@@ -1748,7 +1753,29 @@ static NSString*    HBQueuePauseResumeToolbarIdentifier       = @"HBQueuePauseRe
 //------------------------------------------------------------------------------------
 - (void)currentJobChanged: (HBJob *) currentJob
 {
+    /* if the job has a destination path, lets perform finished job notifications in fHBController 
+     * We call this here so that we pickup the last job in the queue and single encodes before fCurrentJob
+     * is released. So for the first job and the beginning of single encodes we check for the existence
+     * of a valid fCurrentJob jobGroup
+     */
     [currentJob retain];
+    /* We need to compare the job group to determine if this is the end of a job group
+     * or just the end of a job within a group to keep from sending encode done notification
+     * after the first pass in a two pass encode
+     */
+    HBJobGroup * theJobGroupCheck = [currentJob jobGroup];
+    if ((theJobGroupCheck == nil) || (theJobGroupCheck != fCurrentJobGroup))
+    {
+        /* we need to make sure that we are not at the beginning of a queue and also that the job hasn't
+         * been cancelled
+         */
+        if ([[fCurrentJob jobGroup] destinationPath] && [fCurrentJobGroup status] != HBStatusCanceled)
+        {
+            /* send encode messages to fHBController. User prefs are grokked there. */
+            [fHBController showGrowlDoneNotification: [[fCurrentJob jobGroup] destinationPath]];
+            [fHBController sendToMetaX: [[fCurrentJob jobGroup] destinationPath]];
+        }
+    }
     [fCurrentJob release];
     fCurrentJob = currentJob;
 
@@ -1770,7 +1797,11 @@ static NSString*    HBQueuePauseResumeToolbarIdentifier       = @"HBQueuePauseRe
             // all other cases are assumed to be a successful encode. BTW, libhb
             // doesn't currently report errors back to the GUI.
             if ([fCurrentJobGroup status] != HBStatusCanceled)
+            {
                 [fCurrentJobGroup setStatus:HBStatusCompleted];
+            }
+            
+            
         }
         
         // Set the new group