From e2e2e542ed5ceb4d61d13ccce60f38c897c96736 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Duval?= Date: Sun, 2 Jul 2006 11:15:18 +0000 Subject: [PATCH] fix a crash in SetVolume, fix debug build git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@18005 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/midi/MidiStore.cpp | 2 +- src/kits/midi/SoftSynth.cpp | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/kits/midi/MidiStore.cpp b/src/kits/midi/MidiStore.cpp index 4820191647..2648594848 100644 --- a/src/kits/midi/MidiStore.cpp +++ b/src/kits/midi/MidiStore.cpp @@ -725,7 +725,7 @@ BMidiStore::ReadChunk() ReadTrack(); else { TRACE(("Skipping '%c%c%c%c' chunk (%lu bytes)", - fourcc[0], fourcc[1], fourcc[2], fourcc[3], byteCount)) + fourcc[0], fourcc[1], fourcc[2], fourcc[3], fByteCount)) SkipBytes(fByteCount); } diff --git a/src/kits/midi/SoftSynth.cpp b/src/kits/midi/SoftSynth.cpp index ccccbd0c9f..69e0c5dc07 100644 --- a/src/kits/midi/SoftSynth.cpp +++ b/src/kits/midi/SoftSynth.cpp @@ -23,7 +23,8 @@ using namespace BPrivate; BSoftSynth::BSoftSynth() -: fSynth(NULL), +: fInitCheck(false), + fSynth(NULL), fSettings(NULL), fSoundPlayer(NULL) { @@ -147,9 +148,10 @@ BSoftSynth::FlushInstrumentCache(bool startStopCache) void BSoftSynth::SetVolume(double volume) { - if (volume >= 0.0) { - fluid_synth_set_gain(fSynth, volume); - } + if (InitCheck()) + if (volume >= 0.0) { + fluid_synth_set_gain(fSynth, volume); + } } @@ -434,8 +436,10 @@ BSoftSynth::_Init() return; err = fluid_synth_sfload(fSynth, fInstrumentsFile, 1); - if (err < B_OK) + if (err < B_OK) { + fprintf(stderr, "error in fluid_synth_sfload\n"); return; + } media_raw_audio_format format = media_raw_audio_format::wildcard; format.channel_count = 2; @@ -444,8 +448,10 @@ BSoftSynth::_Init() fSoundPlayer = new BSoundPlayer(&format, "Soft Synth", &PlayBuffer, NULL, this); err = fSoundPlayer->InitCheck(); - if (err != B_OK) + if (err != B_OK) { + fprintf(stderr, "error in BSoundPlayer\n"); return; + } fSoundPlayer->SetHasData(true); fSoundPlayer->Start();