Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Client/mods/deathmatch/logic/CBassAudio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -521,16 +521,17 @@ void CBassAudio::SetPaused(bool bPaused)
}

// Non-streams only
void CBassAudio::SetPlayPosition(double dPosition)
bool CBassAudio::SetPlayPosition(double dPosition)
{
// Only relevant for non-streams, which are always ready if valid
if (m_pSound)
{
// Make sure position is in range
QWORD bytePosition = BASS_ChannelSeconds2Bytes(m_pSound, dPosition);
QWORD byteLength = BASS_ChannelGetLength(m_pSound, BASS_POS_BYTE);
BASS_ChannelSetPosition(m_pSound, Clamp<QWORD>(0, bytePosition, byteLength - 1), BASS_POS_BYTE);
return BASS_ChannelSetPosition(m_pSound, Clamp<QWORD>(0, bytePosition, byteLength - 1), BASS_POS_BYTE);
}
return false;
}

// Non-streams only
Expand Down
2 changes: 1 addition & 1 deletion Client/mods/deathmatch/logic/CBassAudio.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class CBassAudio
bool BeginLoadingMedia();

void SetPaused(bool bPaused);
void SetPlayPosition(double dPosition);
bool SetPlayPosition(double dPosition);
double GetPlayPosition();
double GetLength();
double GetBufferLength();
Expand Down
8 changes: 5 additions & 3 deletions Client/mods/deathmatch/logic/CClientSound.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,18 +293,20 @@ void CClientSound::PlayStream(const SString& strURL, bool bLoop, bool bThrottle,
//
//
////////////////////////////////////////////////////////////
void CClientSound::SetPlayPosition(double dPosition)
bool CClientSound::SetPlayPosition(double dPosition)
{
if (m_pAudio)
{
// Use actual audio if active
m_pAudio->SetPlayPosition(dPosition);
return m_pAudio->SetPlayPosition(dPosition);
}
else
else if (m_SimulatedPlayPosition.IsValid())
{
// Use simulation if not active
m_SimulatedPlayPosition.SetPlayPositionNow(dPosition);
return true;
}
return false;
}

double CClientSound::GetPlayPosition()
Expand Down
2 changes: 1 addition & 1 deletion Client/mods/deathmatch/logic/CClientSound.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class CClientSound : public CClientEntity
void SetPaused(bool bPaused);
bool IsPaused();

void SetPlayPosition(double dPosition);
bool SetPlayPosition(double dPosition);
double GetPlayPosition();

double GetLength(bool bAvoidLoad = false);
Expand Down
6 changes: 1 addition & 5 deletions Client/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7586,11 +7586,7 @@ bool CStaticFunctionDefinitions::StopSound(CClientSound& Sound)

bool CStaticFunctionDefinitions::SetSoundPosition(CClientSound& Sound, double dPosition)
{
if (Sound.IsSoundStream())
return false;

Sound.SetPlayPosition(dPosition);
return true;
return Sound.SetPlayPosition(dPosition);
}

bool CStaticFunctionDefinitions::SetSoundPosition(CClientPlayer& Player, double dPosition)
Expand Down