Migrate FFMPEG plug-in to use ARC.

CQTexperiment
Chris Moeller 2016-05-03 00:58:05 -07:00
parent 3c229f2017
commit 21c948212b
2 changed files with 11 additions and 5 deletions

View File

@ -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;

View File

@ -18,7 +18,7 @@
typedef struct FileContext {
const AVClass *class;
id<CogSource> 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<CogSource> __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<CogSource> __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;
}