Update FFMS2 providers to initialize COM when running under Windows, as per the new FFMS2 init procedure.
Originally committed to SVN as r2986.
This commit is contained in:
parent
50069248e9
commit
c8b125943c
2 changed files with 23 additions and 9 deletions
|
@ -41,15 +41,20 @@
|
||||||
// Headers
|
// Headers
|
||||||
#include "include/aegisub/aegisub.h"
|
#include "include/aegisub/aegisub.h"
|
||||||
#include "audio_provider_ffmpegsource.h"
|
#include "audio_provider_ffmpegsource.h"
|
||||||
|
#ifdef WIN32
|
||||||
|
#include <objbase.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
///////////
|
///////////
|
||||||
// Constructor
|
// Constructor
|
||||||
FFmpegSourceAudioProvider::FFmpegSourceAudioProvider(Aegisub::String filename) {
|
FFmpegSourceAudioProvider::FFmpegSourceAudioProvider(Aegisub::String filename) {
|
||||||
if (FFMS_Init()) {
|
#ifdef WIN32
|
||||||
FFMS_DeInit();
|
if (!SUCCEEDED(CoInitializeEx(NULL, COINIT_MULTITHREADED))) {
|
||||||
throw _T("FFmpegSource audio provider: failed to initialize FFMS2");
|
throw _T("FFmpegSource audio provider: COM initialization failure");
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
FFMS_Init();
|
||||||
|
|
||||||
MsgSize = sizeof(FFMSErrMsg);
|
MsgSize = sizeof(FFMSErrMsg);
|
||||||
MsgString = _T("FFmpegSource audio provider: ");
|
MsgString = _T("FFmpegSource audio provider: ");
|
||||||
|
@ -176,6 +181,9 @@ void FFmpegSourceAudioProvider::LoadAudio(Aegisub::String filename) {
|
||||||
// Destructor
|
// Destructor
|
||||||
FFmpegSourceAudioProvider::~FFmpegSourceAudioProvider() {
|
FFmpegSourceAudioProvider::~FFmpegSourceAudioProvider() {
|
||||||
Close();
|
Close();
|
||||||
|
#ifdef WIN32
|
||||||
|
CoUninitialize();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -184,7 +192,6 @@ FFmpegSourceAudioProvider::~FFmpegSourceAudioProvider() {
|
||||||
void FFmpegSourceAudioProvider::Close() {
|
void FFmpegSourceAudioProvider::Close() {
|
||||||
FFMS_DestroyAudioSource(AudioSource);
|
FFMS_DestroyAudioSource(AudioSource);
|
||||||
AudioSource = NULL;
|
AudioSource = NULL;
|
||||||
FFMS_DeInit();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -45,16 +45,21 @@
|
||||||
#include "video_context.h"
|
#include "video_context.h"
|
||||||
#include "options.h"
|
#include "options.h"
|
||||||
#include "aegisub_endian.h"
|
#include "aegisub_endian.h"
|
||||||
|
#ifdef WIN32
|
||||||
|
#include <objbase.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
///////////////
|
///////////////
|
||||||
// Constructor
|
// Constructor
|
||||||
FFmpegSourceVideoProvider::FFmpegSourceVideoProvider(Aegisub::String filename, double fps) {
|
FFmpegSourceVideoProvider::FFmpegSourceVideoProvider(Aegisub::String filename, double fps) {
|
||||||
// initialize ffmpegsource
|
#ifdef WIN32
|
||||||
if (FFMS_Init()) {
|
if (!SUCCEEDED(CoInitializeEx(NULL, COINIT_MULTITHREADED))) {
|
||||||
FFMS_DeInit();
|
throw _T("FFmpegSource video provider: COM initialization failure");
|
||||||
throw _T("FFmpegSource video provider: failed to initialize FFMS2");
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
// initialize ffmpegsource
|
||||||
|
FFMS_Init();
|
||||||
|
|
||||||
// clean up variables
|
// clean up variables
|
||||||
VideoSource = NULL;
|
VideoSource = NULL;
|
||||||
|
@ -78,6 +83,9 @@ FFmpegSourceVideoProvider::FFmpegSourceVideoProvider(Aegisub::String filename, d
|
||||||
// Destructor
|
// Destructor
|
||||||
FFmpegSourceVideoProvider::~FFmpegSourceVideoProvider() {
|
FFmpegSourceVideoProvider::~FFmpegSourceVideoProvider() {
|
||||||
Close();
|
Close();
|
||||||
|
#ifdef WIN32
|
||||||
|
CoUninitialize();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////
|
///////////////
|
||||||
|
@ -205,7 +213,6 @@ void FFmpegSourceVideoProvider::LoadVideo(Aegisub::String filename, double fps)
|
||||||
void FFmpegSourceVideoProvider::Close() {
|
void FFmpegSourceVideoProvider::Close() {
|
||||||
FFMS_DestroyVideoSource(VideoSource);
|
FFMS_DestroyVideoSource(VideoSource);
|
||||||
VideoSource = NULL;
|
VideoSource = NULL;
|
||||||
FFMS_DeInit();
|
|
||||||
|
|
||||||
DstFormat = FFMS_GetPixFmt("none");
|
DstFormat = FFMS_GetPixFmt("none");
|
||||||
LastDstFormat = FFMS_GetPixFmt("none");
|
LastDstFormat = FFMS_GetPixFmt("none");
|
||||||
|
|
Loading…
Reference in a new issue