Changeset 40792ebd37f77c25079bcc0ae5ababc64703328b
- Timestamp:
- 08/06/07 11:24:23
(1 year ago)
- Author:
- Pierre d'Herbemont <pdherbemont@videolan.org>
- git-committer:
- Pierre d'Herbemont <pdherbemont@videolan.org> 1181294663 +0000
- git-parent:
[ddb469c7f7f290d06411f690fa04b4b920882e76]
- git-author:
- Pierre d'Herbemont <pdherbemont@videolan.org> 1181294663 +0000
- Message:
Mac OS X gui: Comply to "Cocoa Thread Safety" guideline, that is, make creating, resizing, closing, the NSView on main thread.
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r2a2b478 |
r40792eb |
|
| 758 | 758 | - (void)enterFullscreen |
|---|
| 759 | 759 | { |
|---|
| 760 | | [[o_view class] resetVout: p_vout]; |
|---|
| | 760 | [[o_view class] performSelectorOnMainThread:@selector(resetVout:) withObject:[NSValue valueWithPointer:p_vout] waitUntilDone:YES]; |
|---|
| 761 | 761 | [[[[VLCMain sharedInstance] getControls] getFSPanel] setActive: nil]; |
|---|
| 762 | 762 | } |
|---|
| … | … | |
| 764 | 764 | - (void)leaveFullscreen |
|---|
| 765 | 765 | { |
|---|
| 766 | | [[o_view class] resetVout: p_vout]; |
|---|
| | 766 | [[o_view class] performSelectorOnMainThread:@selector(resetVout:) withObject:[NSValue valueWithPointer:p_vout] waitUntilDone:YES]; |
|---|
| 767 | 767 | [[[[VLCMain sharedInstance] getControls] getFSPanel] setNonActive: nil]; |
|---|
| 768 | 768 | } |
|---|
| r9ba00f5 |
r40792eb |
|
| 172 | 172 | p_vout->p_sys->b_embedded = VLC_FALSE; |
|---|
| 173 | 173 | |
|---|
| 174 | | p_vout->p_sys->o_pool = [[NSAutoreleasePool alloc] init]; |
|---|
| 175 | | |
|---|
| 176 | | /* Create the GL view */ |
|---|
| 177 | | p_vout->p_sys->o_glview = [[VLCGLView alloc] initWithVout: p_vout]; |
|---|
| 178 | | [p_vout->p_sys->o_glview autorelease]; |
|---|
| 179 | | |
|---|
| 180 | | /* Spawn the window */ |
|---|
| 181 | | |
|---|
| 182 | | if( !(p_vout->p_sys->o_vout_view = [VLCVoutView getVoutView: p_vout |
|---|
| 183 | | subView: p_vout->p_sys->o_glview frame: nil]) ) |
|---|
| | 174 | [VLCGLView performSelectorOnMainThread:@selector(initVout:) withObject:[NSValue valueWithPointer:p_vout] waitUntilDone:YES]; |
|---|
| | 175 | |
|---|
| | 176 | /* Check to see if fillVoutWithNewView: was successfull */ |
|---|
| | 177 | |
|---|
| | 178 | if( !p_vout->p_sys->o_vout_view ) |
|---|
| 184 | 179 | { |
|---|
| 185 | 180 | return VLC_EGENERIC; |
|---|
| 186 | 181 | } |
|---|
| | 182 | |
|---|
| 187 | 183 | p_vout->pf_init = Init; |
|---|
| 188 | 184 | p_vout->pf_end = End; |
|---|
| … | … | |
| 210 | 206 | |
|---|
| 211 | 207 | /* Close the window */ |
|---|
| 212 | | [p_vout->p_sys->o_vout_view closeVout]; |
|---|
| | 208 | [p_vout->p_sys->o_vout_view performSelectorOnMainThread:@selector(closeVout) withObject:NULL waitUntilDone:YES]; |
|---|
| 213 | 209 | |
|---|
| 214 | 210 | [o_pool release]; |
|---|
| … | … | |
| 308 | 304 | *****************************************************************************/ |
|---|
| 309 | 305 | @implementation VLCGLView |
|---|
| | 306 | + (void)initVout:(NSValue *)arg |
|---|
| | 307 | { |
|---|
| | 308 | vout_thread_t * p_vout = [arg pointerValue]; |
|---|
| | 309 | |
|---|
| | 310 | /* Create the GL view */ |
|---|
| | 311 | p_vout->p_sys->o_glview = [[VLCGLView alloc] initWithVout: p_vout]; |
|---|
| | 312 | [p_vout->p_sys->o_glview autorelease]; |
|---|
| | 313 | |
|---|
| | 314 | /* Spawn the window */ |
|---|
| | 315 | p_vout->p_sys->o_vout_view = [VLCVoutView getVoutView: p_vout |
|---|
| | 316 | subView: p_vout->p_sys->o_glview frame: nil]; |
|---|
| | 317 | } |
|---|
| 310 | 318 | |
|---|
| 311 | 319 | /* This function will reset the o_vout_view. It's useful to go fullscreen. */ |
|---|
| 312 | | + (void)resetVout: (vout_thread_t *)p_vout |
|---|
| 313 | | { |
|---|
| | 320 | + (void)resetVout:(NSData *)arg |
|---|
| | 321 | { |
|---|
| | 322 | vout_thread_t * p_vout = [arg pointerValue]; |
|---|
| | 323 | |
|---|
| 314 | 324 | if( p_vout->b_fullscreen ) |
|---|
| 315 | 325 | { |
|---|
| … | … | |
| 345 | 355 | - (id) initWithVout: (vout_thread_t *) vout |
|---|
| 346 | 356 | { |
|---|
| | 357 | /* Must be called from main thread: |
|---|
| | 358 | * "The NSView class is generally thread-safe, with a few exceptions. You |
|---|
| | 359 | * should create, destroy, resize, move, and perform other operations on NSView |
|---|
| | 360 | * objects only from the main thread of an application. Drawing from secondary |
|---|
| | 361 | * threads is thread-safe as long as you bracket drawing calls with calls to |
|---|
| | 362 | * lockFocusIfCanDraw and unlockFocus." Cocoa Thread Safety */ |
|---|
| | 363 | |
|---|
| 347 | 364 | p_vout = vout; |
|---|
| 348 | 365 | |
|---|
| … | … | |
| 419 | 436 | ( bounds.size.height - y ) / 2, x, y ); |
|---|
| 420 | 437 | |
|---|
| | 438 | [super reshape]; |
|---|
| | 439 | |
|---|
| 421 | 440 | if( p_vout->p_sys->b_got_frame ) |
|---|
| 422 | 441 | { |
|---|
| … | … | |
| 435 | 454 | Unlock( p_vout ); |
|---|
| 436 | 455 | } |
|---|
| 437 | | [super reshape]; |
|---|
| 438 | 456 | } |
|---|
| 439 | 457 | |
|---|