Skip to content

Commit 1cedf53

Browse files
author
ap4y
committed
Using estimated duration for CoreAudio files to avoid full packets scans, on tested files it
gives the same result in most situations. fixes ap4y#26
1 parent f5cdd3e commit 1cedf53

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

OrigamiEngine/Plugins/CoreAudioDecoder.m

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -152,18 +152,6 @@ - (BOOL)readInfoFromExtAudioFileRef {
152152
return NO;
153153
}
154154

155-
SInt64 total;
156-
size = sizeof(total);
157-
err = ExtAudioFileGetProperty(_in,
158-
kExtAudioFileProperty_FileLengthFrames,
159-
&size,
160-
&total);
161-
if(err != noErr) {
162-
ExtAudioFileDispose(_in);
163-
return NO;
164-
}
165-
totalFrames = (long)total;
166-
167155
bitrate = 0;
168156
bitsPerSample = asbd.mBitsPerChannel;
169157
channels = asbd.mChannelsPerFrame;
@@ -205,6 +193,11 @@ - (BOOL)readInfoFromExtAudioFileRef {
205193
self.metadata = [self metadataForFile:audioFile];
206194
}
207195

196+
Float64 total = 0;
197+
size = sizeof(total);
198+
err = AudioFileGetProperty(audioFile, kAudioFilePropertyEstimatedDuration, &size, &total);
199+
if(err == noErr) totalFrames = total * frequency;
200+
208201
return YES;
209202
}
210203

0 commit comments

Comments
 (0)