forked from mia/Aegisub
Do COM initialization more properly (I think) in the FFMS2 providers.
Originally committed to SVN as r2989.
This commit is contained in:
parent
200b3393f9
commit
379f15659a
4 changed files with 21 additions and 7 deletions
|
@ -49,10 +49,14 @@
|
||||||
///////////
|
///////////
|
||||||
// Constructor
|
// Constructor
|
||||||
FFmpegSourceAudioProvider::FFmpegSourceAudioProvider(Aegisub::String filename) {
|
FFmpegSourceAudioProvider::FFmpegSourceAudioProvider(Aegisub::String filename) {
|
||||||
|
COMInited = false;
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
if (!SUCCEEDED(CoInitializeEx(NULL, COINIT_MULTITHREADED))) {
|
HRESULT res;
|
||||||
throw _T("FFmpegSource audio provider: COM initialization failure");
|
res = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
|
||||||
}
|
if (SUCCEEDED(res))
|
||||||
|
COMInited = true;
|
||||||
|
else if (res != RPC_E_CHANGED_MODE)
|
||||||
|
throw _T("FFmpegSource video provider: COM initialization failure");
|
||||||
#endif
|
#endif
|
||||||
FFMS_Init();
|
FFMS_Init();
|
||||||
|
|
||||||
|
@ -182,7 +186,8 @@ void FFmpegSourceAudioProvider::LoadAudio(Aegisub::String filename) {
|
||||||
FFmpegSourceAudioProvider::~FFmpegSourceAudioProvider() {
|
FFmpegSourceAudioProvider::~FFmpegSourceAudioProvider() {
|
||||||
Close();
|
Close();
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
CoUninitialize();
|
if (COMInited)
|
||||||
|
CoUninitialize();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,6 +51,8 @@ private:
|
||||||
unsigned MsgSize;
|
unsigned MsgSize;
|
||||||
wxString MsgString;
|
wxString MsgString;
|
||||||
|
|
||||||
|
bool COMInited;
|
||||||
|
|
||||||
void Close();
|
void Close();
|
||||||
void LoadAudio(Aegisub::String filename);
|
void LoadAudio(Aegisub::String filename);
|
||||||
|
|
||||||
|
|
|
@ -53,10 +53,14 @@
|
||||||
///////////////
|
///////////////
|
||||||
// Constructor
|
// Constructor
|
||||||
FFmpegSourceVideoProvider::FFmpegSourceVideoProvider(Aegisub::String filename, double fps) {
|
FFmpegSourceVideoProvider::FFmpegSourceVideoProvider(Aegisub::String filename, double fps) {
|
||||||
|
COMInited = false;
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
if (!SUCCEEDED(CoInitializeEx(NULL, COINIT_MULTITHREADED))) {
|
HRESULT res;
|
||||||
|
res = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
|
||||||
|
if (SUCCEEDED(res))
|
||||||
|
COMInited = true;
|
||||||
|
else if (res != RPC_E_CHANGED_MODE)
|
||||||
throw _T("FFmpegSource video provider: COM initialization failure");
|
throw _T("FFmpegSource video provider: COM initialization failure");
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
// initialize ffmpegsource
|
// initialize ffmpegsource
|
||||||
FFMS_Init();
|
FFMS_Init();
|
||||||
|
@ -84,7 +88,8 @@ FFmpegSourceVideoProvider::FFmpegSourceVideoProvider(Aegisub::String filename, d
|
||||||
FFmpegSourceVideoProvider::~FFmpegSourceVideoProvider() {
|
FFmpegSourceVideoProvider::~FFmpegSourceVideoProvider() {
|
||||||
Close();
|
Close();
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
CoUninitialize();
|
if (COMInited)
|
||||||
|
CoUninitialize();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -64,6 +64,8 @@ private:
|
||||||
unsigned MessageSize;
|
unsigned MessageSize;
|
||||||
wxString ErrorMsg;
|
wxString ErrorMsg;
|
||||||
|
|
||||||
|
bool COMInited;
|
||||||
|
|
||||||
void LoadVideo(Aegisub::String filename, double fps);
|
void LoadVideo(Aegisub::String filename, double fps);
|
||||||
void Close();
|
void Close();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue