Audio on/off changes, android gui fixes, android crash bugfix (1st step in internetlogindialog)

This commit is contained in:
doitux
2012-12-20 09:11:57 +01:00
parent 51ad6c5580
commit 31c3771d59
16 changed files with 156 additions and 64 deletions
+7 -4
View File
@@ -157,8 +157,7 @@ HEADERS += src/engine/game.h \
src/engine/network_engine/clienthand.h \ src/engine/network_engine/clienthand.h \
src/engine/network_engine/clientplayer.h \ src/engine/network_engine/clientplayer.h \
src/engine/network_engine/clientbero.h \ src/engine/network_engine/clientbero.h \
src/gui/qt/chattools/chattools.h \ src/gui/qt/chattools/chattools.h \
src/gui/qt/sound/sdlplayer.h \
src/gui/qt/gametable/gametableimpl.h \ src/gui/qt/gametable/gametableimpl.h \
src/gui/qt/gametable/mycardspixmaplabel.h \ src/gui/qt/gametable/mycardspixmaplabel.h \
src/gui/qt/gametable/mysetlabel.h \ src/gui/qt/gametable/mysetlabel.h \
@@ -236,8 +235,7 @@ HEADERS += src/engine/game.h \
} }
SOURCES += src/pokerth.cpp \ SOURCES += src/pokerth.cpp \
src/gui/qt/chattools/chattools.cpp \ src/gui/qt/chattools/chattools.cpp \
src/gui/qt/sound/sdlplayer.cpp \
src/gui/qt/guiwrapper.cpp \ src/gui/qt/guiwrapper.cpp \
src/gui/qt/qttools/qttoolswrapper.cpp \ src/gui/qt/qttools/qttoolswrapper.cpp \
src/gui/qt/qttools/qthelper/qthelper.cpp \ src/gui/qt/qttools/qthelper/qthelper.cpp \
@@ -636,6 +634,11 @@ android{
src/gui/qt/sound/androidsoundeffect.cpp src/gui/qt/sound/androidsoundeffect.cpp
} }
!android{
HEADERS += src/gui/qt/sound/sdlplayer.h
SOURCES += src/gui/qt/sound/sdlplayer.cpp
}
maemo{ maemo{
DEFINES += MAEMO DEFINES += MAEMO
} }
+2 -2
View File
@@ -42,7 +42,6 @@
#include "cardsvalue.h" #include "cardsvalue.h"
#include "configfile.h" #include "configfile.h"
#include "sdlplayer.h"
#include "soundevents.h" #include "soundevents.h"
#include "gametablestylereader.h" #include "gametablestylereader.h"
#include "carddeckstylereader.h" #include "carddeckstylereader.h"
@@ -690,7 +689,6 @@ void gameTableImpl::applySettings(settingsDialogImpl* mySettingsDialog)
//apply game table style //apply game table style
myGameTableStyle->readStyleFile(QString::fromUtf8(myConfig->readConfigString("CurrentGameTableStyle").c_str())); myGameTableStyle->readStyleFile(QString::fromUtf8(myConfig->readConfigString("CurrentGameTableStyle").c_str()));
#ifdef GUI_800x480 #ifdef GUI_800x480
//cardschancemonitor show/hide //cardschancemonitor show/hide
if (!myConfig->readConfigInt("ShowCardsChanceMonitor")) { if (!myConfig->readConfigInt("ShowCardsChanceMonitor")) {
@@ -838,6 +836,8 @@ void gameTableImpl::applySettings(settingsDialogImpl* mySettingsDialog)
refreshGroupbox(); refreshGroupbox();
provideMyActions(); provideMyActions();
} }
mySoundEventHandler->reInitSoundEngine();
} }
void gameTableImpl::initGui(int speed) void gameTableImpl::initGui(int speed)
@@ -50,7 +50,7 @@
<item> <item>
<widget class="QPushButton" name="pushButton_createGame"> <widget class="QPushButton" name="pushButton_createGame">
<property name="styleSheet"> <property name="styleSheet">
<string notr="true">QObject {font: bold 20px}</string> <string notr="true">QObject {font: bold 30px}</string>
</property> </property>
<property name="text"> <property name="text">
<string>Create Game</string> <string>Create Game</string>
@@ -159,7 +159,7 @@
<string>Registered players only</string> <string>Registered players only</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="../resources/pokerth.qrc"> <iconset resource="../resources/pokerth_android.qrc">
<normaloff>:/gfx/registered.png</normaloff>:/gfx/registered.png</iconset> <normaloff>:/gfx/registered.png</normaloff>:/gfx/registered.png</iconset>
</property> </property>
</item> </item>
@@ -168,7 +168,7 @@
<string>Invited players only</string> <string>Invited players only</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="../resources/pokerth.qrc"> <iconset resource="../resources/pokerth_android.qrc">
<normaloff>:/gfx/list_add_user.png</normaloff>:/gfx/list_add_user.png</iconset> <normaloff>:/gfx/list_add_user.png</normaloff>:/gfx/list_add_user.png</iconset>
</property> </property>
</item> </item>
@@ -177,7 +177,7 @@
<string>Ranking game</string> <string>Ranking game</string>
</property> </property>
<property name="icon"> <property name="icon">
<iconset resource="../resources/pokerth.qrc"> <iconset resource="../resources/pokerth_android.qrc">
<normaloff>:/gfx/cup.png</normaloff>:/gfx/cup.png</iconset> <normaloff>:/gfx/cup.png</normaloff>:/gfx/cup.png</iconset>
</property> </property>
</item> </item>
@@ -441,7 +441,7 @@
<tabstop>pushButton_createGame</tabstop> <tabstop>pushButton_createGame</tabstop>
</tabstops> </tabstops>
<resources> <resources>
<include location="../resources/pokerth.qrc"/> <include location="../resources/pokerth_android.qrc"/>
</resources> </resources>
<connections> <connections>
<connection> <connection>
@@ -255,6 +255,19 @@
</property> </property>
</widget> </widget>
</item> </item>
<item row="5" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout> </layout>
</widget> </widget>
</item> </item>
@@ -265,6 +278,8 @@
<tabstop>spinBox_startCash</tabstop> <tabstop>spinBox_startCash</tabstop>
<tabstop>radioButton_useSavedBlindsSettings</tabstop> <tabstop>radioButton_useSavedBlindsSettings</tabstop>
<tabstop>radioButton_changeBlindsSettings</tabstop> <tabstop>radioButton_changeBlindsSettings</tabstop>
<tabstop>spinBox_netTimeOutPlayerAction</tabstop>
<tabstop>spinBox_netDelayBetweenHands</tabstop>
<tabstop>pushButton_createGame</tabstop> <tabstop>pushButton_createGame</tabstop>
</tabstops> </tabstops>
<resources/> <resources/>
@@ -58,6 +58,9 @@
<property name="text"> <property name="text">
<string>Username:</string> <string>Username:</string>
</property> </property>
<property name="buddy">
<cstring>lineEdit_username</cstring>
</property>
</widget> </widget>
</item> </item>
<item row="0" column="1"> <item row="0" column="1">
@@ -72,6 +75,9 @@
<property name="text"> <property name="text">
<string>Password:</string> <string>Password:</string>
</property> </property>
<property name="buddy">
<cstring>lineEdit_password</cstring>
</property>
</widget> </widget>
</item> </item>
<item row="1" column="1"> <item row="1" column="1">
@@ -131,6 +137,9 @@
<property name="text"> <property name="text">
<string>Login</string> <string>Login</string>
</property> </property>
<property name="autoDefault">
<bool>false</bool>
</property>
</widget> </widget>
</item> </item>
</layout> </layout>
@@ -185,7 +185,7 @@
</layout> </layout>
</item> </item>
<item row="2" column="0" rowspan="2" colspan="2"> <item row="2" column="0" rowspan="2" colspan="2">
<layout class="QHBoxLayout" name="horizontalLayout_2"> <layout class="QHBoxLayout" name="horizontalLayout_animation">
<item> <item>
<widget class="QLabel" name="label_animation"> <widget class="QLabel" name="label_animation">
<property name="text"> <property name="text">
@@ -233,6 +233,19 @@
</item> </item>
</layout> </layout>
</item> </item>
<item>
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item> <item>
<layout class="QHBoxLayout" name="horizontalLayout_5"> <layout class="QHBoxLayout" name="horizontalLayout_5">
<item> <item>
@@ -19,11 +19,13 @@
#include "configfile.h" #include "configfile.h"
#include <tools.h> #include <tools.h>
#include <QtCore> #include <QtCore>
#include <QtGui>
internetGameLoginDialogImpl::internetGameLoginDialogImpl(QWidget *parent, ConfigFile *c) : internetGameLoginDialogImpl::internetGameLoginDialogImpl(QWidget *parent, ConfigFile *c) :
QDialog(parent), myConfig(c) QDialog(parent), myConfig(c)
{ {
setupUi(this); setupUi(this);
this->installEventFilter(this);
//html stuff //html stuff
QString createAccount(QString("<a href='http://create-gaming-account.pokerth.net'>%1</a>").arg(tr("Create new user account"))); QString createAccount(QString("<a href='http://create-gaming-account.pokerth.net'>%1</a>").arg(tr("Create new user account")));
@@ -147,3 +149,27 @@ void internetGameLoginDialogImpl::okButtonCheck()
} }
} }
bool internetGameLoginDialogImpl::eventFilter(QObject *obj, QEvent *event)
{
QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
#ifdef ANDROID
//androi hack for crash bug (hopefully useless from necessitas beta2)
if (event->type() == QEvent::KeyPress && keyEvent->key() == Qt::Key_Return) {
if(lineEdit_username->hasFocus()) {
lineEdit_password->setFocus();
}
if(lineEdit_password->hasFocus()) {
QTimer::singleShot(1000, this, SLOT(clickLoginButton()));
}
event->ignore();
return false;
} else {
// pass the event on to the parent class
return QDialog::eventFilter(obj, event);
}
#else
return QDialog::eventFilter(obj, event);
#endif
}
@@ -35,11 +35,13 @@ public:
void exec(); void exec();
void accept(); void accept();
bool eventFilter(QObject *obj, QEvent *event);
public slots: public slots:
void regUserToggled(bool); void regUserToggled(bool);
void guestUserToggled(bool); void guestUserToggled(bool);
void okButtonCheck(); void okButtonCheck();
void clickLoginButton() { pushButton_login->click(); }
private: private:
+43 -18
View File
@@ -1,25 +1,47 @@
#include "androidaudio.h" #include "androidaudio.h"
#include "androidsoundeffect.h" #include "androidsoundeffect.h"
#include "configfile.h"
#include <QDebug> #include <QDebug>
AndroidAudio::AndroidAudio(QObject *parent) : AndroidAudio::AndroidAudio(ConfigFile *c, QObject *parent) :
QObject(parent), mEngineObject(NULL), mEngineEngine(NULL), mOutputMixObject(NULL), mSounds(), mSoundCount(0), mPlayerObject(NULL) QObject(parent), mEngineObject(NULL), mEngineEngine(NULL), mOutputMixObject(NULL), mSounds(), mSoundCount(0), mPlayerObject(NULL), myConfig(c), audioEnabled(FALSE)
{ {
createEngine(); initAudio();
startSoundPlayer();
} }
AndroidAudio::~AndroidAudio() AndroidAudio::~AndroidAudio()
{ {
destroyEngine(); closeAudio();
}
for (int32_t i = 0; i < mSoundCount; ++i) {
qDeleteAll(mSounds);
void AndroidAudio::initAudio()
{
if (!audioEnabled && myConfig->readConfigInt("PlaySoundEffects")) {
createEngine();
startSoundPlayer();
audioEnabled = TRUE;
} }
} }
void AndroidAudio::closeAudio()
{
if(audioEnabled) {
destroyEngine();
for (int32_t i = 0; i < mSoundCount; ++i) {
qDeleteAll(mSounds);
}
audioEnabled = FALSE;
}
}
void AndroidAudio::reInit()
{
initAudio();
}
// create the engine and output mix objects // create the engine and output mix objects
void AndroidAudio::createEngine() void AndroidAudio::createEngine()
{ {
@@ -73,19 +95,19 @@ void AndroidAudio::destroyEngine()
void AndroidAudio::registerSound(const QString& path, const QString& name) void AndroidAudio::registerSound(const QString& path, const QString& name)
{ {
qDebug() << "registerSound:" << path << name; // qDebug() << "registerSound:" << path << name;
AndroidSoundEffect *lSound = new AndroidSoundEffect(path, this); AndroidSoundEffect *lSound = new AndroidSoundEffect(path, this);
qDebug() << "registerSound:created"; // qDebug() << "registerSound:created";
mSounds[name] = lSound; mSounds[name] = lSound;
qDebug() << "registerSound:loading"; // qDebug() << "registerSound:loading";
lSound->load(); lSound->load();
qDebug() << "registerSound:loaded"; // qDebug() << "registerSound:loaded";
} }
void AndroidAudio::startSoundPlayer() void AndroidAudio::startSoundPlayer()
{ {
qDebug() << "Starting Sound Player"; // qDebug() << "Starting Sound Player";
SLresult lRes; SLresult lRes;
@@ -121,12 +143,12 @@ void AndroidAudio::startSoundPlayer()
const SLInterfaceID lSoundPlayerIIDs[] = { SL_IID_PLAY, SL_IID_BUFFERQUEUE }; const SLInterfaceID lSoundPlayerIIDs[] = { SL_IID_PLAY, SL_IID_BUFFERQUEUE };
const SLboolean lSoundPlayerReqs[] = { SL_BOOLEAN_TRUE, SL_BOOLEAN_TRUE }; const SLboolean lSoundPlayerReqs[] = { SL_BOOLEAN_TRUE, SL_BOOLEAN_TRUE };
qDebug() << "Configured Sound Player"; // qDebug() << "Configured Sound Player";
lRes = (*mEngineEngine)->CreateAudioPlayer(mEngineEngine, &mPlayerObject, &lDataSource, &lDataSink, lSoundPlayerIIDCount, lSoundPlayerIIDs, lSoundPlayerReqs); lRes = (*mEngineEngine)->CreateAudioPlayer(mEngineEngine, &mPlayerObject, &lDataSource, &lDataSink, lSoundPlayerIIDCount, lSoundPlayerIIDs, lSoundPlayerReqs);
Q_ASSERT(SL_RESULT_SUCCESS == lRes); Q_ASSERT(SL_RESULT_SUCCESS == lRes);
qDebug() << "Created Sound Player"; // qDebug() << "Created Sound Player";
lRes = (*mPlayerObject)->Realize(mPlayerObject, SL_BOOLEAN_FALSE); lRes = (*mPlayerObject)->Realize(mPlayerObject, SL_BOOLEAN_FALSE);
Q_ASSERT(SL_RESULT_SUCCESS == lRes); Q_ASSERT(SL_RESULT_SUCCESS == lRes);
@@ -141,13 +163,16 @@ void AndroidAudio::startSoundPlayer()
lRes = (*mPlayerPlay)->SetPlayState(mPlayerPlay, SL_PLAYSTATE_PLAYING); lRes = (*mPlayerPlay)->SetPlayState(mPlayerPlay, SL_PLAYSTATE_PLAYING);
Q_ASSERT(SL_RESULT_SUCCESS == lRes); Q_ASSERT(SL_RESULT_SUCCESS == lRes);
qDebug() << "Created Buffer Player"; // qDebug() << "Created Buffer Player";
} }
void AndroidAudio::playSound(const std::string& name, int i) { void AndroidAudio::playSound(const std::string& name, int i) {
this->registerSound(QString(":/android/android-data/sounds/default/"+QString::fromStdString(name)+".wav"), QString::fromStdString(name)); if(audioEnabled && myConfig->readConfigInt("PlaySoundEffects")) {
this->reallyPlaySound(QString::fromStdString(name));
this->registerSound(QString(":/android/android-data/sounds/default/"+QString::fromStdString(name)+".wav"), QString::fromStdString(name));
this->reallyPlaySound(QString::fromStdString(name));
}
} }
void AndroidAudio::reallyPlaySound(const QString& name) void AndroidAudio::reallyPlaySound(const QString& name)
+8 -1
View File
@@ -13,11 +13,13 @@
#include <android/asset_manager.h> #include <android/asset_manager.h>
#include <android/asset_manager_jni.h> #include <android/asset_manager_jni.h>
class ConfigFile;
class AndroidAudio : public QObject class AndroidAudio : public QObject
{ {
Q_OBJECT Q_OBJECT
public: public:
explicit AndroidAudio(QObject *parent = 0); explicit AndroidAudio(ConfigFile *c, QObject *parent = 0);
~AndroidAudio(); ~AndroidAudio();
signals: signals:
@@ -27,6 +29,9 @@ public slots:
void registerSound(const QString& path, const QString &name); void registerSound(const QString& path, const QString &name);
void reallyPlaySound(const QString& name); void reallyPlaySound(const QString& name);
void playSound(const std::string& name, int i); void playSound(const std::string& name, int i);
void initAudio();
void closeAudio();
void reInit();
private: private:
void createEngine(); void createEngine();
@@ -48,6 +53,8 @@ private:
QMap<QString, AndroidSoundEffect*> mSounds; QMap<QString, AndroidSoundEffect*> mSounds;
int32_t mSoundCount; int32_t mSoundCount;
ConfigFile *myConfig;
bool audioEnabled;
}; };
#endif // ANDROIDAUDIO_H #endif // ANDROIDAUDIO_H
+10 -10
View File
@@ -19,7 +19,7 @@ bool AndroidSoundEffect::load()
{ {
QFile lSoundFile(mPath); QFile lSoundFile(mPath);
qDebug() << "opening:" << mPath; // qDebug() << "opening:" << mPath;
if (!lSoundFile.open(QIODevice::ReadOnly)) { if (!lSoundFile.open(QIODevice::ReadOnly)) {
qDebug() << "Could not open: " << mPath; qDebug() << "Could not open: " << mPath;
@@ -27,7 +27,7 @@ bool AndroidSoundEffect::load()
} }
// parse WAV file // parse WAV file
qDebug() << " reading header:"; // qDebug() << " reading header:";
char id[4]; char id[4];
lSoundFile.read(id, 4); lSoundFile.read(id, 4);
@@ -39,7 +39,7 @@ bool AndroidSoundEffect::load()
int size = 0; int size = 0;
lSoundFile.read((char *)&size, 4); lSoundFile.read((char *)&size, 4);
qDebug() << " size:" << size; // qDebug() << " size:" << size;
lSoundFile.read(id, 4); lSoundFile.read(id, 4);
if( strncmp(id, "WAVE", 4) != 0 ) { if( strncmp(id, "WAVE", 4) != 0 ) {
@@ -52,29 +52,29 @@ bool AndroidSoundEffect::load()
int format_length = 0; int format_length = 0;
lSoundFile.read((char *)&format_length, 4); lSoundFile.read((char *)&format_length, 4);
qDebug() << " format_length:" << format_length; // qDebug() << " format_length:" << format_length;
short format_tag = 0; short format_tag = 0;
lSoundFile.read((char *)&format_tag, 2); lSoundFile.read((char *)&format_tag, 2);
short n_channels = 0; short n_channels = 0;
lSoundFile.read((char *)&n_channels, 2); lSoundFile.read((char *)&n_channels, 2);
qDebug() << " n_channels:" << n_channels; // qDebug() << " n_channels:" << n_channels;
int sample_rate = 0; int sample_rate = 0;
lSoundFile.read((char *)&sample_rate, 4); lSoundFile.read((char *)&sample_rate, 4);
qDebug() << " sample_rate:" << sample_rate; // qDebug() << " sample_rate:" << sample_rate;
int avg_bytes_sec = 0; int avg_bytes_sec = 0;
lSoundFile.read((char *)&avg_bytes_sec, 4); lSoundFile.read((char *)&avg_bytes_sec, 4);
qDebug() << " avg_bytes_sec:" << avg_bytes_sec; // qDebug() << " avg_bytes_sec:" << avg_bytes_sec;
short block_align = 0; short block_align = 0;
lSoundFile.read((char *)&block_align, 2); lSoundFile.read((char *)&block_align, 2);
short bits_per_sample = 0; short bits_per_sample = 0;
lSoundFile.read((char *)&bits_per_sample, 2); lSoundFile.read((char *)&bits_per_sample, 2);
qDebug() << " bits_per_sample:" << bits_per_sample; // qDebug() << " bits_per_sample:" << bits_per_sample;
lSoundFile.read(id, 4); lSoundFile.read(id, 4);
if( strncmp(id, "data", 4) != 0 ) { if( strncmp(id, "data", 4) != 0 ) {
@@ -85,7 +85,7 @@ bool AndroidSoundEffect::load()
lSoundFile.read((char *)&mLength, 4); lSoundFile.read((char *)&mLength, 4);
qDebug() << " reading data:" << mLength; // qDebug() << " reading data:" << mLength;
mBuffer = (char*)malloc((mLength)); mBuffer = (char*)malloc((mLength));
@@ -98,7 +98,7 @@ bool AndroidSoundEffect::load()
return false; return false;
} }
qDebug() << " closing:"; // qDebug() << " closing:";
lSoundFile.close(); lSoundFile.close();
return true; return true;
} }
+7 -16
View File
@@ -17,40 +17,31 @@
*****************************************************************************/ *****************************************************************************/
#include "sdlplayer.h" #include "sdlplayer.h"
#ifndef ANDROID
#if (defined __APPLE__) #if (defined __APPLE__)
#include <SDL.h> #include <SDL.h>
#else #else
#include <SDL/SDL.h> #include <SDL/SDL.h>
#endif #endif
#endif
using namespace std; using namespace std;
SDLPlayer::SDLPlayer(ConfigFile *c) SDLPlayer::SDLPlayer(ConfigFile *c)
#ifndef ANDROID
: sound(NULL), soundData(NULL), currentChannel(0), audioEnabled(FALSE), myConfig(c) : sound(NULL), soundData(NULL), currentChannel(0), audioEnabled(FALSE), myConfig(c)
#endif
{ {
#ifndef ANDROID
myAppDataPath = QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str()); myAppDataPath = QString::fromUtf8(myConfig->readConfigString("AppDataDir").c_str());
SDL_Init(SDL_INIT_AUDIO); SDL_Init(SDL_INIT_AUDIO);
initAudio(); initAudio();
#endif
} }
SDLPlayer::~SDLPlayer() SDLPlayer::~SDLPlayer()
{ {
#ifndef ANDROID
closeAudio(); closeAudio();
SDL_Quit(); SDL_Quit();
#endif
} }
void SDLPlayer::initAudio() void SDLPlayer::initAudio()
{ {
#ifndef ANDROID
if (!audioEnabled && myConfig->readConfigInt("PlaySoundEffects")) { if (!audioEnabled && myConfig->readConfigInt("PlaySoundEffects")) {
int audio_rate = 44100; int audio_rate = 44100;
Uint16 audio_format = AUDIO_S16; /* 16-bit stereo */ Uint16 audio_format = AUDIO_S16; /* 16-bit stereo */
@@ -66,12 +57,10 @@ void SDLPlayer::initAudio()
qDebug() << "Mix_OpenAudio() was not successfull, no sound possible :("; qDebug() << "Mix_OpenAudio() was not successfull, no sound possible :(";
} }
} }
#endif
} }
void SDLPlayer::playSound(string audioString, int playerID) void SDLPlayer::playSound(string audioString, int playerID)
{ {
#ifndef ANDROID
if(audioEnabled && myConfig->readConfigInt("PlaySoundEffects")) { if(audioEnabled && myConfig->readConfigInt("PlaySoundEffects")) {
QFile myFile(myAppDataPath + "sounds/default/" + QString::fromStdString(audioString)+".wav"); QFile myFile(myAppDataPath + "sounds/default/" + QString::fromStdString(audioString)+".wav");
@@ -142,13 +131,10 @@ void SDLPlayer::playSound(string audioString, int playerID)
currentChannel = Mix_PlayChannel(-1, sound,0); currentChannel = Mix_PlayChannel(-1, sound,0);
} }
} }
#endif
} }
void SDLPlayer::closeAudio() void SDLPlayer::closeAudio()
{ { if(audioEnabled) {
#ifndef ANDROID
if(audioEnabled) {
Mix_HaltChannel(currentChannel); Mix_HaltChannel(currentChannel);
Mix_FreeChunk(sound); Mix_FreeChunk(sound);
sound = NULL; sound = NULL;
@@ -158,5 +144,10 @@ void SDLPlayer::closeAudio()
qDebug() << "Mix_CloseAudio()"; qDebug() << "Mix_CloseAudio()";
audioEnabled = false; audioEnabled = false;
} }
#endif }
void SDLPlayer::reInitAudio()
{
closeAudio();
initAudio();
} }
+1 -6
View File
@@ -23,12 +23,10 @@
#include "configfile.h" #include "configfile.h"
#include <string> #include <string>
#ifndef ANDROID
#ifdef __APPLE__ #ifdef __APPLE__
#include <SDL_mixer.h> #include <SDL_mixer.h>
#else #else
#include <SDL/SDL_mixer.h> #include <SDL/SDL_mixer.h>
#endif
#endif #endif
struct Mix_Chunk; struct Mix_Chunk;
@@ -48,18 +46,15 @@ public:
void initAudio(); void initAudio();
void playSound(std::string, int playerID); void playSound(std::string, int playerID);
void closeAudio(); void closeAudio();
void reInitAudio();
private: private:
#ifndef ANDROID
Mix_Chunk *sound; Mix_Chunk *sound;
unsigned char *soundData; unsigned char *soundData;
int currentChannel; int currentChannel;
bool audioEnabled; bool audioEnabled;
ConfigFile *myConfig; ConfigFile *myConfig;
QString myAppDataPath; QString myAppDataPath;
#endif
}; };
#endif #endif
+6 -1
View File
@@ -18,7 +18,7 @@ SoundEvents::SoundEvents(ConfigFile *c): myConfig(c), lastSBValue(0), lastSBLeve
{ {
#ifdef ANDROID #ifdef ANDROID
myPlayer = new AndroidAudio(); myPlayer = new AndroidAudio(myConfig);
#else #else
myPlayer = new SDLPlayer(myConfig); myPlayer = new SDLPlayer(myConfig);
#endif #endif
@@ -30,6 +30,11 @@ SoundEvents::~SoundEvents()
myPlayer->deleteLater(); myPlayer->deleteLater();
} }
void SoundEvents::reInitSoundEngine()
{
myPlayer->reInit();
}
void SoundEvents::blindsWereSet(int sB) void SoundEvents::blindsWereSet(int sB)
{ {
if(newGameNow) { if(newGameNow) {
+1
View File
@@ -21,6 +21,7 @@ public:
void blindsWereSet(int sB); void blindsWereSet(int sB);
void newGameStarts(); void newGameStarts();
void playSound(std::string audioString, int playerID); void playSound(std::string audioString, int playerID);
void reInitSoundEngine();
protected: protected:
// Prevent copy construction. // Prevent copy construction.