1 #include "audioconfig.h"
2 #include "audiodevice.inc"
4 #include "maxchannels.h"
8 #define CLAMP(x, y, z) (x) = ((x) < (y) ? (y) : ((x) > (z) ? (z) : (x)))
10 AudioConfig::AudioConfig()
14 AudioConfig::~AudioConfig()
18 AudioConfig& AudioConfig::operator=(AudioConfig &that)
21 audio_in_driver = that.audio_in_driver;
22 afirewire_in_port = that.afirewire_in_port;
23 afirewire_in_channel = that.afirewire_in_channel;
24 strcpy(esound_in_server, that.esound_in_server);
25 esound_in_port = that.esound_in_port;
26 strcpy(oss_in_device, that.oss_in_device);
27 oss_in_channels = that.oss_in_channels;
28 oss_in_bits = that.oss_in_bits;
31 audio_out_driver = that.audio_out_driver;
32 strcpy(oss_out_device, that.oss_out_device);
33 strcpy(esound_out_server, that.esound_out_server);
34 esound_out_port = that.esound_out_port;
35 oss_out_channels = that.oss_out_channels;
36 oss_out_bits = that.oss_out_bits;
39 audio_duplex_driver = that.audio_duplex_driver;
40 strcpy(oss_duplex_device, that.oss_duplex_device);
41 strcpy(esound_duplex_server, that.esound_duplex_server);
42 esound_duplex_port = that.esound_duplex_port;
43 oss_duplex_channels = that.oss_duplex_channels;
44 oss_duplex_bits = that.oss_duplex_bits;
45 CLAMP(oss_in_channels, 1, MAXCHANNELS);
46 CLAMP(oss_in_bits, 8, 32);
47 CLAMP(oss_duplex_channels, 1, MAXCHANNELS);
48 CLAMP(oss_duplex_bits, 8, 32);
52 int AudioConfig::load_defaults(BC_Hash *defaults)
54 audio_in_driver = defaults->get("AUDIOINDRIVER", AUDIO_OSS);
55 afirewire_in_port = defaults->get("AFIREWIRE_IN_PORT", 0);
56 afirewire_in_channel = defaults->get("AFIREWIRE_IN_CHANNEL", 63);
57 sprintf(oss_in_device, "/dev/dsp");
58 defaults->get("OSS_IN_DEVICE", oss_in_device);
59 oss_in_channels = defaults->get("OSS_IN_CHANNELS", 2);
60 oss_in_bits = defaults->get("OSS_IN_BITS", 16);
61 sprintf(esound_in_server, "");
62 defaults->get("ESOUND_IN_SERVER", esound_in_server);
63 esound_in_port = defaults->get("ESOUND_IN_PORT", 0);
65 audio_out_driver = defaults->get("AUDIO_OUT_DRIVER", AUDIO_OSS);
66 audio_duplex_driver = defaults->get("AUDIO_DUPLEX_DRIVER", AUDIO_OSS);
67 sprintf(oss_out_device, "/dev/dsp");
68 defaults->get("OSS_OUT_DEVICE", oss_out_device);
69 oss_out_channels = defaults->get("OUT_CHANNELS", 2);
70 oss_out_bits = defaults->get("OUT_BITS", 16);
71 sprintf(esound_out_server, "");
72 defaults->get("ESOUND_OUT_SERVER", esound_out_server);
73 esound_out_port = defaults->get("ESOUND_OUT_PORT", 0);
75 audio_duplex_driver = defaults->get("AUDIO_DUPLEX_DRIVER", AUDIO_OSS);
76 sprintf(oss_duplex_device, "/dev/dsp");
77 defaults->get("OSS_DUPLEX_DEVICE", oss_duplex_device);
78 oss_duplex_channels = defaults->get("DUPLEX_CHANNELS", 2);
79 oss_duplex_bits = defaults->get("DUPLEX_BITS", 16);
80 sprintf(esound_duplex_server, "");
81 defaults->get("ESOUND_DUPLEX_SERVER", esound_duplex_server);
82 esound_duplex_port = defaults->get("ESOUND_DUPLEX_PORT", 0);
86 int AudioConfig::save_defaults(BC_Hash *defaults)
88 defaults->update("AUDIOINDRIVER", audio_in_driver);
89 defaults->update("AFIREWIRE_IN_PORT", afirewire_in_port);
90 defaults->update("AFIREWIRE_IN_CHANNEL", afirewire_in_channel);
91 defaults->update("OSS_IN_DEVICE", oss_in_device);
92 defaults->update("OSS_IN_CHANNELS", oss_in_channels);
93 defaults->update("OSS_IN_BITS", oss_in_bits);
94 defaults->update("ESOUND_IN_SERVER", esound_in_server);
95 defaults->update("ESOUND_IN_PORT", esound_in_port);
97 defaults->update("AUDIO_OUT_DRIVER", audio_out_driver);
98 defaults->update("AUDIO_DUPLEX_DRIVER", audio_duplex_driver);
99 defaults->update("OSS_OUT_DEVICE", oss_out_device);
100 defaults->update("OUT_CHANNELS", oss_out_channels);
101 defaults->update("OUT_BITS", oss_out_bits);
102 defaults->update("ESOUND_OUT_SERVER", esound_out_server);
103 defaults->update("ESOUND_OUT_PORT", esound_out_port);
105 defaults->update("AUDIO_DUPLEX_DRIVER", audio_duplex_driver);
106 defaults->update("OSS_DUPLEX_DEVICE", oss_duplex_device);
107 defaults->update("OSS_DUPLEX_CHANNELS", oss_duplex_channels);
108 defaults->update("OSS_DUPLEX_BITS", oss_duplex_bits);
109 defaults->update("ESOUND_DUPLEX_SERVER", esound_duplex_server);
110 defaults->update("ESOUND_DUPLEX_PORT", esound_duplex_port);