From ea385c4da848110d7105d2ab4809610eb941de0c Mon Sep 17 00:00:00 2001 From: feal87 Date: Tue, 2 Mar 2010 12:55:26 +0000 Subject: [PATCH] Fixed the capture video functionality of GSDX. Let's hope I'll make bositman happy with this. :D It was a series of very old bug. 1) After the passage to the WX system the CoInitialize was not anymore called on the GS thread causing the Filter enumeration on DirectShow to fail. 2) After the "MFC Free" commit of Gabest, if you selected the Uncompressed functionality a nullpointer exception trigger (as there is no filter for that) 3) Strangely there was no code path to connect the source with the mux when Uncompressed was selected (without an encoder in the middle). I added it. Test it and report problem. I already know there is a problem with the closing of the sound recording, but that's a PCSX2 problem, not a GSDX one. git-svn-id: http://pcsx2.googlecode.com/svn/trunk@2657 96395faa-99c1-11dd-bbfe-3dabce05a288 --- plugins/GSdx/GSCapture.cpp | 24 +++++++++++++++++------- plugins/GSdx/GSCaptureDlg.cpp | 16 ++++++++++++---- 2 files changed, 29 insertions(+), 11 deletions(-) diff --git a/plugins/GSdx/GSCapture.cpp b/plugins/GSdx/GSCapture.cpp index 685141bd93..79f76fa9d9 100644 --- a/plugins/GSdx/GSCapture.cpp +++ b/plugins/GSdx/GSCapture.cpp @@ -434,16 +434,26 @@ bool GSCapture::BeginCapture(int fps) m_src = new GSSource(m_size.x, m_size.y, fps, NULL, hr); - if(FAILED(hr = m_graph->AddFilter(m_src, L"Source")) - || FAILED(hr = m_graph->AddFilter(dlg.m_enc, L"Encoder"))) + if (dlg.m_enc==0) { - return false; + if (FAILED(hr = m_graph->AddFilter(m_src, L"Source"))) + return false; + if (FAILED(hr = m_graph->ConnectDirect(GetFirstPin(m_src, PINDIR_OUTPUT), GetFirstPin(mux, PINDIR_INPUT), NULL))) + return false; } - - if(FAILED(hr = m_graph->ConnectDirect(GetFirstPin(m_src, PINDIR_OUTPUT), GetFirstPin(dlg.m_enc, PINDIR_INPUT), NULL)) - || FAILED(hr = m_graph->ConnectDirect(GetFirstPin(dlg.m_enc, PINDIR_OUTPUT), GetFirstPin(mux, PINDIR_INPUT), NULL))) + else { - return false; + if(FAILED(hr = m_graph->AddFilter(m_src, L"Source")) + || FAILED(hr = m_graph->AddFilter(dlg.m_enc, L"Encoder"))) + { + return false; + } + + if(FAILED(hr = m_graph->ConnectDirect(GetFirstPin(m_src, PINDIR_OUTPUT), GetFirstPin(dlg.m_enc, PINDIR_INPUT), NULL)) + || FAILED(hr = m_graph->ConnectDirect(GetFirstPin(dlg.m_enc, PINDIR_OUTPUT), GetFirstPin(mux, PINDIR_INPUT), NULL))) + { + return false; + } } BeginEnumFilters(m_graph, pEF, pBF) diff --git a/plugins/GSdx/GSCaptureDlg.cpp b/plugins/GSdx/GSCaptureDlg.cpp index d918cbb18c..0e63d1c6d1 100644 --- a/plugins/GSdx/GSCaptureDlg.cpp +++ b/plugins/GSdx/GSCaptureDlg.cpp @@ -68,6 +68,7 @@ void GSCaptureDlg::OnInit() ComboBoxAppend(IDC_CODECS, "Uncompressed", 0, true); + CoInitialize(0); BeginEnumSysDev(CLSID_VideoCompressorCategory, moniker) { Codec c; @@ -179,7 +180,8 @@ bool GSCaptureDlg::OnCommand(HWND hWnd, UINT id, UINT code) Codec c; - if(GetSelCodec(c) == 0) + int ris = GetSelCodec(c); + if(ris == 0) { return false; } @@ -190,9 +192,15 @@ bool GSCaptureDlg::OnCommand(HWND hWnd, UINT id, UINT code) theApp.SetConfig("CaptureHeight", m_height); theApp.SetConfig("CaptureFileName", m_filename.c_str()); - wstring s = wstring(c.DisplayName.m_str); - - theApp.SetConfig("CaptureVideoCodecDisplayName", string(s.begin(), s.end()).c_str()); + if (ris != 2) + { + wstring s = wstring(c.DisplayName.m_str); + theApp.SetConfig("CaptureVideoCodecDisplayName", string(s.begin(), s.end()).c_str()); + } + else + { + theApp.SetConfig("CaptureVideoCodecDisplayName", ""); + } } return __super::OnCommand(hWnd, id, code);