Audio Player: Add new method of signaling stop
This new method should cause all stops to default to immediate stoppage, and only stops that occur after an end of track signal should indicate to play out the entire buffer. Signed-off-by: Christopher Snowhill <kode54@gmail.com>main
parent
4f942ac890
commit
447a60afd9
|
@ -315,6 +315,8 @@
|
||||||
// if there's already one at the head of chainQueue... r-r-right?
|
// if there's already one at the head of chainQueue... r-r-right?
|
||||||
for(BufferChain *chain in chainQueue) {
|
for(BufferChain *chain in chainQueue) {
|
||||||
if([chain isRunning]) {
|
if([chain isRunning]) {
|
||||||
|
if(output)
|
||||||
|
[output setShouldPlayOutBuffer:YES];
|
||||||
atomic_fetch_sub(&refCount, 1);
|
atomic_fetch_sub(&refCount, 1);
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
@ -338,6 +340,8 @@
|
||||||
while(duration >= 30.0 && shouldContinue) {
|
while(duration >= 30.0 && shouldContinue) {
|
||||||
[semaphore wait];
|
[semaphore wait];
|
||||||
if(atomic_load_explicit(&resettingNow, memory_order_relaxed)) {
|
if(atomic_load_explicit(&resettingNow, memory_order_relaxed)) {
|
||||||
|
if(output)
|
||||||
|
[output setShouldPlayOutBuffer:YES];
|
||||||
atomic_fetch_sub(&refCount, 1);
|
atomic_fetch_sub(&refCount, 1);
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
@ -357,6 +361,8 @@
|
||||||
[self requestNextStream:nextStreamUserInfo];
|
[self requestNextStream:nextStreamUserInfo];
|
||||||
|
|
||||||
if(!nextStream) {
|
if(!nextStream) {
|
||||||
|
if(output)
|
||||||
|
[output setShouldPlayOutBuffer:YES];
|
||||||
atomic_fetch_sub(&refCount, 1);
|
atomic_fetch_sub(&refCount, 1);
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
@ -407,6 +413,8 @@
|
||||||
while(shouldContinue && ![newChain open:url withUserInfo:nextStreamUserInfo withRGInfo:nextStreamRGInfo]) {
|
while(shouldContinue && ![newChain open:url withUserInfo:nextStreamUserInfo withRGInfo:nextStreamRGInfo]) {
|
||||||
if(nextStream == nil) {
|
if(nextStream == nil) {
|
||||||
newChain = nil;
|
newChain = nil;
|
||||||
|
if(output)
|
||||||
|
[output setShouldPlayOutBuffer:YES];
|
||||||
atomic_fetch_sub(&refCount, 1);
|
atomic_fetch_sub(&refCount, 1);
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
@ -416,6 +424,8 @@
|
||||||
|
|
||||||
if([nextStream isEqualTo:url]) {
|
if([nextStream isEqualTo:url]) {
|
||||||
newChain = nil;
|
newChain = nil;
|
||||||
|
if(output)
|
||||||
|
[output setShouldPlayOutBuffer:YES];
|
||||||
atomic_fetch_sub(&refCount, 1);
|
atomic_fetch_sub(&refCount, 1);
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
@ -442,6 +452,9 @@
|
||||||
// - self.nextStreamUserInfo == next playlist entry
|
// - self.nextStreamUserInfo == next playlist entry
|
||||||
// - head of chainQueue is the buffer chain for the next entry (which has launched its threads already)
|
// - head of chainQueue is the buffer chain for the next entry (which has launched its threads already)
|
||||||
|
|
||||||
|
if(output)
|
||||||
|
[output setShouldPlayOutBuffer:YES];
|
||||||
|
|
||||||
atomic_fetch_sub(&refCount, 1);
|
atomic_fetch_sub(&refCount, 1);
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,6 +63,8 @@
|
||||||
|
|
||||||
- (void)setShouldContinue:(BOOL)s;
|
- (void)setShouldContinue:(BOOL)s;
|
||||||
|
|
||||||
|
- (void)setShouldPlayOutBuffer:(BOOL)s;
|
||||||
|
|
||||||
- (void)pause;
|
- (void)pause;
|
||||||
- (void)resume;
|
- (void)resume;
|
||||||
|
|
||||||
|
|
|
@ -170,6 +170,10 @@
|
||||||
// [output stop];
|
// [output stop];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)setShouldPlayOutBuffer:(BOOL)s {
|
||||||
|
[output setShouldPlayOutBuffer:s];
|
||||||
|
}
|
||||||
|
|
||||||
- (BOOL)isPaused {
|
- (BOOL)isPaused {
|
||||||
return paused;
|
return paused;
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,6 +116,8 @@ using std::atomic_long;
|
||||||
FSurroundFilter *fsurround;
|
FSurroundFilter *fsurround;
|
||||||
|
|
||||||
BOOL resetStreamFormat;
|
BOOL resetStreamFormat;
|
||||||
|
|
||||||
|
BOOL shouldPlayOutBuffer;
|
||||||
|
|
||||||
float *samplePtr;
|
float *samplePtr;
|
||||||
float tempBuffer[512 * 32];
|
float tempBuffer[512 * 32];
|
||||||
|
@ -149,6 +151,8 @@ using std::atomic_long;
|
||||||
|
|
||||||
- (void)setEqualizerEnabled:(BOOL)enabled;
|
- (void)setEqualizerEnabled:(BOOL)enabled;
|
||||||
|
|
||||||
|
- (void)setShouldPlayOutBuffer:(BOOL)enabled;
|
||||||
|
|
||||||
- (void)sustainHDCD;
|
- (void)sustainHDCD;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -342,6 +342,7 @@ current_device_listener(AudioObjectID inObjectID, UInt32 inNumberAddresses, cons
|
||||||
- (void)threadEntry:(id)arg {
|
- (void)threadEntry:(id)arg {
|
||||||
running = YES;
|
running = YES;
|
||||||
started = NO;
|
started = NO;
|
||||||
|
shouldPlayOutBuffer = NO;
|
||||||
secondsLatency = 1.0;
|
secondsLatency = 1.0;
|
||||||
|
|
||||||
while(!stopping) {
|
while(!stopping) {
|
||||||
|
@ -940,6 +941,7 @@ current_device_listener(AudioObjectID inObjectID, UInt32 inNumberAddresses, cons
|
||||||
stopInvoked = NO;
|
stopInvoked = NO;
|
||||||
stopCompleted = NO;
|
stopCompleted = NO;
|
||||||
commandStop = NO;
|
commandStop = NO;
|
||||||
|
shouldPlayOutBuffer = NO;
|
||||||
|
|
||||||
audioFormatDescription = NULL;
|
audioFormatDescription = NULL;
|
||||||
|
|
||||||
|
@ -1208,7 +1210,7 @@ current_device_listener(AudioObjectID inObjectID, UInt32 inNumberAddresses, cons
|
||||||
}
|
}
|
||||||
if(renderSynchronizer || audioRenderer) {
|
if(renderSynchronizer || audioRenderer) {
|
||||||
if(renderSynchronizer) {
|
if(renderSynchronizer) {
|
||||||
if(!commandStop) {
|
if(shouldPlayOutBuffer && !commandStop) {
|
||||||
int compareVal = 0;
|
int compareVal = 0;
|
||||||
double secondsLatency = self->secondsLatency >= 0 ? self->secondsLatency : 0;
|
double secondsLatency = self->secondsLatency >= 0 ? self->secondsLatency : 0;
|
||||||
int compareMax = (((1000000 / 5000) * secondsLatency) + (10000 / 5000)); // latency plus 10ms, divide by sleep intervals
|
int compareMax = (((1000000 / 5000) * secondsLatency) + (10000 / 5000)); // latency plus 10ms, divide by sleep intervals
|
||||||
|
@ -1302,4 +1304,8 @@ current_device_listener(AudioObjectID inObjectID, UInt32 inNumberAddresses, cons
|
||||||
secondsHdcdSustained = 10.0;
|
secondsHdcdSustained = 10.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)setShouldPlayOutBuffer:(BOOL)s {
|
||||||
|
shouldPlayOutBuffer = s;
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
Loading…
Reference in New Issue