Cog Audio: Properly support seeking within the file that appears to be playing, even if it has already finished decoding
parent
083dbbf18b
commit
5aa3f7dd0a
|
@ -39,6 +39,8 @@
|
||||||
|
|
||||||
atomic_bool resettingNow;
|
atomic_bool resettingNow;
|
||||||
atomic_int refCount;
|
atomic_int refCount;
|
||||||
|
|
||||||
|
int currentPlaybackStatus;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id)init;
|
- (id)init;
|
||||||
|
|
|
@ -158,11 +158,31 @@
|
||||||
|
|
||||||
- (void)seekToTime:(double)time
|
- (void)seekToTime:(double)time
|
||||||
{
|
{
|
||||||
//Need to reset everything's buffers, and then seek?
|
if (endOfInputReached)
|
||||||
/*HACK TO TEST HOW WELL THIS WOULD WORK*/
|
{
|
||||||
[output seek:time];
|
// This is a dirty hack in case the playback has finished with the track
|
||||||
[bufferChain seek:time];
|
// that the user thinks they're seeking into
|
||||||
/*END HACK*/
|
CogStatus status = (CogStatus) currentPlaybackStatus;
|
||||||
|
NSURL *url;
|
||||||
|
id userInfo;
|
||||||
|
NSDictionary *rgi;
|
||||||
|
|
||||||
|
@synchronized (chainQueue) {
|
||||||
|
url = [bufferChain streamURL];
|
||||||
|
userInfo = [bufferChain userInfo];
|
||||||
|
rgi = [bufferChain rgInfo];
|
||||||
|
}
|
||||||
|
|
||||||
|
[self stop];
|
||||||
|
|
||||||
|
[self play:url withUserInfo:userInfo withRGInfo:rgi startPaused:(status == CogStatusPaused) andSeekTo:time];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Still decoding the current file, safe to seek within it
|
||||||
|
[output seek:time];
|
||||||
|
[bufferChain seek:time];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)setVolume:(double)v
|
- (void)setVolume:(double)v
|
||||||
|
@ -446,7 +466,9 @@
|
||||||
|
|
||||||
|
|
||||||
- (void)setPlaybackStatus:(int)status waitUntilDone:(BOOL)wait
|
- (void)setPlaybackStatus:(int)status waitUntilDone:(BOOL)wait
|
||||||
{
|
{
|
||||||
|
currentPlaybackStatus = status;
|
||||||
|
|
||||||
[self sendDelegateMethod:@selector(audioPlayer:didChangeStatus:userInfo:) withObject:[NSNumber numberWithInt:status] withObject:[bufferChain userInfo] waitUntilDone:wait];
|
[self sendDelegateMethod:@selector(audioPlayer:didChangeStatus:userInfo:) withObject:[NSNumber numberWithInt:status] withObject:[bufferChain userInfo] waitUntilDone:wait];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue