Fix some memory leak complaints from Valgrind
[lsnes.git] / src / core / dummysound.cpp
blob6be01848b8b635c93692847b770b3900d3bc7e64
1 #include "core/command.hpp"
2 #include "core/audioapi.hpp"
4 #include <cstdlib>
5 #include <iostream>
7 namespace
9 void dummy_init() throw()
11 audioapi_voice_rate(0, 0);
14 void dummy_quit() throw()
18 void dummy_enable(bool enable) throw()
22 bool dummy_initialized()
24 return true;
27 void dummy_set_device(const std::string& pdev, const std::string& rdev) throw(std::bad_alloc,
28 std::runtime_error)
30 if(pdev != "null")
31 throw std::runtime_error("Bad sound device '" + pdev + "'");
32 if(rdev != "null")
33 throw std::runtime_error("Bad sound device '" + rdev + "'");
36 std::string dummy_get_device(bool rec) throw(std::bad_alloc)
38 return "null";
41 std::map<std::string, std::string> dummy_get_devices(bool rec) throw(std::bad_alloc)
43 std::map<std::string, std::string> ret;
44 ret["null"] = "NULL sound output";
45 return ret;
48 const char* dummy_name() { return "Dummy sound plugin"; }
50 _audioapi_driver driver = {
51 .init = dummy_init,
52 .quit = dummy_quit,
53 .enable = dummy_enable,
54 .initialized = dummy_initialized,
55 .set_device = dummy_set_device,
56 .get_device = dummy_get_device,
57 .get_devices = dummy_get_devices,
58 .name = dummy_name
62 audioapi_driver::audioapi_driver(struct _audioapi_driver _driver)
64 driver = _driver;
67 void audioapi_driver_init() throw()
69 driver.init();
72 void audioapi_driver_quit() throw()
74 driver.quit();
77 void audioapi_driver_enable(bool _enable) throw()
79 driver.enable(_enable);
82 bool audioapi_driver_initialized()
84 return driver.initialized();
87 void audioapi_driver_set_device(const std::string& pdev, const std::string& rdev) throw(std::bad_alloc,
88 std::runtime_error)
90 driver.set_device(pdev, rdev);
93 std::string audioapi_driver_get_device(bool rec) throw(std::bad_alloc)
95 return driver.get_device(rec);
98 std::map<std::string, std::string> audioapi_driver_get_devices(bool rec) throw(std::bad_alloc)
100 return driver.get_devices(rec);
103 const char* audioapi_driver_name() throw()
105 return driver.name();