From 1d4620edcee4ae9641fd8a1e73fb5baab4b93735 Mon Sep 17 00:00:00 2001 From: Max Gu Date: Wed, 20 Jul 2016 18:40:49 -0700 Subject: [PATCH] Adding documentation for assetURL in ASVideoNode, and adding a mutex lock for assetURL setter (#1961) * Adding comment in ASVideoNode.h for the assetURL property * Adding a mutexlock in setAssetURL in ASVideoNode --- AsyncDisplayKit/ASVideoNode.h | 5 +++++ AsyncDisplayKit/ASVideoNode.mm | 2 ++ 2 files changed, 7 insertions(+) diff --git a/AsyncDisplayKit/ASVideoNode.h b/AsyncDisplayKit/ASVideoNode.h index 178ceff5c7..e525d1a2dc 100644 --- a/AsyncDisplayKit/ASVideoNode.h +++ b/AsyncDisplayKit/ASVideoNode.h @@ -41,6 +41,11 @@ NS_ASSUME_NONNULL_BEGIN - (BOOL)isPlaying; @property (nullable, nonatomic, strong, readwrite) AVAsset *asset; +/** + ** @abstract The URL with which the asset was initialized. + ** @discussion Setting the URL will overwrite the current asset with a newly created AVURLAsset created from the given URL, and AVAsset *asset will point to that newly created AVURLAsset. Please don't set both assetURL and asset. + ** @return Current URL the asset was initialized or nil if no URL was given. + **/ @property (nullable, nonatomic, strong, readwrite) NSURL *assetURL; @property (nullable, nonatomic, strong, readwrite) AVVideoComposition *videoComposition; @property (nullable, nonatomic, strong, readwrite) AVAudioMix *audioMix; diff --git a/AsyncDisplayKit/ASVideoNode.mm b/AsyncDisplayKit/ASVideoNode.mm index 8771e703d9..5f679f5cc1 100644 --- a/AsyncDisplayKit/ASVideoNode.mm +++ b/AsyncDisplayKit/ASVideoNode.mm @@ -442,6 +442,8 @@ static NSString * const kStatus = @"status"; - (void)setAssetURL:(NSURL *)assetURL { + ASDN::MutexLocker l(__instanceLock__); + if (!ASObjectIsEqual(assetURL, self.assetURL)) { self.asset = [AVURLAsset assetWithURL:assetURL]; }