From 21c948212bec1ad16a44b99062d08da34eb2650b Mon Sep 17 00:00:00 2001 From: Chris Moeller Date: Tue, 3 May 2016 00:58:05 -0700 Subject: [PATCH] Migrate FFMPEG plug-in to use ARC. --- Plugins/FFMPEG/FFMPEG.xcodeproj/project.pbxproj | 2 ++ Plugins/FFMPEG/FFMPEGFileProtocols.m | 14 +++++++++----- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Plugins/FFMPEG/FFMPEG.xcodeproj/project.pbxproj b/Plugins/FFMPEG/FFMPEG.xcodeproj/project.pbxproj index ecdee3035..0b5aad40b 100644 --- a/Plugins/FFMPEG/FFMPEG.xcodeproj/project.pbxproj +++ b/Plugins/FFMPEG/FFMPEG.xcodeproj/project.pbxproj @@ -312,6 +312,7 @@ 1DEB913F08733D840010E9CD /* Debug */ = { isa = XCBuildConfiguration; buildSettings = { + CLANG_ENABLE_OBJC_ARC = YES; GCC_PREPROCESSOR_DEFINITIONS = "DEBUG=1"; GCC_WARN_ABOUT_RETURN_TYPE = YES; GCC_WARN_UNUSED_VARIABLE = YES; @@ -325,6 +326,7 @@ 1DEB914008733D840010E9CD /* Release */ = { isa = XCBuildConfiguration; buildSettings = { + CLANG_ENABLE_OBJC_ARC = YES; CODE_SIGN_IDENTITY = "Developer ID Application"; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; GCC_WARN_ABOUT_RETURN_TYPE = YES; diff --git a/Plugins/FFMPEG/FFMPEGFileProtocols.m b/Plugins/FFMPEG/FFMPEGFileProtocols.m index 396844c4c..cbb0930f1 100644 --- a/Plugins/FFMPEG/FFMPEGFileProtocols.m +++ b/Plugins/FFMPEG/FFMPEGFileProtocols.m @@ -18,7 +18,7 @@ typedef struct FileContext { const AVClass *class; - id fd; + void *fd; } FileContext; static const AVOption file_options[] = { @@ -59,7 +59,9 @@ static const AVClass unpack_class = { static int file_read(URLContext *h, unsigned char *buf, int size) { FileContext *c = h->priv_data; - return [c->fd read:buf amount:size]; + NSObject* _fd = (__bridge NSObject *)(c->fd); + id __unsafe_unretained fd = (id) _fd; + return [fd read:buf amount:size]; } static int file_check(URLContext *h, int mask) @@ -85,7 +87,7 @@ static int file_open(URLContext *h, const char *filename, int flags) if (![fd open:url]) return -1; - c->fd = [fd retain]; + c->fd = (void*)CFBridgingRetain(fd); return 0; } @@ -101,7 +103,9 @@ static int http_open(URLContext *h, const char *filename, int flags) static int64_t file_seek(URLContext *h, int64_t pos, int whence) { FileContext *c = h->priv_data; - return [c->fd seek:pos whence:whence] ? [c->fd tell] : -1; + NSObject* _fd = (__bridge NSObject *)(c->fd); + id __unsafe_unretained fd = (id) _fd; + return [fd seek:pos whence:whence] ? [fd tell] : -1; } static int64_t http_seek(URLContext *h, int64_t pos, int whence) @@ -112,7 +116,7 @@ static int64_t http_seek(URLContext *h, int64_t pos, int whence) static int file_close(URLContext *h) { FileContext *c = h->priv_data; - [c->fd release]; + CFBridgingRelease(c->fd); return 0; }