Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(117)

Side by Side Diff: webrtc/modules/video_render/mac/video_render_nsopengl.mm

Issue 1476453002: Clean up PlatformThread. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: IsRunning DCHECK Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 _fullScreenWindow( nil), 371 _fullScreenWindow( nil),
372 _windowRect( ), 372 _windowRect( ),
373 _windowWidth( 0), 373 _windowWidth( 0),
374 _windowHeight( 0), 374 _windowHeight( 0),
375 _nsglChannels( ), 375 _nsglChannels( ),
376 _zOrderToChannel( ), 376 _zOrderToChannel( ),
377 _renderingIsPaused (FALSE), 377 _renderingIsPaused (FALSE),
378 _windowRefSuperView(NULL), 378 _windowRefSuperView(NULL),
379 _windowRefSuperViewFrame(NSMakeRect(0,0,0,0)) 379 _windowRefSuperViewFrame(NSMakeRect(0,0,0,0))
380 { 380 {
381 _screenUpdateThread = PlatformThread::CreateThread( 381 _screenUpdateThread.reset(new rtc::PlatformThread(
382 ScreenUpdateThreadProc, this, "ScreenUpdateNSOpenGL"); 382 ScreenUpdateThreadProc, this, "ScreenUpdateNSOpenGL"));
383 } 383 }
384 384
385 int VideoRenderNSOpenGL::ChangeWindow(CocoaRenderView* newWindowRef) 385 int VideoRenderNSOpenGL::ChangeWindow(CocoaRenderView* newWindowRef)
386 { 386 {
387 387
388 LockAGLCntx(); 388 LockAGLCntx();
389 389
390 _windowRef = newWindowRef; 390 _windowRef = newWindowRef;
391 391
392 if(CreateMixingContext() == -1) 392 if(CreateMixingContext() == -1)
(...skipping 27 matching lines...) Expand all
420 { 420 {
421 421
422 LockAGLCntx(); 422 LockAGLCntx();
423 423
424 const unsigned int MONITOR_FREQ = 60; 424 const unsigned int MONITOR_FREQ = 60;
425 if(TRUE == _renderingIsPaused) 425 if(TRUE == _renderingIsPaused)
426 { 426 {
427 WEBRTC_TRACE(kTraceDebug, kTraceVideoRenderer, _id, "Restarting screenUp dateThread"); 427 WEBRTC_TRACE(kTraceDebug, kTraceVideoRenderer, _id, "Restarting screenUp dateThread");
428 428
429 // we already have the thread. Most likely StopRender() was called and t hey were paused 429 // we already have the thread. Most likely StopRender() was called and t hey were paused
430 if(FALSE == _screenUpdateThread->Start() || 430 _screenUpdateThread->Start();
431 FALSE == _screenUpdateEvent->StartTimer(true, 1000/MONITOR_FREQ) ) 431 if (FALSE ==
432 { 432 _screenUpdateEvent->StartTimer(true, 1000 / MONITOR_FREQ)) {
433 WEBRTC_TRACE(kTraceError, kTraceVideoRenderer, _id, "Failed to resta rt screenUpdateThread or screenUpdateEvent"); 433 WEBRTC_TRACE(kTraceError, kTraceVideoRenderer, _id, "Failed to resta rt screenUpdateThread or screenUpdateEvent");
434 UnlockAGLCntx(); 434 UnlockAGLCntx();
435 return -1; 435 return -1;
436 } 436 }
437 437
438 _screenUpdateThread->SetPriority(kRealtimePriority); 438 _screenUpdateThread->SetPriority(rtc::kRealtimePriority);
439 439
440 UnlockAGLCntx(); 440 UnlockAGLCntx();
441 return 0; 441 return 0;
442 } 442 }
443 443
444 444
445 if (!_screenUpdateThread) 445 if (!_screenUpdateThread)
446 { 446 {
447 WEBRTC_TRACE(kTraceDebug, kTraceVideoRenderer, _id, "failed start screen UpdateThread"); 447 WEBRTC_TRACE(kTraceDebug, kTraceVideoRenderer, _id, "failed start screen UpdateThread");
448 UnlockAGLCntx(); 448 UnlockAGLCntx();
(...skipping 15 matching lines...) Expand all
464 464
465 // pause the update thread and the event timer 465 // pause the update thread and the event timer
466 if(!_screenUpdateThread || !_screenUpdateEvent) 466 if(!_screenUpdateThread || !_screenUpdateEvent)
467 { 467 {
468 _renderingIsPaused = TRUE; 468 _renderingIsPaused = TRUE;
469 469
470 UnlockAGLCntx(); 470 UnlockAGLCntx();
471 return 0; 471 return 0;
472 } 472 }
473 473
474 if(FALSE == _screenUpdateThread->Stop() || FALSE == _screenUpdateEvent->Stop Timer()) 474 _screenUpdateThread->Stop();
475 { 475 if (FALSE == _screenUpdateEvent->StopTimer()) {
476 _renderingIsPaused = FALSE; 476 _renderingIsPaused = FALSE;
477 477
478 UnlockAGLCntx(); 478 UnlockAGLCntx();
479 return -1; 479 return -1;
480 } 480 }
481 481
482 _renderingIsPaused = TRUE; 482 _renderingIsPaused = TRUE;
483 483
484 UnlockAGLCntx(); 484 UnlockAGLCntx();
485 return 0; 485 return 0;
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
650 [_windowRef setFrame:_windowRefSuperViewFrame]; 650 [_windowRef setFrame:_windowRefSuperViewFrame];
651 } 651 }
652 652
653 WEBRTC_TRACE(kTraceDebug, kTraceVideoRenderer, 0, "%s:%d Attempting to release fullscreen window", __FUNCTION__, __LINE__); 653 WEBRTC_TRACE(kTraceDebug, kTraceVideoRenderer, 0, "%s:%d Attempting to release fullscreen window", __FUNCTION__, __LINE__);
654 [_fullScreenWindow releaseFullScreen]; 654 [_fullScreenWindow releaseFullScreen];
655 655
656 } 656 }
657 } 657 }
658 658
659 // Signal event to exit thread, then delete it 659 // Signal event to exit thread, then delete it
660 PlatformThread* tmpPtr = _screenUpdateThread.release(); 660 rtc::PlatformThread* tmpPtr = _screenUpdateThread.release();
661 661
662 if (tmpPtr) 662 if (tmpPtr)
663 { 663 {
664 _screenUpdateEvent->Set(); 664 _screenUpdateEvent->Set();
665 _screenUpdateEvent->StopTimer(); 665 _screenUpdateEvent->StopTimer();
666 666
667 if (tmpPtr->Stop()) 667 tmpPtr->Stop();
668 { 668 delete tmpPtr;
669 delete tmpPtr;
670 }
671 delete _screenUpdateEvent; 669 delete _screenUpdateEvent;
672 _screenUpdateEvent = NULL; 670 _screenUpdateEvent = NULL;
673 } 671 }
674 672
675 if (_nsglContext != 0) 673 if (_nsglContext != 0)
676 { 674 {
677 [_nsglContext makeCurrentContext]; 675 [_nsglContext makeCurrentContext];
678 _nsglContext = nil; 676 _nsglContext = nil;
679 } 677 }
680 678
(...skipping 28 matching lines...) Expand all
709 { 707 {
710 708
711 LockAGLCntx(); 709 LockAGLCntx();
712 if (!_screenUpdateThread) 710 if (!_screenUpdateThread)
713 { 711 {
714 UnlockAGLCntx(); 712 UnlockAGLCntx();
715 return -1; 713 return -1;
716 } 714 }
717 715
718 _screenUpdateThread->Start(); 716 _screenUpdateThread->Start();
719 _screenUpdateThread->SetPriority(kRealtimePriority); 717 _screenUpdateThread->SetPriority(rtc::kRealtimePriority);
720 718
721 // Start the event triggering the render process 719 // Start the event triggering the render process
722 unsigned int monitorFreq = 60; 720 unsigned int monitorFreq = 60;
723 _screenUpdateEvent->StartTimer(true, 1000/monitorFreq); 721 _screenUpdateEvent->StartTimer(true, 1000/monitorFreq);
724 722
725 if (CreateMixingContext() == -1) 723 if (CreateMixingContext() == -1)
726 { 724 {
727 UnlockAGLCntx(); 725 UnlockAGLCntx();
728 return -1; 726 return -1;
729 } 727 }
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
857 855
858 return -1; 856 return -1;
859 } 857 }
860 858
861 return 0; 859 return 0;
862 } 860 }
863 861
864 int VideoRenderNSOpenGL::StopThread() 862 int VideoRenderNSOpenGL::StopThread()
865 { 863 {
866 864
867 PlatformThread* tmpPtr = _screenUpdateThread.release(); 865 rtc::PlatformThread* tmpPtr = _screenUpdateThread.release();
868 WEBRTC_TRACE(kTraceInfo, kTraceVideoRenderer, _id, 866 WEBRTC_TRACE(kTraceInfo, kTraceVideoRenderer, _id,
869 "%s Stopping thread ", __FUNCTION__, tmpPtr); 867 "%s Stopping thread ", __FUNCTION__, tmpPtr);
870 868
871 if (tmpPtr) 869 if (tmpPtr)
872 { 870 {
873 _screenUpdateEvent->Set(); 871 _screenUpdateEvent->Set();
874 if (tmpPtr->Stop()) 872 tmpPtr->Stop();
875 { 873 delete tmpPtr;
876 delete tmpPtr;
877 }
878 } 874 }
879 875
880 delete _screenUpdateEvent; 876 delete _screenUpdateEvent;
881 _screenUpdateEvent = NULL; 877 _screenUpdateEvent = NULL;
882 878
883 return 0; 879 return 0;
884 } 880 }
885 881
886 bool VideoRenderNSOpenGL::IsFullScreen() 882 bool VideoRenderNSOpenGL::IsFullScreen()
887 { 883 {
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
1242 } 1238 }
1243 1239
1244 1240
1245 1241
1246 */ 1242 */
1247 1243
1248 1244
1249 } // namespace webrtc 1245 } // namespace webrtc
1250 1246
1251 #endif // COCOA_RENDERING 1247 #endif // COCOA_RENDERING
OLDNEW
« no previous file with comments | « webrtc/modules/video_render/mac/video_render_nsopengl.h ('k') | webrtc/modules/video_render/windows/video_render_direct3d9.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698