Fixed progress is incorrect when file finishes playing half way through.

This commit is contained in:
Thong Nguyen 2012-10-10 13:25:06 +01:00
parent 8508bc20be
commit 1f3c8eca52
10 changed files with 29 additions and 11 deletions

View File

@ -2,7 +2,7 @@
AudioPlayer.m
Created by Thong Nguyen on 14/05/2012.
http://http://code.google.com/p/bluecucumber
https://github.com/tumtumtum/audjustable
Inspired by Matt Gallagher's AudioStreamer:
https://github.com/mattgallagher/AudioStreamer
@ -188,5 +188,6 @@ AudioQueueBufferRefLookupEntry;
-(void) stop;
-(void) flushStop;
-(void) dispose;
-(NSObject*) currentlyPlayingQueueItemId;
@end

View File

@ -2,7 +2,7 @@
AudioPlayer.m
Created by Thong Nguyen on 14/05/2012.
http://http://code.google.com/p/bluecucumber
https://github.com/tumtumtum/audjustable
Inspired by Matt Gallagher's AudioStreamer:
https://github.com/mattgallagher/AudioStreamer
@ -695,7 +695,10 @@ static void AudioQueueIsRunningCallbackProc(void* userData, AudioQueueRef audioQ
if (currentlyPlayingEntry)
{
currentlyPlayingEntry->bytesPlayed += bufferIn->mAudioDataByteSize;
if (!audioQueueFlushing)
{
currentlyPlayingEntry->bytesPlayed += bufferIn->mAudioDataByteSize;
}
}
int index = (int)bufferIn % audioQueueBufferRefLookupCount;
@ -1752,4 +1755,16 @@ static void AudioQueueIsRunningCallbackProc(void* userData, AudioQueueRef audioQ
[self stopThread];
}
-(NSObject*) currentlyPlayingQueueItemId
{
QueueEntry* entry = currentlyPlayingEntry;
if (entry == nil)
{
return nil;
}
return entry.queueItemId;
}
@end

View File

@ -2,7 +2,7 @@
AudioPlayer.m
Created by Thong Nguyen on 14/05/2012.
http://http://code.google.com/p/bluecucumber
https://github.com/tumtumtum/audjustable
Copyright (c) 2012 Thong Nguyen (tumtumtum@gmail.com). All rights reserved.

View File

@ -2,7 +2,7 @@
AudioPlayer.m
Created by Thong Nguyen on 14/05/2012.
http://http://code.google.com/p/bluecucumber
https://github.com/tumtumtum/audjustable
Copyright (c) 2012 Thong Nguyen (tumtumtum@gmail.com). All rights reserved.
@ -49,6 +49,8 @@ static void ReadStreamCallbackProc(CFReadStreamRef stream, CFStreamEventType eve
case kCFStreamEventHasBytesAvailable:
[datasource dataAvailable];
break;
default:
break;
}
}

View File

@ -2,7 +2,7 @@
AudioPlayer.m
Created by Thong Nguyen on 14/05/2012.
http://http://code.google.com/p/bluecucumber
https://github.com/tumtumtum/audjustable
Copyright (c) 2012 Thong Nguyen (tumtumtum@gmail.com). All rights reserved.

View File

@ -2,7 +2,7 @@
AudioPlayer.m
Created by Thong Nguyen on 14/05/2012.
http://http://code.google.com/p/bluecucumber
https://github.com/tumtumtum/audjustable
Copyright (c) 2012 Thong Nguyen (tumtumtum@gmail.com). All rights reserved.

View File

@ -2,7 +2,7 @@
AudioPlayer.m
Created by Thong Nguyen on 14/05/2012.
http://http://code.google.com/p/bluecucumber
https://github.com/tumtumtum/audjustable
Copyright (c) 2012 Thong Nguyen (tumtumtum@gmail.com). All rights reserved.

View File

@ -2,7 +2,7 @@
AudioPlayer.m
Created by Thong Nguyen on 14/05/2012.
http://http://code.google.com/p/bluecucumber
https://github.com/tumtumtum/audjustable
Copyright (c) 2012 Thong Nguyen (tumtumtum@gmail.com). All rights reserved.

View File

@ -2,7 +2,7 @@
AudioPlayer.m
Created by Thong Nguyen on 14/05/2012.
http://http://code.google.com/p/bluecucumber
https://github.com/tumtumtum/audjustable
Copyright (c) 2012 Thong Nguyen (tumtumtum@gmail.com). All rights reserved.

View File

@ -2,7 +2,7 @@
AudioPlayer.m
Created by Thong Nguyen on 14/05/2012.
http://http://code.google.com/p/bluecucumber
https://github.com/tumtumtum/audjustable
Copyright (c) 2012 Thong Nguyen (tumtumtum@gmail.com). All rights reserved.