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

Side by Side Diff: webrtc/modules/video_render/mac/video_render_agl.cc

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 377 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 _zOrderToChannel( ), 388 _zOrderToChannel( ),
389 _hiviewEventHandlerRef( NULL), 389 _hiviewEventHandlerRef( NULL),
390 _windowEventHandlerRef( NULL), 390 _windowEventHandlerRef( NULL),
391 _currentViewBounds( ), 391 _currentViewBounds( ),
392 _lastViewBounds( ), 392 _lastViewBounds( ),
393 _renderingIsPaused( false), 393 _renderingIsPaused( false),
394 394
395 { 395 {
396 //WEBRTC_TRACE(kTraceInfo, kTraceVideoRenderer, _id, "%s"); 396 //WEBRTC_TRACE(kTraceInfo, kTraceVideoRenderer, _id, "%s");
397 397
398 _screenUpdateThread = PlatformThread::CreateThread(ScreenUpdateThreadProc, 398 _screenUpdateThread.reset(
399 this, "ScreenUpdate"); 399 new rtc::PlatformThread(ScreenUpdateThreadProc, this, "ScreenUpdate"));
400 _screenUpdateEvent = EventWrapper::Create(); 400 _screenUpdateEvent = EventWrapper::Create();
401 401
402 if(!IsValidWindowPtr(_windowRef)) 402 if(!IsValidWindowPtr(_windowRef))
403 { 403 {
404 //WEBRTC_TRACE(kTraceError, kTraceVideoRenderer, _id, "%s:%d Invalid Win dowRef:0x%x", __FUNCTION__, __LINE__, _windowRef); 404 //WEBRTC_TRACE(kTraceError, kTraceVideoRenderer, _id, "%s:%d Invalid Win dowRef:0x%x", __FUNCTION__, __LINE__, _windowRef);
405 } 405 }
406 else 406 else
407 { 407 {
408 //WEBRTC_TRACE(kTraceDebug, kTraceVideoRenderer, _id, "%s:%d WindowRef 0 x%x is valid", __FUNCTION__, __LINE__, _windowRef); 408 //WEBRTC_TRACE(kTraceDebug, kTraceVideoRenderer, _id, "%s:%d WindowRef 0 x%x is valid", __FUNCTION__, __LINE__, _windowRef);
409 } 409 }
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
505 _zOrderToChannel( ), 505 _zOrderToChannel( ),
506 _hiviewEventHandlerRef( NULL), 506 _hiviewEventHandlerRef( NULL),
507 _windowEventHandlerRef( NULL), 507 _windowEventHandlerRef( NULL),
508 _currentViewBounds( ), 508 _currentViewBounds( ),
509 _lastViewBounds( ), 509 _lastViewBounds( ),
510 _renderingIsPaused( false), 510 _renderingIsPaused( false),
511 { 511 {
512 //WEBRTC_TRACE(kTraceDebug, "%s:%d Constructor", __FUNCTION__, __LINE__); 512 //WEBRTC_TRACE(kTraceDebug, "%s:%d Constructor", __FUNCTION__, __LINE__);
513 // _renderCritSec = CriticalSectionWrapper::CreateCriticalSection(); 513 // _renderCritSec = CriticalSectionWrapper::CreateCriticalSection();
514 514
515 _screenUpdateThread = PlatformThread::CreateThread( 515 _screenUpdateThread.reset(new rtc::PlatformThread(
516 ScreenUpdateThreadProc, this, "ScreenUpdateThread"); 516 ScreenUpdateThreadProc, this, "ScreenUpdateThread"));
517 _screenUpdateEvent = EventWrapper::Create(); 517 _screenUpdateEvent = EventWrapper::Create();
518 518
519 GetWindowRect(_windowRect); 519 GetWindowRect(_windowRect);
520 520
521 _lastViewBounds.origin.x = 0; 521 _lastViewBounds.origin.x = 0;
522 _lastViewBounds.origin.y = 0; 522 _lastViewBounds.origin.y = 0;
523 _lastViewBounds.size.width = 0; 523 _lastViewBounds.size.width = 0;
524 _lastViewBounds.size.height = 0; 524 _lastViewBounds.size.height = 0;
525 525
526 #ifdef NEW_HIVIEW_PARENT_EVENT_HANDLER 526 #ifdef NEW_HIVIEW_PARENT_EVENT_HANDLER
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
670 { 670 {
671 status = RemoveEventHandler(_hiviewEventHandlerRef); 671 status = RemoveEventHandler(_hiviewEventHandlerRef);
672 if(status != noErr) 672 if(status != noErr)
673 { 673 {
674 //WEBRTC_TRACE(kTraceDebug, "%s:%d Failed to remove hiview event han dler: %d", __FUNCTION__, __LINE__, (int)_hiviewEventHandlerRef); 674 //WEBRTC_TRACE(kTraceDebug, "%s:%d Failed to remove hiview event han dler: %d", __FUNCTION__, __LINE__, (int)_hiviewEventHandlerRef);
675 } 675 }
676 } 676 }
677 #endif 677 #endif
678 678
679 // Signal event to exit thread, then delete it 679 // Signal event to exit thread, then delete it
680 PlatformThread* tmpPtr = _screenUpdateThread.release(); 680 rtc::PlatformThread* tmpPtr = _screenUpdateThread.release();
681 681
682 if (tmpPtr) 682 if (tmpPtr)
683 { 683 {
684 _screenUpdateEvent->Set(); 684 _screenUpdateEvent->Set();
685 _screenUpdateEvent->StopTimer(); 685 _screenUpdateEvent->StopTimer();
686 686
687 tmpPtr->Stop(); 687 tmpPtr->Stop();
688 delete tmpPtr; 688 delete tmpPtr;
689 delete _screenUpdateEvent; 689 delete _screenUpdateEvent;
690 _screenUpdateEvent = NULL; 690 _screenUpdateEvent = NULL;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
732 LockAGLCntx(); 732 LockAGLCntx();
733 733
734 // Start rendering thread... 734 // Start rendering thread...
735 if (!_screenUpdateThread) 735 if (!_screenUpdateThread)
736 { 736 {
737 UnlockAGLCntx(); 737 UnlockAGLCntx();
738 //WEBRTC_TRACE(kTraceError, "%s:%d Thread not created", __FUNCTION__, __ LINE__); 738 //WEBRTC_TRACE(kTraceError, "%s:%d Thread not created", __FUNCTION__, __ LINE__);
739 return -1; 739 return -1;
740 } 740 }
741 _screenUpdateThread->Start(); 741 _screenUpdateThread->Start();
742 _screenUpdateThread->SetPriority(kRealtimePriority); 742 _screenUpdateThread->SetPriority(rtc::kRealtimePriority);
743 743
744 // Start the event triggering the render process 744 // Start the event triggering the render process
745 unsigned int monitorFreq = 60; 745 unsigned int monitorFreq = 60;
746 _screenUpdateEvent->StartTimer(true, 1000/monitorFreq); 746 _screenUpdateEvent->StartTimer(true, 1000/monitorFreq);
747 747
748 // Create mixing textures 748 // Create mixing textures
749 if (CreateMixingContext() == -1) 749 if (CreateMixingContext() == -1)
750 { 750 {
751 //WEBRTC_TRACE(kTraceError, "%s:%d Could not create a mixing context", _ _FUNCTION__, __LINE__); 751 //WEBRTC_TRACE(kTraceError, "%s:%d Could not create a mixing context", _ _FUNCTION__, __LINE__);
752 UnlockAGLCntx(); 752 UnlockAGLCntx();
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
849 } 849 }
850 zIt++;// = _zOrderToChannel.begin(); 850 zIt++;// = _zOrderToChannel.begin();
851 } 851 }
852 852
853 return 0; 853 return 0;
854 } 854 }
855 855
856 int VideoRenderAGL::StopThread() 856 int VideoRenderAGL::StopThread()
857 { 857 {
858 CriticalSectionScoped cs(&_renderCritSec); 858 CriticalSectionScoped cs(&_renderCritSec);
859 PlatformThread* tmpPtr = _screenUpdateThread.release(); 859 rtc::PlatformThread* tmpPtr = _screenUpdateThread.release();
860 860
861 if (tmpPtr) 861 if (tmpPtr)
862 { 862 {
863 _screenUpdateEvent->Set(); 863 _screenUpdateEvent->Set();
864 _renderCritSec.Leave(); 864 _renderCritSec.Leave();
865 tmpPtr->Stop(); 865 tmpPtr->Stop();
866 delete tmpPtr; 866 delete tmpPtr;
867 _renderCritSec.Enter(); 867 _renderCritSec.Enter();
868 } 868 }
869 869
(...skipping 1003 matching lines...) Expand 10 before | Expand all | Expand 10 after
1873 { 1873 {
1874 //WEBRTC_TRACE(kTraceInfo, kTraceVideoRenderer, _id, "%s:%d Rendering is paused. Restarting now", __FUNCTION__, __LINE__); 1874 //WEBRTC_TRACE(kTraceInfo, kTraceVideoRenderer, _id, "%s:%d Rendering is paused. Restarting now", __FUNCTION__, __LINE__);
1875 1875
1876 // we already have the thread. Most likely StopRender() was called and t hey were paused 1876 // we already have the thread. Most likely StopRender() was called and t hey were paused
1877 if(FALSE == _screenUpdateThread->Start()) 1877 if(FALSE == _screenUpdateThread->Start())
1878 { 1878 {
1879 //WEBRTC_TRACE(kTraceError, kTraceVideoRenderer, _id, "%s:%d Failed to start screenUpdateThread", __FUNCTION__, __LINE__); 1879 //WEBRTC_TRACE(kTraceError, kTraceVideoRenderer, _id, "%s:%d Failed to start screenUpdateThread", __FUNCTION__, __LINE__);
1880 UnlockAGLCntx(); 1880 UnlockAGLCntx();
1881 return -1; 1881 return -1;
1882 } 1882 }
1883 _screenUpdateThread->SetPriority(kRealtimePriority); 1883 _screenUpdateThread->SetPriority(rtc::kRealtimePriority);
1884 if(FALSE == _screenUpdateEvent->StartTimer(true, 1000/MONITOR_FREQ)) 1884 if(FALSE == _screenUpdateEvent->StartTimer(true, 1000/MONITOR_FREQ))
1885 { 1885 {
1886 //WEBRTC_TRACE(kTraceError, kTraceVideoRenderer, _id, "%s:%d Failed to start screenUpdateEvent", __FUNCTION__, __LINE__); 1886 //WEBRTC_TRACE(kTraceError, kTraceVideoRenderer, _id, "%s:%d Failed to start screenUpdateEvent", __FUNCTION__, __LINE__);
1887 UnlockAGLCntx(); 1887 UnlockAGLCntx();
1888 return -1; 1888 return -1;
1889 } 1889 }
1890 1890
1891 return 0; 1891 return 0;
1892 } 1892 }
1893 1893
1894 _screenUpdateThread = PlatformThread::CreateThread(ScreenUpdateThreadProc, 1894 _screenUpdateThread.reset(
1895 this, "ScreenUpdate"); 1895 new rtc::PlatformThread(ScreenUpdateThreadProc, this, "ScreenUpdate"));
1896 _screenUpdateEvent = EventWrapper::Create(); 1896 _screenUpdateEvent = EventWrapper::Create();
1897 1897
1898 if (!_screenUpdateThread) 1898 if (!_screenUpdateThread)
1899 { 1899 {
1900 //WEBRTC_TRACE(kTraceError, kTraceVideoRenderer, _id, "%s:%d Failed to s tart screenUpdateThread", __FUNCTION__, __LINE__); 1900 //WEBRTC_TRACE(kTraceError, kTraceVideoRenderer, _id, "%s:%d Failed to s tart screenUpdateThread", __FUNCTION__, __LINE__);
1901 UnlockAGLCntx(); 1901 UnlockAGLCntx();
1902 return -1; 1902 return -1;
1903 } 1903 }
1904 1904
1905 _screenUpdateThread->Start(); 1905 _screenUpdateThread->Start();
1906 _screenUpdateThread->SetPriority(kRealtimePriority); 1906 _screenUpdateThread->SetPriority(rtc::kRealtimePriority);
1907 _screenUpdateEvent->StartTimer(true, 1000/MONITOR_FREQ); 1907 _screenUpdateEvent->StartTimer(true, 1000/MONITOR_FREQ);
1908 1908
1909 //WEBRTC_TRACE(kTraceInfo, kTraceVideoRenderer, _id, "%s:%d Started screenUp dateThread", __FUNCTION__, __LINE__); 1909 //WEBRTC_TRACE(kTraceInfo, kTraceVideoRenderer, _id, "%s:%d Started screenUp dateThread", __FUNCTION__, __LINE__);
1910 1910
1911 UnlockAGLCntx(); 1911 UnlockAGLCntx();
1912 return 0; 1912 return 0;
1913
1914 } 1913 }
1915 1914
1916 int32_t VideoRenderAGL::StopRender() 1915 int32_t VideoRenderAGL::StopRender()
1917 { 1916 {
1918 LockAGLCntx(); 1917 LockAGLCntx();
1919 1918
1920 if(!_screenUpdateThread || !_screenUpdateEvent) 1919 if(!_screenUpdateThread || !_screenUpdateEvent)
1921 { 1920 {
1922 _renderingIsPaused = TRUE; 1921 _renderingIsPaused = TRUE;
1923 UnlockAGLCntx(); 1922 UnlockAGLCntx();
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
1979 _renderCritSec.Enter(); 1978 _renderCritSec.Enter();
1980 } 1979 }
1981 void VideoRenderAGL::UnlockAGLCntx() 1980 void VideoRenderAGL::UnlockAGLCntx()
1982 { 1981 {
1983 _renderCritSec.Leave(); 1982 _renderCritSec.Leave();
1984 } 1983 }
1985 1984
1986 } // namespace webrtc 1985 } // namespace webrtc
1987 1986
1988 #endif // CARBON_RENDERING 1987 #endif // CARBON_RENDERING
OLDNEW
« no previous file with comments | « webrtc/modules/video_render/mac/video_render_agl.h ('k') | webrtc/modules/video_render/mac/video_render_nsopengl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698