Provide a mechanism to hint for correct duration.

For cases where duration can't be calculated accurately
This commit is contained in:
Daniel Cohen Gindi 2014-12-14 10:16:45 +02:00
parent 477b1f175f
commit 50a8b610c4
3 changed files with 5 additions and 0 deletions

1
StreamingKit/StreamingKit/STKDataSource.h Normal file → Executable file
View File

@ -48,6 +48,7 @@
@property (readonly) SInt64 position;
@property (readonly) SInt64 length;
@property (readonly) BOOL hasBytesAvailable;
@property (nonatomic, readwrite, assign) double durationHint;
@property (readwrite, unsafe_unretained) id<STKDataSourceDelegate> delegate;
-(BOOL) registerForEvents:(NSRunLoop*)runLoop;

1
StreamingKit/StreamingKit/STKQueueEntry.h Normal file → Executable file
View File

@ -28,6 +28,7 @@
volatile int processedPacketsCount;
volatile int processedPacketsSizeTotal;
AudioStreamBasicDescription audioStreamBasicDescription;
double durationHint;
}
@property (readonly) UInt64 audioDataLengthInBytes;

3
StreamingKit/StreamingKit/STKQueueEntry.m Normal file → Executable file
View File

@ -23,6 +23,7 @@
self.dataSource = dataSourceIn;
self.queueItemId = queueItemIdIn;
self->lastFrameQueued = -1;
self->durationHint = dataSourceIn.durationHint;
}
return self;
@ -60,6 +61,8 @@
-(double) duration
{
if (durationHint > 0.0) return durationHint;
if (self->sampleRate <= 0)
{
return 0;