Skip to content

Commit

Permalink
fixed iOS 6.0 deprecation warning on dispatch_get_current_queue()
Browse files Browse the repository at this point in the history
  • Loading branch information
Hovig Devejian authored and Hovig Devejian committed Mar 14, 2013
1 parent 3a6e5d4 commit e1f1afa
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
1 change: 1 addition & 0 deletions framework/Source/GPUImageOpenGLESContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ typedef enum { kGPUImageNoRotation, kGPUImageRotateLeft, kGPUImageRotateRight, k
@property(readonly, nonatomic) dispatch_queue_t contextQueue;
@property(readwrite, retain, nonatomic) GLProgram *currentShaderProgram;

+ (void *)contextKey;
+ (GPUImageOpenGLESContext *)sharedImageProcessingOpenGLESContext;
+ (dispatch_queue_t)sharedOpenGLESQueue;
+ (void)useImageProcessingContext;
Expand Down
10 changes: 9 additions & 1 deletion framework/Source/GPUImageOpenGLESContext.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,27 @@ @implementation GPUImageOpenGLESContext
@synthesize currentShaderProgram = _currentShaderProgram;
@synthesize contextQueue = _contextQueue;

static void *openGLESContextQueueKey;

- (id)init;
{
if (!(self = [super init]))
{
return nil;
}


openGLESContextQueueKey = &openGLESContextQueueKey;
_contextQueue = dispatch_queue_create("com.sunsetlakesoftware.GPUImage.openGLESContextQueue", NULL);
dispatch_queue_set_specific(_contextQueue, openGLESContextQueueKey, (__bridge void *)self, NULL);
shaderProgramCache = [[NSMutableDictionary alloc] init];

return self;
}

+ (void *)contextKey {
return openGLESContextQueueKey;
}

// Based on Colin Wheeler's example here: http://cocoasamurai.blogspot.com/2011/04/singletons-your-doing-them-wrong.html
+ (GPUImageOpenGLESContext *)sharedImageProcessingOpenGLESContext;
{
Expand Down
10 changes: 4 additions & 6 deletions framework/Source/GPUImageOutput.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@ void runSynchronouslyOnVideoProcessingQueue(void (^block)(void))
{
dispatch_queue_t videoProcessingQueue = [GPUImageOpenGLESContext sharedOpenGLESQueue];

if (dispatch_get_current_queue() == videoProcessingQueue)
if(dispatch_get_specific([GPUImageOpenGLESContext contextKey]))
{
block();
}
else
}else
{
dispatch_sync(videoProcessingQueue, block);
}
Expand All @@ -33,11 +32,10 @@ void runAsynchronouslyOnVideoProcessingQueue(void (^block)(void))
{
dispatch_queue_t videoProcessingQueue = [GPUImageOpenGLESContext sharedOpenGLESQueue];

if (dispatch_get_current_queue() == videoProcessingQueue)
if(dispatch_get_specific([GPUImageOpenGLESContext contextKey]))
{
block();
}
else
}else
{
dispatch_async(videoProcessingQueue, block);
}
Expand Down

0 comments on commit e1f1afa

Please sign in to comment.