Trying to fix android build.
This commit is contained in:
+1
-7
@@ -383,7 +383,7 @@ unix:!mac {
|
||||
$${PREFIX}/lib64
|
||||
}
|
||||
android{
|
||||
LIB_DIRS = ../cmoss/bin/droid/lib/armv5
|
||||
LIB_DIRS = $${PREFIX}/lib/armv5
|
||||
}
|
||||
BOOST_FS = boost_filesystem \
|
||||
boost_filesystem-mt
|
||||
@@ -598,12 +598,6 @@ gui_800x480 {
|
||||
android{
|
||||
# Use old boost::filesystem, because the new version requires std::wstring.
|
||||
DEFINES += BOOST_FILESYSTEM_VERSION=2
|
||||
# If /usr/include is included, this will mess with the android sdk.
|
||||
INCLUDEPATH -= /usr/include
|
||||
LIBPATH -= /usr/lib
|
||||
# Include directory containing android builds of used libs.
|
||||
INCLUDEPATH += ../cmoss/bin/droid/include
|
||||
LIBPATH += ../cmoss/bin/droid/lib/armv5
|
||||
# sqlite3 is included directly.
|
||||
INCLUDEPATH += src/third_party/sqlite3
|
||||
}
|
||||
|
||||
@@ -245,10 +245,6 @@ mac{
|
||||
android{
|
||||
# Use old boost::filesystem, because the new version requires std::wstring.
|
||||
DEFINES += BOOST_FILESYSTEM_VERSION=2
|
||||
# If /usr/include is included, this will mess with the android sdk.
|
||||
INCLUDEPATH -= /usr/include
|
||||
# Include directory containing android builds of used libs.
|
||||
INCLUDEPATH += ../cmoss/bin/droid/include
|
||||
# sqlite3 is included directly.
|
||||
INCLUDEPATH += src/third_party/sqlite3
|
||||
SOURCES += src/third_party/sqlite3/sqlite3.c
|
||||
|
||||
@@ -17,33 +17,41 @@
|
||||
*****************************************************************************/
|
||||
#include "sdlplayer.h"
|
||||
|
||||
#ifndef __ANDROID_API__
|
||||
#if (defined __APPLE__)
|
||||
#include <SDL.h>
|
||||
#else
|
||||
#include <SDL/SDL.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
using namespace std;
|
||||
|
||||
SDLPlayer::SDLPlayer(ConfigFile *c)
|
||||
#ifndef __ANDROID_API__
|
||||
: soundData(NULL), currentChannel(0) , audioEnabled(0), myConfig(c)
|
||||
#endif
|
||||
{
|
||||
#ifndef __ANDROID_API__
|
||||
SDL_Init(SDL_INIT_AUDIO);
|
||||
initAudio();
|
||||
|
||||
myAppDataPath = QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str());
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
SDLPlayer::~SDLPlayer()
|
||||
{
|
||||
#ifndef __ANDROID_API__
|
||||
closeAudio();
|
||||
SDL_Quit();
|
||||
#endif
|
||||
}
|
||||
|
||||
void SDLPlayer::initAudio()
|
||||
{
|
||||
|
||||
#ifndef __ANDROID_API__
|
||||
if (!audioEnabled && myConfig->readConfigInt("PlaySoundEffects")) {
|
||||
int audio_rate = 44100;
|
||||
Uint16 audio_format = AUDIO_S16; /* 16-bit stereo */
|
||||
@@ -56,11 +64,12 @@ void SDLPlayer::initAudio()
|
||||
audioEnabled = 1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void SDLPlayer::playSound(string audioString, int playerID)
|
||||
{
|
||||
|
||||
#ifndef __ANDROID_API__
|
||||
if(audioEnabled && myConfig->readConfigInt("PlaySoundEffects")) {
|
||||
|
||||
QFile myFile(myAppDataPath + "sounds/default/" + QString::fromStdString(audioString)+".wav");
|
||||
@@ -142,11 +151,12 @@ void SDLPlayer::playSound(string audioString, int playerID)
|
||||
// currentChannel = Mix_PlayChannel(-1, sound,0);
|
||||
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void SDLPlayer::audioDone()
|
||||
{
|
||||
|
||||
#ifndef __ANDROID_API__
|
||||
if(audioEnabled) {
|
||||
Mix_HaltChannel(currentChannel);
|
||||
Mix_FreeChunk(sound);
|
||||
@@ -154,14 +164,16 @@ void SDLPlayer::audioDone()
|
||||
delete[] soundData;
|
||||
soundData = NULL;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void SDLPlayer::closeAudio()
|
||||
{
|
||||
|
||||
#ifndef __ANDROID_API__
|
||||
if(audioEnabled) {
|
||||
audioDone();
|
||||
Mix_CloseAudio();
|
||||
audioEnabled = false;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -21,15 +21,15 @@
|
||||
#define SDLPLAYER_H
|
||||
|
||||
#include "configfile.h"
|
||||
#include <string>
|
||||
|
||||
#if (defined __APPLE__)
|
||||
#ifndef __ANDROID_API__
|
||||
#ifdef __APPLE__
|
||||
#include <SDL_mixer.h>
|
||||
#else
|
||||
#include <SDL/SDL_mixer.h>
|
||||
#endif
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#endif
|
||||
|
||||
// struct Mix_Chunk;
|
||||
|
||||
@@ -52,6 +52,7 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
#ifndef __ANDROID_API__
|
||||
Mix_Chunk *sound;
|
||||
unsigned char *soundData;
|
||||
int currentChannel;
|
||||
@@ -60,7 +61,7 @@ private:
|
||||
|
||||
ConfigFile *myConfig;
|
||||
QString myAppDataPath;
|
||||
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user