summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMuller, Alexander (A.) <amulle19@ford.com>2016-12-09 12:08:06 -0800
committerMuller, Alexander (A.) <amulle19@ford.com>2016-12-09 12:08:06 -0800
commitb066606e8a06957ee6f1607b02e7035d2cc285d2 (patch)
treeb37b52d86cdfebacbff782aa3f6b3268a5f618f7
parent9700f3c3c361c597771537a008aa73bacae1fea5 (diff)
downloadsdl_ios-b066606e8a06957ee6f1607b02e7035d2cc285d2.tar.gz
Adding in nil checks for completion handlers of Streaming Media Manager.
-rw-r--r--SmartDeviceLink/SDLStreamingMediaManager.m44
1 files changed, 30 insertions, 14 deletions
diff --git a/SmartDeviceLink/SDLStreamingMediaManager.m b/SmartDeviceLink/SDLStreamingMediaManager.m
index ee64109c3..aea83d2be 100644
--- a/SmartDeviceLink/SDLStreamingMediaManager.m
+++ b/SmartDeviceLink/SDLStreamingMediaManager.m
@@ -145,8 +145,10 @@ NS_ASSUME_NONNULL_BEGIN
typeof(weakSelf) strongSelf = weakSelf;
// If success, we will get an ACK or NACK, so those methods will handle calling the video block
if (!success) {
- strongSelf.videoStartBlock(NO, NO, error);
- strongSelf.videoStartBlock = nil;
+ if (strongSelf.videoStartBlock != nil) {
+ strongSelf.videoStartBlock(NO, NO, error);
+ strongSelf.videoStartBlock = nil;
+ }
}
}];
} else {
@@ -180,8 +182,10 @@ NS_ASSUME_NONNULL_BEGIN
typeof(weakSelf) strongSelf = weakSelf;
// If this passes, we will get an ACK or NACK, so those methods will handle calling the audio block
if (!success) {
- strongSelf.audioStartBlock(NO, NO, error);
- strongSelf.audioStartBlock = nil;
+ if (strongSelf.audioStartBlock != nil) {
+ strongSelf.audioStartBlock(NO, NO, error);
+ strongSelf.audioStartBlock = nil;
+ }
}
}];
} else {
@@ -277,8 +281,10 @@ NS_ASSUME_NONNULL_BEGIN
case SDLServiceType_Audio: {
self.audioSessionConnected = YES;
self.audioSessionEncrypted = header.encrypted;
- self.audioStartBlock(YES, header.encrypted, nil);
- self.audioStartBlock = nil;
+ if (self.audioStartBlock != nil) {
+ self.audioStartBlock(YES, header.encrypted, nil);
+ self.audioStartBlock = nil;
+ }
} break;
case SDLServiceType_Video: {
NSError *error = nil;
@@ -287,16 +293,22 @@ NS_ASSUME_NONNULL_BEGIN
if (!success) {
[self sdl_teardownCompressionSession];
[self.protocol endServiceWithType:SDLServiceType_Video];
- self.videoStartBlock(NO, header.encrypted, error);
- self.videoStartBlock = nil;
+
+ if (self.videoStartBlock != nil) {
+ self.videoStartBlock(NO, header.encrypted, error);
+ self.videoStartBlock = nil;
+ }
return;
}
self.videoSessionConnected = YES;
self.videoSessionEncrypted = header.encrypted;
- self.videoStartBlock(YES, header.encrypted, nil);
- self.videoStartBlock = nil;
+
+ if (self.videoStartBlock != nil) {
+ self.videoStartBlock(YES, header.encrypted, nil);
+ self.videoStartBlock = nil;
+ }
} break;
default: break;
}
@@ -307,14 +319,18 @@ NS_ASSUME_NONNULL_BEGIN
case SDLServiceType_Audio: {
NSError *error = [NSError errorWithDomain:SDLErrorDomainStreamingMediaAudio code:SDLStreamingAudioErrorHeadUnitNACK userInfo:nil];
- self.audioStartBlock(NO, NO, error);
- self.audioStartBlock = nil;
+ if (self.audioStartBlock != nil) {
+ self.audioStartBlock(NO, NO, error);
+ self.audioStartBlock = nil;
+ }
} break;
case SDLServiceType_Video: {
NSError *error = [NSError errorWithDomain:SDLErrorDomainStreamingMediaVideo code:SDLStreamingVideoErrorHeadUnitNACK userInfo:nil];
- self.videoStartBlock(NO, NO, error);
- self.videoStartBlock = nil;
+ if (self.videoStartBlock != nil) {
+ self.videoStartBlock(NO, NO, error);
+ self.videoStartBlock = nil;
+ }
} break;
default: break;
}