mirror of
https://github.com/glest/glest-source.git
synced 2025-08-30 03:09:49 +02:00
- attempt for better support for older versions of libvlc
This commit is contained in:
@@ -241,6 +241,10 @@ IF(BUILD_MEGAGLEST_MODEL_VIEWER OR BUILD_MEGAGLEST_MAP_EDITOR OR BUILD_MEGAGLEST
|
||||
IF(LIBVLC_VERSION_PRE_V2)
|
||||
ADD_DEFINITIONS(-DLIBVLC_VERSION_PRE_2)
|
||||
ENDIF()
|
||||
IF(LIBVLC_VERSION_PRE_1_1_13)
|
||||
ADD_DEFINITIONS(-DLIBVLC_VERSION_PRE_1_1_13)
|
||||
ENDIF()
|
||||
|
||||
ELSE()
|
||||
MESSAGE(STATUS "**WARNING: LIBVLC NOT found so intro videos are NOT supported.")
|
||||
ENDIF()
|
||||
|
@@ -24,31 +24,31 @@
|
||||
#endif
|
||||
|
||||
#if defined(WIN32)
|
||||
/**
|
||||
* @param location The location of the registry key. For example "Software\\Bethesda Softworks\\Morrowind"
|
||||
* @param name the name of the registry key, for example "Installed Path"
|
||||
* @return the value of the key or an empty string if an error occured.
|
||||
*/
|
||||
std::string getRegKey(const std::string& location, const std::string& name){
|
||||
HKEY key;
|
||||
CHAR value[1024];
|
||||
DWORD bufLen = 1024*sizeof(CHAR);
|
||||
long ret;
|
||||
ret = RegOpenKeyExA(HKEY_LOCAL_MACHINE, location.c_str(), 0, KEY_QUERY_VALUE, &key);
|
||||
if( ret != ERROR_SUCCESS ){
|
||||
return std::string();
|
||||
}
|
||||
ret = RegQueryValueExA(key, name.c_str(), 0, 0, (LPBYTE) value, &bufLen);
|
||||
RegCloseKey(key);
|
||||
if ( (ret != ERROR_SUCCESS) || (bufLen > 1024*sizeof(TCHAR)) ){
|
||||
return std::string();
|
||||
}
|
||||
string stringValue = value;
|
||||
size_t i = stringValue.length();
|
||||
while( i > 0 && stringValue[i-1] == '\0' ){
|
||||
--i;
|
||||
}
|
||||
return stringValue.substr(0,i);
|
||||
/**
|
||||
* @param location The location of the registry key. For example "Software\\Bethesda Softworks\\Morrowind"
|
||||
* @param name the name of the registry key, for example "Installed Path"
|
||||
* @return the value of the key or an empty string if an error occured.
|
||||
*/
|
||||
std::string getRegKey(const std::string& location, const std::string& name){
|
||||
HKEY key;
|
||||
CHAR value[1024];
|
||||
DWORD bufLen = 1024*sizeof(CHAR);
|
||||
long ret;
|
||||
ret = RegOpenKeyExA(HKEY_LOCAL_MACHINE, location.c_str(), 0, KEY_QUERY_VALUE, &key);
|
||||
if( ret != ERROR_SUCCESS ){
|
||||
return std::string();
|
||||
}
|
||||
ret = RegQueryValueExA(key, name.c_str(), 0, 0, (LPBYTE) value, &bufLen);
|
||||
RegCloseKey(key);
|
||||
if ( (ret != ERROR_SUCCESS) || (bufLen > 1024*sizeof(TCHAR)) ){
|
||||
return std::string();
|
||||
}
|
||||
string stringValue = value;
|
||||
size_t i = stringValue.length();
|
||||
while( i > 0 && stringValue[i-1] == '\0' ){
|
||||
--i;
|
||||
}
|
||||
return stringValue.substr(0,i);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -106,7 +106,7 @@ static void display(void *data, void *id) {
|
||||
(void) data;
|
||||
}
|
||||
|
||||
#if defined(HAS_LIBVLC) && defined(LIBVLC_VERSION_PRE_2)
|
||||
#if defined(HAS_LIBVLC) && defined(LIBVLC_VERSION_PRE_2) && defined(LIBVLC_VERSION_PRE_1_1_13)
|
||||
static void catchError(libvlc_exception_t *ex) {
|
||||
if(libvlc_exception_raised(ex)) {
|
||||
fprintf(stderr, "exception: %s\n", libvlc_exception_get_message(ex));
|
||||
@@ -160,7 +160,7 @@ void VideoPlayer::PlayVideo() {
|
||||
std::vector<const char *> vlc_argv;
|
||||
vlc_argv.push_back("--no-xlib" /* tell VLC to not use Xlib */);
|
||||
vlc_argv.push_back("--no-video-title-show");
|
||||
#ifdef LIBVLC_VERSION_PRE_2
|
||||
#if defined(LIBVLC_VERSION_PRE_2) && defined(LIBVLC_VERSION_PRE_1_1_13)
|
||||
char clock[64], cunlock[64], cdata[64];
|
||||
char cwidth[32], cheight[32], cpitch[32];
|
||||
/*
|
||||
@@ -235,7 +235,7 @@ void VideoPlayer::PlayVideo() {
|
||||
*/
|
||||
if(verboseEnabled) printf("Trying [%s]\n",getenv("VLC_PLUGIN_PATH"));
|
||||
|
||||
#ifdef LIBVLC_VERSION_PRE_2
|
||||
#if defined(LIBVLC_VERSION_PRE_2) && defined(LIBVLC_VERSION_PRE_1_1_13)
|
||||
libvlc_exception_t ex;
|
||||
libvlc_exception_init(&ex);
|
||||
|
||||
@@ -294,7 +294,7 @@ void VideoPlayer::PlayVideo() {
|
||||
*/
|
||||
|
||||
if(libvlc != NULL) {
|
||||
#ifdef LIBVLC_VERSION_PRE_2
|
||||
#if defined(LIBVLC_VERSION_PRE_2) && defined(LIBVLC_VERSION_PRE_1_1_13)
|
||||
m = libvlc_media_new(libvlc, filename.c_str(), &ex);
|
||||
catchError(&ex);
|
||||
|
||||
@@ -303,12 +303,12 @@ void VideoPlayer::PlayVideo() {
|
||||
#endif
|
||||
libvlc_media_release(m);
|
||||
|
||||
#ifndef LIBVLC_VERSION_PRE_2
|
||||
#if !defined(LIBVLC_VERSION_PRE_2) && !defined(LIBVLC_VERSION_PRE_1_1_13)
|
||||
libvlc_video_set_callbacks(mp, lock, unlock, display, &ctx);
|
||||
libvlc_video_set_format(mp, "RV16", width, height, this->surface->pitch);
|
||||
#endif
|
||||
|
||||
#ifdef LIBVLC_VERSION_PRE_2
|
||||
#if defined(LIBVLC_VERSION_PRE_2) && defined(LIBVLC_VERSION_PRE_1_1_13)
|
||||
libvlc_media_player_play(mp,&ex);
|
||||
#else
|
||||
libvlc_media_player_play(mp);
|
||||
@@ -384,7 +384,7 @@ void VideoPlayer::PlayVideo() {
|
||||
/*
|
||||
* Stop stream and clean up libVLC
|
||||
*/
|
||||
#ifdef LIBVLC_VERSION_PRE_2
|
||||
#if defined(LIBVLC_VERSION_PRE_2) && defined(LIBVLC_VERSION_PRE_1_1_13)
|
||||
libvlc_media_player_stop(mp,&ex);
|
||||
catchError(&ex);
|
||||
#else
|
||||
|
Reference in New Issue
Block a user