Skip to content

Commit

Permalink
Merge pull request tumtumtum#384 from derpoliuk/fix-seek-progress
Browse files Browse the repository at this point in the history
Fix wrong -[STKAudioPlayer progress] after seek
  • Loading branch information
derpoliuk committed Jan 17, 2018
2 parents 8599763 + b189ca6 commit 230ed02
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions StreamingKit/StreamingKit/STKAudioPlayer.m
Original file line number Diff line number Diff line change
Expand Up @@ -1497,15 +1497,15 @@ -(void) processSeekToTime

error = AudioFileStreamSeek(audioFileStream, seekPacket, &packetAlignedByteOffset, &ioFlags);

if (!error && !(ioFlags & kAudioFileStreamSeekFlag_OffsetIsEstimated))
{
double delta = ((seekByteOffset - (SInt64)currentEntry->audioDataOffset) - packetAlignedByteOffset) / calculatedBitRate * 8;

OSSpinLockLock(&currentEntry->spinLock);
currentEntry->seekTime -= delta;
OSSpinLockUnlock(&currentEntry->spinLock);

if (!error) {
seekByteOffset = packetAlignedByteOffset + currentEntry->audioDataOffset;
if (!(ioFlags & kAudioFileStreamSeekFlag_OffsetIsEstimated)) {
double delta = ((seekByteOffset - (SInt64)currentEntry->audioDataOffset) - packetAlignedByteOffset) / calculatedBitRate * 8;

OSSpinLockLock(&currentEntry->spinLock);
currentEntry->seekTime -= delta;
OSSpinLockUnlock(&currentEntry->spinLock);
}
}
}

Expand Down

0 comments on commit 230ed02

Please sign in to comment.