Add support for external at3plus decoders on MacOSX 64bit.

This commit is contained in:
Henrik Rydgård 2013-06-16 12:41:41 +02:00
parent f99caadec7
commit 5c14ec134c
6 changed files with 51 additions and 20 deletions

5
.gitignore vendored
View File

@ -60,3 +60,8 @@ local.properties
# For vim
*.swp
tags
libat3plusdecoder.dylib
libat3plusdecoder.so
at3plusdecoder.dll
at3plusdecoder64.dll

View File

@ -1,4 +1,4 @@
#ifdef _WIN32
#ifdef _WIN32
#include <Windows.h>
#else
#include <dlfcn.h>
@ -11,17 +11,31 @@
#include <string.h>
#include <string>
#include "base/logging.h"
#include "Core/Config.h"
#include "Common/FileUtil.h"
#include "Core/HW/atrac3plus.h"
#ifdef __APPLE__
#include "TargetConditionals.h"
#if TARGET_OS_MAC
#define MACOSX
#endif
#endif
extern std::string externalDirectory;
namespace Atrac3plus_Decoder {
#ifdef _WIN32
bool IsSupported() {
#if (defined(_WIN32) && (defined(_M_IX86) || defined(_M_X64))) || defined(ARMEABI) || defined(ARMEABI_V7A) || defined(MACOSX)
return true;
#else
return false;
#endif
}
#ifdef _WIN32
HMODULE hlib = 0;
#else
static void *so;
@ -43,6 +57,8 @@ namespace Atrac3plus_Decoder {
#else
return "at3plusdecoder.dll";
#endif
#elif defined(__APPLE__)
return "libat3plusdecoder.dylib";
#else
return "libat3plusdecoder.so";
#endif
@ -67,7 +83,7 @@ namespace Atrac3plus_Decoder {
// Other platforms can't.
return false;
}
bool IsInstalled() {
return File::Exists(GetInstalledFilename());
}
@ -105,8 +121,8 @@ namespace Atrac3plus_Decoder {
// Okay, we're screwed. Let's bail.
return -1;
}
#ifdef _WIN32
#ifdef _WIN32
#ifdef _M_X64
hlib = LoadLibraryA(GetInstalledFilename().c_str());
@ -121,7 +137,6 @@ namespace Atrac3plus_Decoder {
return -1;
}
#else
std::string filename = GetInstalledFilename();
ILOG("Attempting to load atrac3plus decoder from %s", filename.c_str());
@ -149,7 +164,7 @@ namespace Atrac3plus_Decoder {
}
int Shutdown() {
#ifdef _WIN32
#ifdef _WIN32
if (hlib) {
FreeLibrary(hlib);
hlib = 0;

View File

@ -2,7 +2,7 @@
#define _ATRAC3PLUS_DECODER_
namespace Atrac3plus_Decoder {
bool IsSupported();
bool IsInstalled();
bool CanAutoInstall();
bool DoAutoInstall();
@ -88,4 +88,4 @@ namespace Atrac3plus_Decoder {
};
}
#endif // _ATRAC3PLUS_DECODER_
#endif // _ATRAC3PLUS_DECODER_

View File

@ -700,15 +700,13 @@ void AudioScreen::render() {
}
#if (defined(_WIN32) && (defined(_M_IX86) || defined(_M_X64))) || defined(ARMEABI) || defined(ARMEABI_V7A)
VLinear vlinear(30, 300, 20);
if (!Atrac3plus_Decoder::IsInstalled() && UIButton(GEN_ID, vlinear, 400, 0, a->T("Download Atrac3+ plugin"), ALIGN_LEFT)) {
screenManager()->push(new PluginScreen());
if (Atrac3plus_Decoder::IsSupported()) {
VLinear vlinear(30, 300, 20);
if (!Atrac3plus_Decoder::IsInstalled() && UIButton(GEN_ID, vlinear, 400, 0, a->T("Download Atrac3+ plugin"), ALIGN_LEFT)) {
screenManager()->push(new PluginScreen());
}
}
#endif
UIEnd();
}

View File

@ -356,7 +356,7 @@ void NativeInitGraphics() {
screenManager = new ScreenManager();
if (boot_filename.empty()) {
#if (defined(_WIN32) && (defined(_M_IX86) || defined(_M_X64))) || defined(ARMEABI) || defined(ARMEABI_V7A)
#if (defined(_WIN32) && (defined(_M_IX86) || defined(_M_X64))) || defined(ARMEABI) || defined(ARMEABI_V7A) || (defined(MACOSX) && defined(_M_IX64))
if (Atrac3plus_Decoder::CanAutoInstall()) {
Atrac3plus_Decoder::DoAutoInstall();
screenManager->switchScreen(new LogoScreen(boot_filename));

View File

@ -25,6 +25,13 @@
#include "UI/ui_atlas.h"
#include "Core/HW/atrac3plus.h"
#ifdef __APPLE__
#include "TargetConditionals.h"
#if TARGET_OS_MAC
#define MACOSX
#endif
#endif
void DrawBackground(float alpha);
void PluginScreen::DrawBackground(UIContext &dc)
@ -108,17 +115,23 @@ void PluginScreen::update(InputState &input) {
abi = "armeabi";
#elif defined(ARMEABI_V7A)
abi = "armeabi-v7a";
#elif defined(MACOSX)
abi = "MacOSX64";
#endif
const char *notSupportedText = p->T("SorryNoDownload", "Sorry, there is no automatic download of the decoder\navailable for this platform.");
if (!abi.empty()) {
at3plusdecoderUrl_ = root->getString(abi.c_str(), "");
if (at3plusdecoderUrl_.empty()) {
buttonDownload_->SetEnabled(false);
tvDescription_->SetText(notSupportedText);
} else {
buttonDownload_->SetEnabled(true);
const char *notInstalledText = p->T("To download and install", "To download and install Mai's Atrac3+ decoding support, click Download.\n");
const char *reInstallText = p->T("Already installed", "Mai's Atrac3+ decoder already installed.\nWould you like to redownload and reinstall it?\n");
const char *notInstalledText = p->T("To download and install", "To download and install Mai's Atrac3+ decoding\n support, click Download.");
const char *reInstallText = p->T("Already installed", "Mai's Atrac3+ decoder already installed.\nWould you like to redownload and reinstall it?");
tvDescription_->SetText(Atrac3plus_Decoder::IsInstalled() ? reInstallText : notInstalledText);
}
} else {
tvDescription_->SetText(notSupportedText);
}
}