Add destructors to sound objects

This commit is contained in:
oldmud0 2018-08-29 14:57:58 -05:00
parent 5bd40225bd
commit 4c5bafdcad
5 changed files with 17 additions and 4 deletions

View File

@ -7,6 +7,12 @@ AOBlipPlayer::AOBlipPlayer(QWidget *parent, AOApplication *p_ao_app)
ao_app = p_ao_app;
}
AOBlipPlayer::~AOBlipPlayer()
{
m_sfxplayer->stop();
m_sfxplayer->deleteLater();
}
void AOBlipPlayer::set_blips(QString p_sfx)
{
m_sfxplayer->stop();
@ -23,6 +29,5 @@ void AOBlipPlayer::blip_tick()
void AOBlipPlayer::set_volume(int p_value)
{
m_volume = p_value;
float volume = p_value / 100.0f;
m_sfxplayer->setVolume(qreal(volume));
m_sfxplayer->setVolume(p_value / 100.0);
}

View File

@ -12,6 +12,7 @@ class AOBlipPlayer
{
public:
AOBlipPlayer(QWidget *parent, AOApplication *p_ao_app);
~AOBlipPlayer();
void set_blips(QString p_sfx);
void blip_tick();

View File

@ -10,6 +10,7 @@ AOMusicPlayer::AOMusicPlayer(QWidget *parent, AOApplication *p_ao_app)
AOMusicPlayer::~AOMusicPlayer()
{
m_player->stop();
m_player->deleteLater();
}
void AOMusicPlayer::play(QString p_song)

View File

@ -7,6 +7,12 @@ AOSfxPlayer::AOSfxPlayer(QWidget *parent, AOApplication *p_ao_app)
ao_app = p_ao_app;
}
AOSfxPlayer::~AOSfxPlayer()
{
m_sfxplayer->stop();
m_sfxplayer->deleteLater();
}
void AOSfxPlayer::play(QString p_sfx, QString p_char)
{
m_sfxplayer->stop();
@ -31,6 +37,5 @@ void AOSfxPlayer::stop()
void AOSfxPlayer::set_volume(int p_value)
{
m_volume = p_value;
float volume = p_value / 100.0f;
m_sfxplayer->setVolume(qreal(volume));
m_sfxplayer->setVolume(p_value / 100.0);
}

View File

@ -12,6 +12,7 @@ class AOSfxPlayer
{
public:
AOSfxPlayer(QWidget *parent, AOApplication *p_ao_app);
~AOSfxPlayer();
void play(QString p_sfx, QString p_char = "");
void stop();