Fixes starting playback on short files

These two changes fix playback issues with either starting in the middle
of the playlist on a really short file terminating immediately instead
of queueing more files (InputNode.m), and issues with starting playback
at all on the end of a playlist on a short file. (OutputCoreAudio.m)

Fixes #246

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
CQTexperiment
Christopher Snowhill 2022-03-05 15:53:47 -08:00
parent 7c5cec1eb7
commit 6dccaa4d7f
2 changed files with 13 additions and 5 deletions

View File

@ -186,16 +186,18 @@
amountInBuffer = 0; amountInBuffer = 0;
bytesInBuffer = 0; bytesInBuffer = 0;
} else { } else {
if(initialBufferFilled == NO) {
[controller initialBufferFilled:self];
}
DLog(@"End of stream? %@", [self properties]); DLog(@"End of stream? %@", [self properties]);
endOfStream = YES; endOfStream = YES;
shouldClose = [controller endOfInputReached]; // Lets us know if we should keep going or not (occassionally, for track changes within a file) 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); 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 // wait before exiting, as we might still get seeking request
DLog("InputNode: Before wait") DLog("InputNode: Before wait")
[exitAtTheEndOfTheStream waitIndefinitely]; [exitAtTheEndOfTheStream waitIndefinitely];

View File

@ -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.GraphicEQenable"];
[[NSUserDefaultsController sharedUserDefaultsController] removeObserver:self forKeyPath:@"values.eqPreamp"]; [[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]) { while(![[outputController buffer] isEmpty]) {
[writeSemaphore signal]; [writeSemaphore signal];
[readSemaphore signal]; [readSemaphore signal];