setDataSource now immediately stops whatever is currently playing. STKAutoRecoveringHTTPDataSource watchdog timer improvements

This commit is contained in:
Thong Nguyen 2014-02-13 22:02:48 +00:00
parent a15c2c27ff
commit 1243dbf0e1
3 changed files with 15 additions and 2 deletions

View File

@ -62,6 +62,7 @@ typedef enum
STKAudioPlayerStopReasonNone = 0,
STKAudioPlayerStopReasonEof,
STKAudioPlayerStopReasonUserAction,
STKAudioPlayerStopReasonPendingNext,
STKAudioPlayerStopReasonError = 0xffff
}
STKAudioPlayerStopReason;

View File

@ -679,6 +679,8 @@ static void AudioFileStreamPacketsProc(void* clientData, UInt32 numberBytes, UIn
[upcomingQueue enqueue:[[STKQueueEntry alloc] initWithDataSource:dataSourceIn andQueueItemId:queueItemId]];
[self stopAudioUnitWithReason:STKAudioPlayerStopReasonPendingNext];
self.internalState = STKAudioPlayerInternalStatePendingNext;
}
pthread_mutex_unlock(&playerMutex);
@ -1061,6 +1063,7 @@ static void AudioFileStreamPacketsProc(void* clientData, UInt32 numberBytes, UIn
OSSpinLockUnlock(&currentEntryReferencesLock);
currentlyReadingEntry.dataSource.delegate = self;
[currentlyReadingEntry.dataSource close];
[currentlyReadingEntry.dataSource registerForEvents:[NSRunLoop currentRunLoop]];
[currentlyReadingEntry.dataSource seekToOffset:0];

View File

@ -43,8 +43,8 @@
#import <SystemConfiguration/SystemConfiguration.h>
#import "STKAutoRecoveringHTTPDataSource.h"
#define DEFAULT_WATCHDOG_PERIOD_SECONDS (5)
#define DEFAULT_INACTIVE_PERIOD_BEFORE_RECONNECT_SECONDS (5)
#define DEFAULT_WATCHDOG_PERIOD_SECONDS (8)
#define DEFAULT_INACTIVE_PERIOD_BEFORE_RECONNECT_SECONDS (15)
static uint64_t GetTickCount(void)
{
@ -165,6 +165,8 @@ static void PopulateOptionsWithDefault(STKAutoRecoveringHTTPDataSourceOptions* o
timeoutTimer = nil;
}
ticksWhenLastDataReceived = GetTickCount();
[self createTimeoutTimer];
return YES;
@ -244,6 +246,13 @@ static void PopulateOptionsWithDefault(STKAutoRecoveringHTTPDataSourceOptions* o
return NO;
}
-(void) seekToOffset:(long long)offset
{
ticksWhenLastDataReceived = GetTickCount();
[super seekToOffset:offset];
}
-(void) close
{
[self destroyTimeoutTimer];