diff options
| author | manuel <manuel@mausz.at> | 2011-05-11 18:36:49 +0200 |
|---|---|---|
| committer | manuel <manuel@mausz.at> | 2011-05-11 18:36:49 +0200 |
| commit | f5cb775b8f794fc4900fda1fbb2d6c59d695f815 (patch) | |
| tree | bc18ae97c7db289196dfe345c0d1c5c8501485ad /pacman-c++ | |
| parent | ca29fc0babe8fc985a9e4656f80fc7faec4ac8a5 (diff) | |
| download | foop-f5cb775b8f794fc4900fda1fbb2d6c59d695f815.tar.gz foop-f5cb775b8f794fc4900fda1fbb2d6c59d695f815.tar.bz2 foop-f5cb775b8f794fc4900fda1fbb2d6c59d695f815.zip | |
fix another phonon issue with gaplessplayer (pause() is not synchron so we might start the second player although we issued pause())
Diffstat (limited to 'pacman-c++')
| -rw-r--r-- | pacman-c++/common/audio.cpp | 14 | ||||
| -rw-r--r-- | pacman-c++/common/audio.h | 1 |
2 files changed, 10 insertions, 5 deletions
diff --git a/pacman-c++/common/audio.cpp b/pacman-c++/common/audio.cpp index eddbace..fe259e2 100644 --- a/pacman-c++/common/audio.cpp +++ b/pacman-c++/common/audio.cpp | |||
| @@ -328,7 +328,7 @@ void FakeAudioPlayer::finished_ex() | |||
| 328 | /* --------------------------------------------------------------- */ | 328 | /* --------------------------------------------------------------- */ |
| 329 | 329 | ||
| 330 | GaplessAudioPlayer::GaplessAudioPlayer(Sound::Type sound, qint32 mark, QObject *parent) | 330 | GaplessAudioPlayer::GaplessAudioPlayer(Sound::Type sound, qint32 mark, QObject *parent) |
| 331 | : QObject(parent), m_sound(sound) | 331 | : QObject(parent), m_paused(false), m_sound(sound) |
| 332 | { | 332 | { |
| 333 | m_working = AudioManager::isWorking(); | 333 | m_working = AudioManager::isWorking(); |
| 334 | if (!m_working) | 334 | if (!m_working) |
| @@ -367,6 +367,7 @@ void GaplessAudioPlayer::play() | |||
| 367 | { | 367 | { |
| 368 | if (!m_working) | 368 | if (!m_working) |
| 369 | return; | 369 | return; |
| 370 | m_paused = false; | ||
| 370 | if (!m_player1->isPlaying() && !m_player2->isPlaying()) | 371 | if (!m_player1->isPlaying() && !m_player2->isPlaying()) |
| 371 | startPlayer1(); | 372 | startPlayer1(); |
| 372 | } | 373 | } |
| @@ -375,20 +376,23 @@ void GaplessAudioPlayer::pause() | |||
| 375 | { | 376 | { |
| 376 | if (!m_working) | 377 | if (!m_working) |
| 377 | return; | 378 | return; |
| 378 | if (!m_player1->isPaused()) | 379 | m_paused = true; |
| 379 | m_player1->pause(); | 380 | m_player1->pause(); |
| 380 | if (!m_player2->isPaused()) | 381 | m_player2->pause(); |
| 381 | m_player2->pause(); | ||
| 382 | } | 382 | } |
| 383 | 383 | ||
| 384 | void GaplessAudioPlayer::startPlayer1() | 384 | void GaplessAudioPlayer::startPlayer1() |
| 385 | { | 385 | { |
| 386 | if (m_paused) | ||
| 387 | return; | ||
| 386 | AudioManager::self()->play(m_sound, m_player1); | 388 | AudioManager::self()->play(m_sound, m_player1); |
| 387 | m_player2->pause(); | 389 | m_player2->pause(); |
| 388 | } | 390 | } |
| 389 | 391 | ||
| 390 | void GaplessAudioPlayer::startPlayer2() | 392 | void GaplessAudioPlayer::startPlayer2() |
| 391 | { | 393 | { |
| 394 | if (m_paused) | ||
| 395 | return; | ||
| 392 | AudioManager::self()->play(m_sound, m_player2); | 396 | AudioManager::self()->play(m_sound, m_player2); |
| 393 | m_player1->pause(); | 397 | m_player1->pause(); |
| 394 | } | 398 | } |
diff --git a/pacman-c++/common/audio.h b/pacman-c++/common/audio.h index 45af34b..b9b8d8d 100644 --- a/pacman-c++/common/audio.h +++ b/pacman-c++/common/audio.h | |||
| @@ -105,6 +105,7 @@ protected slots: | |||
| 105 | 105 | ||
| 106 | protected: | 106 | protected: |
| 107 | bool m_working; | 107 | bool m_working; |
| 108 | bool m_paused; | ||
| 108 | Sound::Type m_sound; | 109 | Sound::Type m_sound; |
| 109 | AudioPlayer *m_player1; | 110 | AudioPlayer *m_player1; |
| 110 | AudioPlayer *m_player2; | 111 | AudioPlayer *m_player2; |
