diff options
author | dynaflash <[email protected]> | 2008-11-20 20:52:03 +0000 |
---|---|---|
committer | dynaflash <[email protected]> | 2008-11-20 20:52:03 +0000 |
commit | 9b5251d846d08747d3f0a07aa3ef1dd14c6c532e (patch) | |
tree | 20db9c84cb627b6d8bb684714d039f615fc88024 /macosx | |
parent | f6d4ca235a2a9221148003aa223ff10f5f34e459 (diff) |
MacGui: Fix issue with queue where cancelling a two pass job during the first pass would leave the second pass in libhh which caused the next job to start by processing the remaining pass from the cancelled job.
- addresses bug reported here http://forum.handbrake.fr/viewtopic.php?f=12&t=7420
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@1936 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'macosx')
-rw-r--r-- | macosx/Controller.mm | 93 |
1 files changed, 53 insertions, 40 deletions
diff --git a/macosx/Controller.mm b/macosx/Controller.mm index 7681c1f3f..a1ab827e4 100644 --- a/macosx/Controller.mm +++ b/macosx/Controller.mm @@ -3047,46 +3047,6 @@ fWorkingCount = 0; //------------------------------------------------------------------------------------ -// Cancels and deletes the current job and stops libhb from processing the remaining -// encodes. -//------------------------------------------------------------------------------------ -- (void) doCancelCurrentJob -{ - // Stop the current job. hb_stop will only cancel the current pass and then set - // its state to HB_STATE_WORKDONE. It also does this asynchronously. So when we - // see the state has changed to HB_STATE_WORKDONE (in updateUI), we'll delete the - // remaining passes of the job and then start the queue back up if there are any - // remaining jobs. - - - hb_stop( fQueueEncodeLibhb ); - fEncodeState = 2; // don't alert at end of processing since this was a cancel - - // now that we've stopped the currently encoding job, lets mark it as cancelled - [[QueueFileArray objectAtIndex:currentQueueEncodeIndex] setObject:[NSNumber numberWithInt:3] forKey:@"Status"]; - // and as always, save it in the queue .plist... - /* We save all of the Queue data here */ - [self saveQueueFileItem]; - // so now lets move to - currentQueueEncodeIndex++ ; - // ... and see if there are more items left in our queue - int queueItems = [QueueFileArray count]; - /* If we still have more items in our queue, lets go to the next one */ - if (currentQueueEncodeIndex < queueItems) - { - [self writeToActivityLog: "doCancelCurrentJob currentQueueEncodeIndex is incremented to: %d", currentQueueEncodeIndex]; - [self writeToActivityLog: "doCancelCurrentJob moving to the next job"]; - - [self performNewQueueScan:[[QueueFileArray objectAtIndex:currentQueueEncodeIndex] objectForKey:@"SourcePath"] scanTitleNum:[[[QueueFileArray objectAtIndex:currentQueueEncodeIndex] objectForKey:@"TitleNumber"]intValue]]; - } - else - { - [self writeToActivityLog: "doCancelCurrentJob the item queue is complete"]; - } - -} - -//------------------------------------------------------------------------------------ // Displays an alert asking user if the want to cancel encoding of current job. // Cancel: returns immediately after posting the alert. Later, when the user // acknowledges the alert, doCancelCurrentJob is called. @@ -3130,9 +3090,62 @@ fWorkingCount = 0; } } +//------------------------------------------------------------------------------------ +// Cancels and deletes the current job and stops libhb from processing the remaining +// encodes. +//------------------------------------------------------------------------------------ +- (void) doCancelCurrentJob +{ + // Stop the current job. hb_stop will only cancel the current pass and then set + // its state to HB_STATE_WORKDONE. It also does this asynchronously. So when we + // see the state has changed to HB_STATE_WORKDONE (in updateUI), we'll delete the + // remaining passes of the job and then start the queue back up if there are any + // remaining jobs. + + + hb_stop( fQueueEncodeLibhb ); + + // Delete all remaining jobs since libhb doesn't do this on its own. + hb_job_t * job; + while( ( job = hb_job(fQueueEncodeLibhb, 0) ) ) + hb_rem( fQueueEncodeLibhb, job ); + + fEncodeState = 2; // don't alert at end of processing since this was a cancel + + // now that we've stopped the currently encoding job, lets mark it as cancelled + [[QueueFileArray objectAtIndex:currentQueueEncodeIndex] setObject:[NSNumber numberWithInt:3] forKey:@"Status"]; + // and as always, save it in the queue .plist... + /* We save all of the Queue data here */ + [self saveQueueFileItem]; + // so now lets move to + currentQueueEncodeIndex++ ; + // ... and see if there are more items left in our queue + int queueItems = [QueueFileArray count]; + /* If we still have more items in our queue, lets go to the next one */ + if (currentQueueEncodeIndex < queueItems) + { + [self writeToActivityLog: "doCancelCurrentJob currentQueueEncodeIndex is incremented to: %d", currentQueueEncodeIndex]; + [self writeToActivityLog: "doCancelCurrentJob moving to the next job"]; + + [self performNewQueueScan:[[QueueFileArray objectAtIndex:currentQueueEncodeIndex] objectForKey:@"SourcePath"] scanTitleNum:[[[QueueFileArray objectAtIndex:currentQueueEncodeIndex] objectForKey:@"TitleNumber"]intValue]]; + } + else + { + [self writeToActivityLog: "doCancelCurrentJob the item queue is complete"]; + } + +} + - (void) doCancelCurrentJobAndStop { hb_stop( fQueueEncodeLibhb ); + + // Delete all remaining jobs since libhb doesn't do this on its own. + hb_job_t * job; + while( ( job = hb_job(fQueueEncodeLibhb, 0) ) ) + hb_rem( fQueueEncodeLibhb, job ); + + fEncodeState = 2; // don't alert at end of processing since this was a cancel // now that we've stopped the currently encoding job, lets mark it as cancelled |