mirror of https://github.com/odrling/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
|
@ -49,10 +49,14 @@
|
|||
///////////
|
||||
// Constructor
|
||||
FFmpegSourceAudioProvider::FFmpegSourceAudioProvider(Aegisub::String filename) {
|
||||
COMInited = false;
|
||||
#ifdef WIN32
|
||||
if (!SUCCEEDED(CoInitializeEx(NULL, COINIT_MULTITHREADED))) {
|
||||
throw _T("FFmpegSource audio provider: COM initialization failure");
|
||||
}
|
||||
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");
|
||||
#endif
|
||||
FFMS_Init();
|
||||
|
||||
|
@ -182,7 +186,8 @@ void FFmpegSourceAudioProvider::LoadAudio(Aegisub::String filename) {
|
|||
FFmpegSourceAudioProvider::~FFmpegSourceAudioProvider() {
|
||||
Close();
|
||||
#ifdef WIN32
|
||||
CoUninitialize();
|
||||
if (COMInited)
|
||||
CoUninitialize();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -51,6 +51,8 @@ private:
|
|||
unsigned MsgSize;
|
||||
wxString MsgString;
|
||||
|
||||
bool COMInited;
|
||||
|
||||
void Close();
|
||||
void LoadAudio(Aegisub::String filename);
|
||||
|
||||
|
|
|
@ -53,10 +53,14 @@
|
|||
///////////////
|
||||
// Constructor
|
||||
FFmpegSourceVideoProvider::FFmpegSourceVideoProvider(Aegisub::String filename, double fps) {
|
||||
COMInited = false;
|
||||
#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");
|
||||
}
|
||||
#endif
|
||||
// initialize ffmpegsource
|
||||
FFMS_Init();
|
||||
|
@ -84,7 +88,8 @@ FFmpegSourceVideoProvider::FFmpegSourceVideoProvider(Aegisub::String filename, d
|
|||
FFmpegSourceVideoProvider::~FFmpegSourceVideoProvider() {
|
||||
Close();
|
||||
#ifdef WIN32
|
||||
CoUninitialize();
|
||||
if (COMInited)
|
||||
CoUninitialize();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -64,6 +64,8 @@ private:
|
|||
unsigned MessageSize;
|
||||
wxString ErrorMsg;
|
||||
|
||||
bool COMInited;
|
||||
|
||||
void LoadVideo(Aegisub::String filename, double fps);
|
||||
void Close();
|
||||
|
||||
|
|
Loading…
Reference in New Issue