CoreAudio input: Optimized file size reporting to cache the file size on open, so file input isn't seeking as much
parent
a1a0bd2db4
commit
5b73336cb0
|
@ -29,6 +29,7 @@
|
|||
@interface CoreAudioDecoder : NSObject <CogDecoder>
|
||||
{
|
||||
@public long _lastPosition;
|
||||
@public long _fileSize;
|
||||
id<CogSource> _audioSource;
|
||||
AudioFileID _audioFile;
|
||||
ExtAudioFileRef _in;
|
||||
|
|
|
@ -61,15 +61,7 @@ static SInt64 getSizeProc(void* clientData) {
|
|||
NSObject* _handle = (__bridge NSObject *)(clientData);
|
||||
CoreAudioDecoder * __unsafe_unretained pSelf = (id) _handle;
|
||||
|
||||
id<CogSource> source = pSelf->_audioSource;
|
||||
|
||||
SInt64 size;
|
||||
|
||||
[source seek:0 whence:SEEK_END];
|
||||
size = [source tell];
|
||||
[source seek:pSelf->_lastPosition whence:SEEK_SET];
|
||||
|
||||
return size;
|
||||
return pSelf->_fileSize;
|
||||
}
|
||||
|
||||
@implementation CoreAudioDecoder
|
||||
|
@ -114,6 +106,9 @@ static SInt64 getSizeProc(void* clientData) {
|
|||
|
||||
_audioSource = source;
|
||||
_lastPosition = [source tell];
|
||||
[source seek:0 whence:SEEK_END];
|
||||
_fileSize = [source tell];
|
||||
[source seek:_lastPosition whence:SEEK_SET];
|
||||
|
||||
err = AudioFileOpenWithCallbacks((__bridge void *)self, readProc, 0, getSizeProc, 0, 0, &_audioFile);
|
||||
if(noErr != err) {
|
||||
|
|
Loading…
Reference in New Issue