Use master state for trampolines
[lsnes.git] / src / core / audioapi-driver.cpp
blob1251812d0ef1d06c1fb99a0aa9c9022ef4d7e176
1 #include "core/advdumper.hpp"
2 #include "core/audioapi.hpp"
3 #include "core/audioapi-driver.hpp"
4 #include "core/dispatch.hpp"
5 #include "core/framerate.hpp"
6 #include "core/instance.hpp"
7 #include "library/minmax.hpp"
8 #include "library/threads.hpp"
10 #include <cstdlib>
11 #include <cstring>
12 #include <cmath>
13 #include <iostream>
14 #include <unistd.h>
15 #include <sys/time.h>
17 #define MUSIC_BUFFERS 8
18 #define MAX_VOICE_ADJUST 200
20 namespace
22 void dummy_init() throw()
24 lsnes_instance.audio->voice_rate(0, 0);
27 void dummy_quit() throw()
31 void dummy_enable(bool enable) throw()
35 bool dummy_initialized()
37 return true;
40 void dummy_set_device(const std::string& pdev, const std::string& rdev) throw(std::bad_alloc,
41 std::runtime_error)
43 if(pdev != "null")
44 throw std::runtime_error("Bad sound device '" + pdev + "'");
45 if(rdev != "null")
46 throw std::runtime_error("Bad sound device '" + rdev + "'");
49 std::string dummy_get_device(bool rec) throw(std::bad_alloc)
51 return "null";
54 std::map<std::string, std::string> dummy_get_devices(bool rec) throw(std::bad_alloc)
56 std::map<std::string, std::string> ret;
57 ret["null"] = "NULL sound output";
58 return ret;
61 const char* dummy_name() { return "Dummy sound plugin"; }
63 _audioapi_driver driver = {
64 .init = dummy_init,
65 .quit = dummy_quit,
66 .enable = dummy_enable,
67 .initialized = dummy_initialized,
68 .set_device = dummy_set_device,
69 .get_device = dummy_get_device,
70 .get_devices = dummy_get_devices,
71 .name = dummy_name
75 audioapi_driver::audioapi_driver(struct _audioapi_driver _driver)
77 driver = _driver;
80 void audioapi_driver_init() throw()
82 driver.init();
85 void audioapi_driver_quit() throw()
87 driver.quit();
90 void audioapi_driver_enable(bool _enable) throw()
92 driver.enable(_enable);
95 bool audioapi_driver_initialized()
97 return driver.initialized();
100 void audioapi_driver_set_device(const std::string& pdev, const std::string& rdev) throw(std::bad_alloc,
101 std::runtime_error)
103 driver.set_device(pdev, rdev);
106 std::string audioapi_driver_get_device(bool rec) throw(std::bad_alloc)
108 return driver.get_device(rec);
111 std::map<std::string, std::string> audioapi_driver_get_devices(bool rec) throw(std::bad_alloc)
113 return driver.get_devices(rec);
116 const char* audioapi_driver_name() throw()
118 return driver.name();