diff --git a/Audio/Chain/InputNode.m b/Audio/Chain/InputNode.m index 950097b4e..4b739248f 100644 --- a/Audio/Chain/InputNode.m +++ b/Audio/Chain/InputNode.m @@ -186,16 +186,18 @@ amountInBuffer = 0; bytesInBuffer = 0; } else { - if(initialBufferFilled == NO) { - [controller initialBufferFilled:self]; - } - DLog(@"End of stream? %@", [self properties]); endOfStream = YES; shouldClose = [controller endOfInputReached]; // Lets us know if we should keep going or not (occassionally, for track changes within a file) DLog(@"closing? is %i", shouldClose); + // Move this here, so that the above endOfInputReached has a chance to queue another track before starting output + // Technically, the output should still play out its buffer first before checking if it should stop + if(initialBufferFilled == NO) { + [controller initialBufferFilled:self]; + } + // wait before exiting, as we might still get seeking request DLog("InputNode: Before wait") [exitAtTheEndOfTheStream waitIndefinitely]; diff --git a/Audio/Output/OutputCoreAudio.m b/Audio/Output/OutputCoreAudio.m index 5cd9833dc..5e0281548 100644 --- a/Audio/Output/OutputCoreAudio.m +++ b/Audio/Output/OutputCoreAudio.m @@ -816,7 +816,13 @@ default_device_changed(AudioObjectID inObjectID, UInt32 inNumberAddresses, const [[NSUserDefaultsController sharedUserDefaultsController] removeObserver:self forKeyPath:@"values.GraphicEQenable"]; [[NSUserDefaultsController sharedUserDefaultsController] removeObserver:self forKeyPath:@"values.eqPreamp"]; } - if(stopNext && started && !paused) { + if(stopNext && !paused) { + if(!started) { + // This happens if playback is started on a very short file, and the queue is empty or at the end of the playlist + started = YES; + NSError *err; + [_au startHardwareAndReturnError:&err]; + } while(![[outputController buffer] isEmpty]) { [writeSemaphore signal]; [readSemaphore signal];