diff --git a/pokerth.pro b/pokerth.pro
index ac217e58..4a5d3291 100755
--- a/pokerth.pro
+++ b/pokerth.pro
@@ -13,10 +13,10 @@ INCLUDEPATH += . \
src/engine/network_engine \
src/config \
src/core/tinyxml \
- src/sound \
src/gui/qt \
src/gui/qt/connecttoserverdialog \
src/core \
+ src/gui/qt/sound \
src/gui/qt/qttools \
src/gui/qt/qttools/qthelper \
src/gui/qt/mainwindow \
@@ -36,7 +36,6 @@ INCLUDEPATH += . \
DEPENDPATH += . \
src \
src/config \
- src/sound \
src/core \
src/engine \
src/gui \
@@ -47,6 +46,7 @@ DEPENDPATH += . \
src/engine/network_engine \
src/gui/qt \
src/net/common \
+ src/gui/qt/sound \
src/gui/qt/mainwindow \
src/gui/qt/mainwindow/startsplash \
src/gui/qt/mainwindow/log \
@@ -113,6 +113,7 @@ HEADERS += src/game.h \
src/engine/network_engine/clientpreflop.h \
src/engine/network_engine/clientriver.h \
src/engine/network_engine/clientturn.h \
+ src/gui/qt/sound/sdlplayer.h \
src/gui/qt/mainwindow/mainwindowimpl.h \
src/gui/qt/mainwindow/mycardspixmaplabel.h \
src/gui/qt/mainwindow/mysetlabel.h \
@@ -135,8 +136,7 @@ HEADERS += src/game.h \
src/gui/qttoolsinterface.h \
src/gui/qt/qttools/qttoolswrapper.h \
src/gui/qt/qttools/qthelper/qthelper.h \
- src/gui/generic/serverguiwrapper.h \
- src/sound/sdlplayer.h
+ src/gui/generic/serverguiwrapper.h
FORMS += src/gui/qt/mainwindow.ui \
src/gui/qt/aboutpokerth.ui \
src/gui/qt/connecttoserverdialog.ui \
@@ -206,6 +206,7 @@ SOURCES += src/game.cpp \
src/net/common/netcontext.cpp \
src/net/common/netexception.cpp \
src/net/common/receiverhelper.cpp \
+ src/gui/qt/sound/sdlplayer.cpp \
src/gui/qt/guiwrapper.cpp \
src/gui/qt/mainwindow/mainwindowimpl.cpp \
src/gui/qt/mainwindow/mycardspixmaplabel.cpp \
@@ -228,8 +229,7 @@ SOURCES += src/game.cpp \
src/gui/qttoolsinterface.cpp \
src/gui/qt/qttools/qttoolswrapper.cpp \
src/gui/qt/qttools/qthelper/qthelper.cpp \
- src/gui/generic/serverguiwrapper.cpp \
- src/sound/sdlplayer.cpp
+ src/gui/generic/serverguiwrapper.cpp
RESOURCES += src/gui/qt/resources.qrc
TRANSLATIONS = ts/pokerth_de.ts \
ts/pokerth_es.ts \
diff --git a/src/gui/qt/mainwindow/mainwindowimpl.cpp b/src/gui/qt/mainwindow/mainwindowimpl.cpp
index 3ea903c3..2d4b68ff 100755
--- a/src/gui/qt/mainwindow/mainwindowimpl.cpp
+++ b/src/gui/qt/mainwindow/mainwindowimpl.cpp
@@ -2499,7 +2499,7 @@ void mainWindowImpl::keyPressEvent ( QKeyEvent * event ) {
if (event->key() == Qt::Key_F11) { switchRightToolBox(); }
if (event->key() == Qt::Key_D) { setLabelArray[0]->startTimeOutAnimation(myConfig->readConfigInt("NetTimeOutPlayerAction")); } //f
if (event->key() == Qt::Key_E) { setLabelArray[0]->stopTimeOutAnimation(); } //f
- if (event->key() == Qt::Key_S) { if(myConfig->readConfigInt("PlaySoundEffects")) mySDLPlayer->playSound("beep"); } //s
+ if (event->key() == Qt::Key_S) { if(myConfig->readConfigInt("PlaySoundEffects")) mySDLPlayer->playSound("dealtwocards"); } //s
// if (event->key() == Qt::Key_W) { qApp->quit(); } //s
if (event->key() == 16777249) {
pushButton_break->click();
diff --git a/src/gui/qt/resources.qrc b/src/gui/qt/resources.qrc
index ee731066..12127770 100755
--- a/src/gui/qt/resources.qrc
+++ b/src/gui/qt/resources.qrc
@@ -72,7 +72,9 @@
resources/data/preflopValues
resources/data/flopValues
- resources/data/beep.ogg
+
+
+ resources/sounds/dealtwocards.wav
resources/fonts/VeraBd.ttf
diff --git a/src/gui/qt/resources/data/beep.ogg b/src/gui/qt/resources/data/beep.ogg
deleted file mode 100644
index 1c8d2741..00000000
Binary files a/src/gui/qt/resources/data/beep.ogg and /dev/null differ
diff --git a/src/gui/qt/resources/sounds/dealtwocards.wav b/src/gui/qt/resources/sounds/dealtwocards.wav
new file mode 100644
index 00000000..a9470bea
Binary files /dev/null and b/src/gui/qt/resources/sounds/dealtwocards.wav differ
diff --git a/src/gui/qt/sound/sdlplayer.cpp b/src/gui/qt/sound/sdlplayer.cpp
index a0cc87f6..84eaa0c9 100644
--- a/src/gui/qt/sound/sdlplayer.cpp
+++ b/src/gui/qt/sound/sdlplayer.cpp
@@ -15,8 +15,9 @@
using namespace std;
-SDLPlayer::SDLPlayer()
+SDLPlayer::SDLPlayer():QObject()
{
+ currentChannel = 0;
initAudio();
}
@@ -32,7 +33,7 @@ void SDLPlayer::initAudio() {
audio_format = AUDIO_S16; /* 16-bit stereo */
audio_channels = 2;
audio_buffers = 4096;
- music = NULL;
+ sound = NULL;
SDL_Init(SDL_INIT_AUDIO);
@@ -44,37 +45,33 @@ void SDLPlayer::playSound(string audioString) {
audioDone();
- cout << "play now" << endl;
- /* Actually loads up the music */
- string completeAudioString = audioString + ".wav";
- music = Mix_LoadMUS(completeAudioString.c_str());
+ QFile myFile(":sounds/resources/sounds/"+QString::fromStdString(audioString)+".wav");
+ if(!myFile.open(QIODevice::ReadOnly)) cout << "could not load wav" << endl;
+
+ QDataStream in(&myFile);
+ Uint8 *myMem = new Uint8[(int)myFile.size()];
+ in.readRawData( (char*)myMem, (int)myFile.size() );
+
+ sound = Mix_QuickLoad_WAV( myMem );
- /* This begins playing the music - the first argument is a
- pointer to Mix_Music structure, and the second is how many
- times you want it to loop (use -1 for infinite, and 0 to
- have it just play once) */
- Mix_PlayMusic(music, 0);
+ currentChannel = Mix_PlayChannel(0, sound,0);
- /* We want to know when our music has stopped playing so we
- can free it up and set 'music' back to NULL. SDL_Mixer
- provides us with a callback routine we can use to do
- exactly that */
-// Mix_HookMusicFinished(mainWindowImpl::musicDone());
+ delete[] myMem;
}
void SDLPlayer::audioDone() {
- Mix_HaltMusic();
- Mix_FreeMusic(music);
- music = NULL;
+ Mix_HaltChannel(currentChannel);
+ Mix_FreeChunk(sound);
+ sound = NULL;
}
void SDLPlayer::closeAudio() {
- Mix_HaltMusic();
- Mix_FreeMusic(music);
- music = NULL;
+ Mix_HaltChannel(currentChannel);
+ Mix_FreeChunk(sound);
+ sound = NULL;
Mix_CloseAudio();
SDL_Quit();
}
diff --git a/src/gui/qt/sound/sdlplayer.h b/src/gui/qt/sound/sdlplayer.h
index 4b01d4ae..bf494820 100644
--- a/src/gui/qt/sound/sdlplayer.h
+++ b/src/gui/qt/sound/sdlplayer.h
@@ -9,6 +9,8 @@
// Copyright: See COPYING file that comes with this distribution
//
//
+#include
+
#ifndef SDLPLAYER_H
#define SDLPLAYER_H
@@ -25,7 +27,9 @@
/**
@author FThauer FHammer
*/
-class SDLPlayer{
+class SDLPlayer : public QObject{
+Q_OBJECT
+
public:
SDLPlayer();
@@ -42,7 +46,8 @@ private:
Uint16 audio_format;
int audio_channels;
int audio_buffers;
- Mix_Music *music;
+ Mix_Chunk *sound;
+ int currentChannel;
};