mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 08:37:45 +00:00
SoundPlayer: Check if loader is null
This patch prevents SoundPlayer from crashing when attempting to "seek" when no file has been loaded
This commit is contained in:
parent
5e3192c8d9
commit
7dd3c4a79c
1 changed files with 5 additions and 1 deletions
|
@ -155,7 +155,11 @@ void Player::toggle_mute()
|
||||||
|
|
||||||
void Player::seek(int sample)
|
void Player::seek(int sample)
|
||||||
{
|
{
|
||||||
sample *= (m_playback_manager.device_sample_rate() / static_cast<float>(m_playback_manager.loader()->sample_rate()));
|
auto loader = m_playback_manager.loader();
|
||||||
|
if (loader.is_null()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
sample *= (m_playback_manager.device_sample_rate() / static_cast<float>(loader->sample_rate()));
|
||||||
m_playback_manager.seek(sample);
|
m_playback_manager.seek(sample);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue