Skip to content

Commit

Permalink
player wrapper: properly apply playback speed
Browse files Browse the repository at this point in the history
Apply the playback speed to all players and set it when loading as well.
This ensures correct timing calculations between "file load" and "start",
which is required by in_vgm.
  • Loading branch information
ValleyBell committed Dec 31, 2023
1 parent dde04a7 commit 185694b
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions player/playera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,8 @@ double PlayerA::GetPlaybackSpeed(void) const
void PlayerA::SetPlaybackSpeed(double speed)
{
_config.pbSpeed = speed;
if (_player != NULL)
_player->SetPlaybackSpeed(_config.pbSpeed);
for (size_t curPlr = 0; curPlr < _avbPlrs.size(); curPlr++)
_avbPlrs[curPlr]->SetSampleRate(_smplRate);
return;
}

Expand Down Expand Up @@ -257,8 +257,9 @@ void PlayerA::SetConfiguration(const PlayerA::Config& config)
double oldPbSpeed = _config.pbSpeed;

_config = config;
if (_player != NULL && oldPbSpeed != _config.pbSpeed)
_player->SetPlaybackSpeed(_config.pbSpeed);
SetMasterVolume(_config.masterVol);
if (oldPbSpeed != _config.pbSpeed)
SetPlaybackSpeed(_config.pbSpeed); // refresh in all players
return;
}

Expand Down Expand Up @@ -389,6 +390,10 @@ UINT8 PlayerA::LoadFile(DATA_LOADER* dLoad)
if (_player == NULL)
return 0xFF;

// set the configuration so that the configuration is loaded properly
_player->SetSampleRate(_smplRate);
_player->SetPlaybackSpeed(_config.pbSpeed);

UINT8 retVal = _player->LoadFile(dLoad);
if (retVal >= 0x80)
return retVal;
Expand Down

0 comments on commit 185694b

Please sign in to comment.