Skip to content

Commit

Permalink
Fixed seek not working if sound is stopped and resume enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
Conarnar committed Dec 9, 2024
1 parent 23c1480 commit 2e1bf23
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions source/GcLib/directx/DirectSound.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -737,7 +737,7 @@ SoundPlayer::SoundPlayer() {
playStyle_.bLoop_ = false;
playStyle_.timeLoopStart_ = 0;
playStyle_.timeLoopEnd_ = 0;
playStyle_.timeStart_ = 0;
playStyle_.timeStart_ = -1;
playStyle_.bResume_ = false;

bDelete_ = false;
Expand Down Expand Up @@ -1141,11 +1141,11 @@ bool SoundStreamingPlayer::Play() {
SetFade(0);

bStreamOver_ = false;
if (!bPause_ || !playStyle_.bResume_) {
this->Seek(playStyle_.timeStart_);
if (!bPause_ || !playStyle_.bResume_ || playStyle_.timeStart_ >= 0) {
this->Seek(playStyle_.timeStart_ >= 0 ? playStyle_.timeStart_ : 0);
pDirectSoundBuffer_->SetCurrentPosition(0);
}
playStyle_.timeStart_ = 0;
playStyle_.timeStart_ = -1;

for (size_t iEvent = 0; iEvent < 3; ++iEvent)
::ResetEvent(hEvent_[iEvent]);
Expand Down Expand Up @@ -1370,10 +1370,10 @@ bool SoundPlayerWave::Play() {
if (playStyle_.bLoop_)
dwFlags = DSBPLAY_LOOPING;

if (!bPause_ || !playStyle_.bResume_) {
this->Seek(playStyle_.timeStart_);
if (!bPause_ || !playStyle_.bResume_ || playStyle_.timeStart_ >= 0) {
this->Seek(playStyle_.timeStart_ >= 0 ? playStyle_.timeStart_ : 0);
}
playStyle_.timeStart_ = 0;
playStyle_.timeStart_ = -1;

HRESULT hr = pDirectSoundBuffer_->Play(0, 0, dwFlags);
if (hr == DSERR_BUFFERLOST) {
Expand Down

0 comments on commit 2e1bf23

Please sign in to comment.