File tree Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Expand file tree Collapse file tree 2 files changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -18,11 +18,15 @@ AudioPlayer::~AudioPlayer()
1818{
1919 if (m_loaded) {
2020 ma_sound_uninit (m_sound);
21- ma_decoder_uninit (m_decoder);
21+
22+ if (!m_copy)
23+ ma_decoder_uninit (m_decoder);
2224 }
2325
24- delete m_decoder;
2526 delete m_sound;
27+
28+ if (!m_copy)
29+ delete m_decoder;
2630}
2731
2832bool AudioPlayer::load (unsigned int size, const void *data, unsigned long sampleRate)
@@ -74,6 +78,7 @@ bool AudioPlayer::loadCopy(IAudioPlayer *player)
7478 }
7579
7680 m_loaded = true ;
81+ m_copy = true ;
7782 ma_sound_set_volume (m_sound, m_volume);
7883 return true ;
7984}
Original file line number Diff line number Diff line change @@ -33,6 +33,7 @@ class AudioPlayer : public IAudioPlayer
3333 ma_decoder *m_decoder = nullptr ;
3434 ma_sound *m_sound;
3535 bool m_loaded = false ;
36+ bool m_copy = false ;
3637 bool m_started = false ;
3738 float m_volume = 1 ;
3839};
You can’t perform that action at this time.
0 commit comments