Restart playback on device or output format change
Now the output is restarted on the current file at the current position if the output format has changed. This should resolve the issue finally. Signed-off-by: Christopher Snowhill <kode54@gmail.com>CQTexperiment
parent
728c44242c
commit
f4f4f80f64
|
@ -756,6 +756,12 @@ NSDictionary *makeRGInfo(PlaylistEntry *pe) {
|
||||||
[miniWindow showHDCDLogo:YES];
|
[miniWindow showHDCDLogo:YES];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)audioPlayer:(AudioPlayer *)player restartPlaybackAtCurrentPosition:(id)userInfo {
|
||||||
|
PlaylistEntry *pe = [playlistController currentEntry];
|
||||||
|
BOOL paused = playbackStatus == CogStatusPaused;
|
||||||
|
[player play:[pe URL] withUserInfo:pe withRGInfo:makeRGInfo(pe) startPaused:paused andSeekTo:[pe currentPosition]];
|
||||||
|
}
|
||||||
|
|
||||||
- (void)removeHDCD:(id)sender {
|
- (void)removeHDCD:(id)sender {
|
||||||
MainWindow *mainWindow = (MainWindow *)appController.mainWindow;
|
MainWindow *mainWindow = (MainWindow *)appController.mainWindow;
|
||||||
[mainWindow showHDCDLogo:NO];
|
[mainWindow showHDCDLogo:NO];
|
||||||
|
|
|
@ -76,6 +76,8 @@
|
||||||
- (void)setNextStream:(NSURL *)url withUserInfo:(id)userInfo withRGInfo:(NSDictionary *)rgi;
|
- (void)setNextStream:(NSURL *)url withUserInfo:(id)userInfo withRGInfo:(NSDictionary *)rgi;
|
||||||
- (void)resetNextStreams;
|
- (void)resetNextStreams;
|
||||||
|
|
||||||
|
- (void)restartPlaybackAtCurrentPosition;
|
||||||
|
|
||||||
+ (NSArray *)fileTypes;
|
+ (NSArray *)fileTypes;
|
||||||
+ (NSArray *)schemes;
|
+ (NSArray *)schemes;
|
||||||
+ (NSArray *)containerTypes;
|
+ (NSArray *)containerTypes;
|
||||||
|
@ -121,5 +123,5 @@
|
||||||
- (void)audioPlayer:(AudioPlayer *)player refreshEqualizer:(AudioUnit)eq;
|
- (void)audioPlayer:(AudioPlayer *)player refreshEqualizer:(AudioUnit)eq;
|
||||||
- (void)audioPlayer:(AudioPlayer *)player removeEqualizer:(AudioUnit)eq;
|
- (void)audioPlayer:(AudioPlayer *)player removeEqualizer:(AudioUnit)eq;
|
||||||
- (void)audioPlayer:(AudioPlayer *)player sustainHDCD:(id)userInfo;
|
- (void)audioPlayer:(AudioPlayer *)player sustainHDCD:(id)userInfo;
|
||||||
|
- (void)audioPlayer:(AudioPlayer *)player restartPlaybackAtCurrentPosition:(id)userInfo;
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -220,6 +220,10 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)restartPlaybackAtCurrentPosition {
|
||||||
|
[self sendDelegateMethod:@selector(audioPlayer:restartPlaybackAtCurrentPosition:) withObject:[bufferChain userInfo] waitUntilDone:NO];
|
||||||
|
}
|
||||||
|
|
||||||
- (void)setShouldContinue:(BOOL)s {
|
- (void)setShouldContinue:(BOOL)s {
|
||||||
shouldContinue = s;
|
shouldContinue = s;
|
||||||
|
|
||||||
|
|
|
@ -75,4 +75,6 @@
|
||||||
|
|
||||||
- (void)sustainHDCD;
|
- (void)sustainHDCD;
|
||||||
|
|
||||||
|
- (void)restartPlaybackAtCurrentPosition;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -260,4 +260,8 @@
|
||||||
[controller sustainHDCD];
|
[controller sustainHDCD];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)restartPlaybackAtCurrentPosition {
|
||||||
|
[controller restartPlaybackAtCurrentPosition];
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -63,4 +63,6 @@
|
||||||
|
|
||||||
- (void)sustainHDCD;
|
- (void)sustainHDCD;
|
||||||
|
|
||||||
|
- (void)restartPlaybackAtCurrentPosition;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -159,4 +159,8 @@
|
||||||
[output sustainHDCD];
|
[output sustainHDCD];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)restartPlaybackAtCurrentPosition {
|
||||||
|
[controller restartPlaybackAtCurrentPosition];
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
|
@ -41,6 +41,7 @@
|
||||||
BOOL started;
|
BOOL started;
|
||||||
BOOL paused;
|
BOOL paused;
|
||||||
BOOL stopNext;
|
BOOL stopNext;
|
||||||
|
BOOL restarted;
|
||||||
|
|
||||||
BOOL eqEnabled;
|
BOOL eqEnabled;
|
||||||
|
|
||||||
|
|
|
@ -167,6 +167,7 @@ static OSStatus renderCallback(void *inRefCon, AudioUnitRenderActionFlags *ioAct
|
||||||
running = NO;
|
running = NO;
|
||||||
started = NO;
|
started = NO;
|
||||||
stopNext = NO;
|
stopNext = NO;
|
||||||
|
restarted = NO;
|
||||||
|
|
||||||
streamFormatStarted = NO;
|
streamFormatStarted = NO;
|
||||||
|
|
||||||
|
@ -211,10 +212,16 @@ default_device_changed(AudioObjectID inObjectID, UInt32 inNumberAddresses, const
|
||||||
running = YES;
|
running = YES;
|
||||||
started = NO;
|
started = NO;
|
||||||
stopNext = NO;
|
stopNext = NO;
|
||||||
|
size_t eventCount = 0;
|
||||||
atomic_store(&bytesRendered, 0);
|
atomic_store(&bytesRendered, 0);
|
||||||
NSMutableArray *delayedEvents = [[NSMutableArray alloc] init];
|
NSMutableArray *delayedEvents = [[NSMutableArray alloc] init];
|
||||||
BOOL delayedEventsPopped = YES;
|
BOOL delayedEventsPopped = YES;
|
||||||
while(!stopping) {
|
while(!stopping) {
|
||||||
|
if(++eventCount == 48) {
|
||||||
|
[self resetIfOutputChanged];
|
||||||
|
if(restarted) break;
|
||||||
|
eventCount = 0;
|
||||||
|
}
|
||||||
if([outputController shouldReset]) {
|
if([outputController shouldReset]) {
|
||||||
@autoreleasepool {
|
@autoreleasepool {
|
||||||
[[outputController buffer] reset];
|
[[outputController buffer] reset];
|
||||||
|
@ -459,6 +466,15 @@ default_device_changed(AudioObjectID inObjectID, UInt32 inNumberAddresses, const
|
||||||
free(devids);
|
free(devids);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)resetIfOutputChanged {
|
||||||
|
AVAudioFormat *format = _au.outputBusses[0].format;
|
||||||
|
|
||||||
|
if(!restarted && !_deviceFormat || ![_deviceFormat isEqual:format]) {
|
||||||
|
[outputController restartPlaybackAtCurrentPosition];
|
||||||
|
restarted = YES;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
- (BOOL)updateDeviceFormat {
|
- (BOOL)updateDeviceFormat {
|
||||||
AVAudioFormat *format = _au.outputBusses[0].format;
|
AVAudioFormat *format = _au.outputBusses[0].format;
|
||||||
|
|
||||||
|
@ -560,6 +576,7 @@ default_device_changed(AudioObjectID inObjectID, UInt32 inNumberAddresses, const
|
||||||
paused = NO;
|
paused = NO;
|
||||||
stopNext = NO;
|
stopNext = NO;
|
||||||
outputDeviceID = -1;
|
outputDeviceID = -1;
|
||||||
|
restarted = NO;
|
||||||
|
|
||||||
downmixer = nil;
|
downmixer = nil;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue