forked from mia/Aegisub
FFMS2: revert the initialization mess, instead require the caller to initialize com where it's needed
Originally committed to SVN as r2984.
This commit is contained in:
parent
ab5bc99e94
commit
9fe7b04830
4 changed files with 9 additions and 32 deletions
|
@ -31,33 +31,14 @@ extern "C" {
|
|||
#define _snprintf snprintf
|
||||
#endif
|
||||
|
||||
static int InitCount = 0;
|
||||
static bool FFmpegInited = false;
|
||||
|
||||
FFMS_API(int) FFMS_Init() {
|
||||
FFMS_API(void) FFMS_Init() {
|
||||
if (!FFmpegInited) {
|
||||
av_register_all();
|
||||
av_log_set_level(AV_LOG_QUIET);
|
||||
FFmpegInited = true;
|
||||
}
|
||||
|
||||
if (!InitCount) {
|
||||
#ifdef HAALISOURCE
|
||||
::CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
|
||||
#endif
|
||||
}
|
||||
|
||||
InitCount++;
|
||||
return InitCount;
|
||||
}
|
||||
|
||||
FFMS_API(int) FFMS_DeInit() {
|
||||
InitCount--;
|
||||
if (!InitCount) {
|
||||
#ifdef HAALISOURCE
|
||||
::CoUninitialize();
|
||||
#endif
|
||||
}
|
||||
return InitCount;
|
||||
}
|
||||
|
||||
FFMS_API(int) FFMS_GetLogLevel() {
|
||||
|
|
|
@ -122,8 +122,7 @@ typedef int (FFMS_CC *TAudioNameCallback)(const char *SourceFile, int Track, con
|
|||
|
||||
// Most functions return 0 on success
|
||||
// Functions without error message output can be assumed to never fail
|
||||
FFMS_API(int) FFMS_Init();
|
||||
FFMS_API(int) FFMS_DeInit();
|
||||
FFMS_API(void) FFMS_Init();
|
||||
FFMS_API(int) FFMS_GetLogLevel();
|
||||
FFMS_API(void) FFMS_SetLogLevel(int Level);
|
||||
FFMS_API(FFVideo *) FFMS_CreateVideoSource(const char *SourceFile, int Track, FFIndex *Index, const char *PP, int Threads, int SeekMode, char *ErrorMsg, unsigned MsgSize);
|
||||
|
|
|
@ -51,9 +51,9 @@ static int FFMS_CC UpdateProgress(int64_t Current, int64_t Total, void *Private)
|
|||
|
||||
void TestFullDump1(char *SrcFile, bool WithAudio) {
|
||||
int Private;
|
||||
int ret;
|
||||
char ErrorMsg[2000];
|
||||
int ret = FFMS_Init();
|
||||
assert(!ret);
|
||||
FFMS_Init();
|
||||
|
||||
FFIndexer *FIdx = FFMS_CreateIndexer(SrcFile, ErrorMsg, sizeof(ErrorMsg));
|
||||
assert(FIdx);
|
||||
|
@ -61,6 +61,8 @@ void TestFullDump1(char *SrcFile, bool WithAudio) {
|
|||
FIdx = FFMS_CreateIndexer(SrcFile, ErrorMsg, sizeof(ErrorMsg));
|
||||
assert(FIdx);
|
||||
|
||||
const char *Name = FFMS_GetCodecNameI(FIdx, 0);
|
||||
|
||||
FFIndex *FI = FFMS_DoIndexing(FIdx, -1, -1, FFMS_DefaultAudioFilename, NULL, false, UpdateProgress, &Private, ErrorMsg, sizeof(ErrorMsg));
|
||||
assert(FI);
|
||||
|
||||
|
@ -95,7 +97,6 @@ void TestFullDump1(char *SrcFile, bool WithAudio) {
|
|||
|
||||
FFMS_DestroyFFIndex(FI);
|
||||
FFMS_DestroyVideoSource(V);
|
||||
FFMS_DeInit();
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
@ -109,7 +110,7 @@ int main(int argc, char *argv[]) {
|
|||
TestFiles1[6] = "pyramid-adaptive-10-bframes.mkv";
|
||||
|
||||
for (int i = 0; i < 5; i++)
|
||||
TestFullDump1(TestFiles1[i], true);
|
||||
TestFullDump1(TestFiles1[3], true);
|
||||
/*
|
||||
TestFullDump1(TestFiles1[5], false);
|
||||
|
||||
|
|
|
@ -186,10 +186,7 @@ int main(int argc, char *argv[]) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
if (FFMS_Init()) {
|
||||
std::cout << std::endl << "Error: initialization failed" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
FFMS_Init();
|
||||
|
||||
if (Verbose)
|
||||
FFMS_SetLogLevel(AV_LOG_INFO);
|
||||
|
@ -211,6 +208,5 @@ int main(int argc, char *argv[]) {
|
|||
}
|
||||
|
||||
FFMS_DestroyFFIndex(Index);
|
||||
FFMS_DeInit();
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue