]> git.sesse.net Git - casparcg/blobdiff - modules/flash/producer/FlashAxContainer.cpp
No more use for retry_task in decklink_consumer now since audio and video are complet...
[casparcg] / modules / flash / producer / FlashAxContainer.cpp
index 9949be7393b5360ea206a6c0866d8094024c8955..21504b2cc8c9c48e15e807a6601111d8ae0580cc 100644 (file)
@@ -25,6 +25,7 @@
 #include "../interop/TimerHelper.h"
 
 #include <common/log.h>
+#include <common/os/general_protection_fault.h>
 
 #if defined(_MSC_VER)
 #pragma warning (push, 2) // TODO
@@ -47,7 +48,7 @@ FlashAxContainer::~FlashAxContainer()
        if(m_lpDD4)
        {
                m_lpDD4->Release();
-               m_lpDD4 = nullptr;
+               delete m_lpDD4;
        }
 
        if(pTimerHelper != 0)
@@ -453,6 +454,7 @@ DEFINE_GUID2(IID_IDirectDraw7,0x15e65ec0,0x3b9c,0x11d2,0xb9,0x2f,0x00,0x60,0x97,
 /////////
 HRESULT STDMETHODCALLTYPE FlashAxContainer::QueryService( REFGUID rsid, REFIID riid, void** ppvObj) 
 {
+       ensure_gpf_handler_installed_for_thread("flash-player-thread");
 //     ATLTRACE(_T("IServiceProvider::QueryService\n"));
        //the flashcontrol asks for an interface {618F8AD4-8B7A-11D0-8FCC-00C04FD9189D}, this is IID for a DirectDraw3 object
 
@@ -538,7 +540,8 @@ HRESULT STDMETHODCALLTYPE FlashAxContainer::Advise(VARIANT vtimeMin, VARIANT vti
 
        if(pTimerHelper != 0)
        {
-               pTimerHelper->Setup(vtimeMin.ulVal, vtimeInterval.ulVal, pTimerSink);
+               //static tbb::atomic<DWORD> NEXT_ID;
+               pTimerHelper->Setup(0, vtimeMin.ulVal, vtimeInterval.ulVal, pTimerSink);
                *pdwCookie = pTimerHelper->ID;
                bHasNewTiming_ = true;
 
@@ -600,23 +603,24 @@ void FlashAxContainer::EnterFullscreen()
 
 void STDMETHODCALLTYPE FlashAxContainer::OnFlashCall(BSTR request)
 {
+       ensure_gpf_handler_installed_for_thread("flash-player-thread");
        std::wstring str(request);
-       if(str.find(TEXT("DisplayedTemplate")) != std::wstring::npos)
+       if(str.find(L"DisplayedTemplate") != std::wstring::npos)
        {
                ATLTRACE(_T("ShockwaveFlash::DisplayedTemplate\n"));
                bReadyToRender_ = true;
        }
-       else if(str.find(TEXT("OnCommand")) != std::wstring::npos) {
+       else if(str.find(L"OnCommand") != std::wstring::npos) {
                //this is how templatehost 1.8 reports that a command has been received
                CASPAR_LOG(debug)  << print_()  << L" [command]      " << str;
                bCallSuccessful_ = true;
        }
-       else if(str.find(TEXT("Activity")) != std::wstring::npos)
+       else if(str.find(L"Activity") != std::wstring::npos)
        {
                CASPAR_LOG(debug) << print_() << L" [activity]     " << str;
 
                //this is how templatehost 1.7 reports that a command has been received
-               if(str.find(TEXT("Command recieved")) != std::wstring::npos)
+               if(str.find(L"Command recieved") != std::wstring::npos)
                        bCallSuccessful_ = true;
 
                /*if(pFlashProducer_ != 0 && pFlashProducer_->pMonitor_) {
@@ -625,7 +629,7 @@ void STDMETHODCALLTYPE FlashAxContainer::OnFlashCall(BSTR request)
                                pFlashProducer_->pMonitor_->Inform(str.substr(pos, str.find(TEXT('<'), pos)-pos));
                }*/
        }
-       else if(str.find(TEXT("OnNotify")) != std::wstring::npos)
+       else if(str.find(L"OnNotify") != std::wstring::npos)
        {
                CASPAR_LOG(info) << print_() << L" [notification] " << str;
 
@@ -635,17 +639,20 @@ void STDMETHODCALLTYPE FlashAxContainer::OnFlashCall(BSTR request)
                //              pFlashProducer_->pMonitor_->Inform(str.substr(pos, str.find(TEXT('<'), pos)-pos));
                //}
        }
-       else if(str.find(TEXT("IsEmpty")) != std::wstring::npos)
+       else if(str.find(L"IsEmpty") != std::wstring::npos)
        {
-               CASPAR_LOG(trace) << print_() << L" Empty.";
+               CASPAR_LOG(debug) << print_() << L" Empty.";
                ATLTRACE(_T("ShockwaveFlash::IsEmpty\n"));
                bIsEmpty_ = true;
        }
-       else if(str.find(TEXT("OnError")) != std::wstring::npos)
+       else if(str.find(L"OnError") != std::wstring::npos)
        {
-               CASPAR_LOG(error) << print_() << L" [error]        " << str;
+               if (str.find(L"No template playing on layer") != std::wstring::npos)
+                       CASPAR_LOG(info) << print_() << L" [info]        " << str;
+               else
+                       CASPAR_LOG(error) << print_() << L" [error]        " << str;
        }
-       else if(str.find(TEXT("OnDebug")) != std::wstring::npos)
+       else if(str.find(L"OnDebug") != std::wstring::npos)
        {
                CASPAR_LOG(debug) << print_() << L" [debug]        " << str;
        }
@@ -666,18 +673,14 @@ void STDMETHODCALLTYPE FlashAxContainer::OnFlashCall(BSTR request)
        HRESULT hr = m_spOleObject->QueryInterface(__uuidof(IShockwaveFlash), (void**) &spFlash);
        if(hr == S_OK && spFlash)
        {
-               hr = spFlash->SetReturnValue(TEXT("<null/>"));
+               hr = spFlash->SetReturnValue(L"<null/>");
        }
 }
 
 void STDMETHODCALLTYPE FlashAxContainer::OnReadyStateChange(long newState)
 {
        if(newState == 4)
-       {
                bReadyToRender_ = true;
-       }
-       else
-               bReadyToRender_ = false;
 }
 
 void FlashAxContainer::DestroyAxControl()
@@ -772,10 +775,10 @@ HRESULT FlashAxContainer::CreateAxControl()
                        HRESULT hr2 = m_spOleObject->QueryInterface(__uuidof(IShockwaveFlash), (void**) &spFlash);
                        if(hr2 == S_OK && spFlash)
                        {
-                               if(FAILED(spFlash->put_WMode(TEXT("Transparent"))))
+                               if(FAILED(spFlash->put_WMode(L"Transparent")))
                                        CASPAR_LOG(warning) << print_() << L" Failed to set flash container to transparent mode.";
                                //spFlash->put_WMode(TEXT("ogl"));
-                               hResultQuality = spFlash->put_Quality2(TEXT("Best"));
+                               hResultQuality = spFlash->put_Quality2(L"Best");
                        }
                        if(SUCCEEDED(DispEventAdvise(spFlash, &DIID__IShockwaveFlashEvents)))
                        {
@@ -863,9 +866,7 @@ bool FlashAxContainer::DrawControl(HDC targetDC)
 {
 //     ATLTRACE(_T("FlashAxContainer::DrawControl\n"));
        DVASPECTINFO aspectInfo = {sizeof(DVASPECTINFO), DVASPECTINFOFLAG_CANOPTIMIZE};
-       HRESULT hr = S_OK;
-
-       hr = m_spViewObject->Draw(DVASPECT_CONTENT, -1, &aspectInfo, NULL, NULL, targetDC, NULL, NULL, NULL, NULL); 
+       HRESULT hr = m_spViewObject->Draw(DVASPECT_CONTENT, -1, &aspectInfo, NULL, NULL, targetDC, NULL, NULL, NULL, NULL); 
        bInvalidRect_ = false;
 /*     const video_format_desc& fmtDesc = video_format_desc::FormatDescriptions[format_];