diff --git a/Audio/Chain/InputNode.m b/Audio/Chain/InputNode.m index a36b532b9..02c7cf5aa 100644 --- a/Audio/Chain/InputNode.m +++ b/Audio/Chain/InputNode.m @@ -117,6 +117,7 @@ void *inputBuffer = malloc(CHUNK_SIZE); BOOL shouldClose = YES; + BOOL seekError = NO; while ([self shouldContinue] == YES && [self endOfStream] == NO) { @@ -126,7 +127,7 @@ BOOL isPaused = [output isPaused]; if ( !isPaused ) [output pause]; DLog(@"SEEKING!"); - [decoder seek:seekFrame]; + seekError = [decoder seek:seekFrame] < 0; if ( !isPaused ) [output resume]; shouldSeek = NO; DLog(@"Seeked! Resetting Buffer"); @@ -141,7 +142,7 @@ int framesToRead = (CHUNK_SIZE - amountInBuffer)/bytesPerFrame; int framesRead = [decoder readAudio:((char *)inputBuffer) + amountInBuffer frames:framesToRead]; - if (framesRead > 0) + if (framesRead > 0 && !seekError) { amountInBuffer += (framesRead * bytesPerFrame); [self writeData:inputBuffer amount:amountInBuffer]; diff --git a/Plugins/Flac/FlacDecoder.m b/Plugins/Flac/FlacDecoder.m index ffce7ba4f..66a816953 100644 --- a/Plugins/Flac/FlacDecoder.m +++ b/Plugins/Flac/FlacDecoder.m @@ -262,7 +262,8 @@ void ErrorCallback(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorS - (long)seek:(long)sample { - FLAC__stream_decoder_seek_absolute(decoder, sample); + if (!FLAC__stream_decoder_seek_absolute(decoder, sample)) + return -1; return sample; }