1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 2 3 /* 4 Rosegarden 5 A sequencer and musical notation editor. 6 Copyright 2000-2021 the Rosegarden development team. 7 See the AUTHORS file for more details. 8 9 This program is free software; you can redistribute it and/or 10 modify it under the terms of the GNU General Public License as 11 published by the Free Software Foundation; either version 2 of the 12 License, or (at your option) any later version. See the file 13 COPYING included with this distribution for more information. 14 */ 15 16 #include "DummyDriver.h" 17 18 #ifdef HAVE_ALSA 19 #include "AlsaDriver.h" 20 #endif 21 22 #include "SoundDriverFactory.h" 23 24 namespace Rosegarden 25 { 26 27 static bool s_soundEnabled = true; 28 29 SoundDriver * createDriver(MappedStudio * studio)30SoundDriverFactory::createDriver(MappedStudio *studio) 31 { 32 SoundDriver *driver = nullptr; 33 bool initialised = false; 34 35 #ifdef HAVE_ALSA 36 if (s_soundEnabled) { 37 driver = new AlsaDriver(studio); 38 } else { 39 driver = new DummyDriver(studio); 40 } 41 #else 42 driver = new DummyDriver(studio); 43 #endif 44 45 initialised = driver->initialise(); 46 47 if ( ! initialised ) { 48 49 QString log = driver->getStatusLog(); 50 51 driver->shutdown(); 52 delete driver; 53 54 // if the driver couldn't be initialised, then 55 // fall to the DummyDriver as a last chance, 56 // so GUI can still be used for notation. 57 // 58 driver = new DummyDriver(studio, log); 59 driver->initialise(); 60 } 61 return driver; 62 } 63 setSoundEnabled(bool b)64void SoundDriverFactory::setSoundEnabled(bool b) 65 { 66 s_soundEnabled = b; 67 } 68 69 } 70 71 72