From 3394d3c840c6342712352d451d7cdf32623a2e3c Mon Sep 17 00:00:00 2001 From: fredb Date: Sun, 12 Nov 2006 13:54:50 +0000 Subject: [PATCH] Don't segfault when sound is not available --- src/Instrumentation/mk_viii.hxx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Instrumentation/mk_viii.hxx b/src/Instrumentation/mk_viii.hxx index 60a3f9458..47b76440f 100755 --- a/src/Instrumentation/mk_viii.hxx +++ b/src/Instrumentation/mk_viii.hxx @@ -745,10 +745,10 @@ public: inline SampleElement (SGSoundSample *sample, double volume = 1.0) : _sample(sample), _volume(volume) { silence = false; } - virtual inline void play (double volume) { set_volume(volume); _sample->play_once(); } - virtual inline void stop () { _sample->stop(); } - virtual inline bool is_playing () { return _sample->is_playing(); } - virtual inline void set_volume (double volume) { _sample->set_volume(volume * _volume); } + virtual inline void play (double volume) { if (_sample) { set_volume(volume); _sample->play_once(); } } + virtual inline void stop () { if (_sample) _sample->stop(); } + virtual inline bool is_playing () { return _sample ? _sample->is_playing() : false; } + virtual inline void set_volume (double volume) { if (_sample) _sample->set_volume(volume * _volume); } }; ///////////////////////////////////////////////////////////////////////// -- 2.39.5