From 3105209dada7173d7ab91881d346aec8677ecdb9 Mon Sep 17 00:00:00 2001 From: Peter Veenstra Date: Thu, 3 Feb 2005 10:34:37 +0000 Subject: [PATCH] Only do things with the channel if it actually is present. Fixes some crashes with pcspeaker disabled Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@2104 --- src/hardware/pcspeaker.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/hardware/pcspeaker.cpp b/src/hardware/pcspeaker.cpp index 732d3329..dc36788f 100644 --- a/src/hardware/pcspeaker.cpp +++ b/src/hardware/pcspeaker.cpp @@ -15,6 +15,8 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + + /* $Id: pcspeaker.cpp,v 1.18 2005-02-03 10:34:37 qbix79 Exp $ */ #include #include "dosbox.h" @@ -158,7 +160,7 @@ static void ForwardPIT(float newindex) { void PCSPEAKER_SetCounter(Bitu cntr,Bitu mode) { if (!spkr.last_ticks) { - spkr.chan->Enable(true); + if(spkr.chan) spkr.chan->Enable(true); spkr.last_index=0; } spkr.last_ticks=PIC_Ticks; @@ -213,7 +215,7 @@ void PCSPEAKER_SetCounter(Bitu cntr,Bitu mode) { void PCSPEAKER_SetType(Bitu mode) { if (!spkr.last_ticks) { - spkr.chan->Enable(true); + if(spkr.chan) spkr.chan->Enable(true); spkr.last_index=0; } spkr.last_ticks=PIC_Ticks; @@ -296,10 +298,10 @@ static void PCSPEAKER_CallBack(Bitu len) { } *stream++=(Bit16s)(value/sample_add); } - spkr.chan->AddSamples_m16(len,(Bit16s*)MixTemp); + if(spkr.chan) spkr.chan->AddSamples_m16(len,(Bit16s*)MixTemp); if ((spkr.last_ticks+10000)Enable(false); + if(spkr.chan) spkr.chan->Enable(false); } }