3 #include "playbackconfig.h"
4 #include "videodevice.inc"
7 AudioOutConfig::AudioOutConfig(int duplex)
11 fragment_size = 16384;
17 for(int i = 0; i < MAXDEVICES; i++)
19 oss_enable[i] = (i == 0);
20 sprintf(oss_out_device[i], "/dev/dsp");
23 sprintf(esound_out_server, "");
26 sprintf(alsa_out_device, "default");
28 interrupt_workaround = 0;
30 firewire_channel = 63;
32 strcpy(firewire_path, "/dev/video1394");
37 strcpy(dv1394_path, "/dev/dv1394");
42 AudioOutConfig::~AudioOutConfig()
48 int AudioOutConfig::operator!=(AudioOutConfig &that)
50 return !(*this == that);
53 int AudioOutConfig::operator==(AudioOutConfig &that)
56 fragment_size == that.fragment_size &&
57 driver == that.driver &&
58 EQUIV(audio_offset, that.audio_offset) &&
61 !strcmp(oss_out_device[0], that.oss_out_device[0]) &&
62 (oss_out_bits == that.oss_out_bits) &&
66 !strcmp(esound_out_server, that.esound_out_server) &&
67 (esound_out_port == that.esound_out_port) &&
71 !strcmp(alsa_out_device, that.alsa_out_device) &&
72 (alsa_out_bits == that.alsa_out_bits) &&
73 (interrupt_workaround == that.interrupt_workaround) &&
75 firewire_channel == that.firewire_channel &&
76 firewire_port == that.firewire_port &&
77 firewire_syt == that.firewire_syt &&
78 !strcmp(firewire_path, that.firewire_path) &&
80 dv1394_channel == that.dv1394_channel &&
81 dv1394_port == that.dv1394_port &&
82 dv1394_syt == that.dv1394_syt &&
83 !strcmp(dv1394_path, that.dv1394_path);
88 AudioOutConfig& AudioOutConfig::operator=(AudioOutConfig &that)
94 void AudioOutConfig::copy_from(AudioOutConfig *src)
96 fragment_size = src->fragment_size;
98 audio_offset = src->audio_offset;
100 strcpy(esound_out_server, src->esound_out_server);
101 esound_out_port = src->esound_out_port;
102 for(int i = 0; i < MAXDEVICES; i++)
104 oss_enable[i] = src->oss_enable[i];
105 strcpy(oss_out_device[i], src->oss_out_device[i]);
107 oss_out_bits = src->oss_out_bits;
109 strcpy(alsa_out_device, src->alsa_out_device);
110 alsa_out_bits = src->alsa_out_bits;
111 interrupt_workaround = src->interrupt_workaround;
113 firewire_channel = src->firewire_channel;
114 firewire_port = src->firewire_port;
115 firewire_syt = src->firewire_syt;
116 strcpy(firewire_path, src->firewire_path);
118 dv1394_channel = src->dv1394_channel;
119 dv1394_port = src->dv1394_port;
120 dv1394_syt = src->dv1394_syt;
121 strcpy(dv1394_path, src->dv1394_path);
125 int AudioOutConfig::load_defaults(BC_Hash *defaults)
127 char string[BCTEXTLEN];
129 fragment_size = defaults->get("FRAGMENT_SIZE", fragment_size);
130 audio_offset = defaults->get("AUDIO_OFFSET", audio_offset);
131 sprintf(string, "AUDIO_OUT_DRIVER_%d", duplex);
132 driver = defaults->get(string, driver);
134 for(int i = 0; i < MAXDEVICES; i++)
136 sprintf(string, "OSS_ENABLE_%d_%d", i, duplex);
137 oss_enable[i] = defaults->get(string, oss_enable[i]);
138 sprintf(string, "OSS_OUT_DEVICE_%d_%d", i, duplex);
139 defaults->get(string, oss_out_device[i]);
141 sprintf(string, "OSS_OUT_BITS_%d", duplex);
142 oss_out_bits = defaults->get(string, oss_out_bits);
144 defaults->get("ALSA_OUT_DEVICE", alsa_out_device);
145 alsa_out_bits = defaults->get("ALSA_OUT_BITS", alsa_out_bits);
146 interrupt_workaround = defaults->get("ALSA_INTERRUPT_WORKAROUND", interrupt_workaround);
148 sprintf(string, "ESOUND_OUT_SERVER_%d", duplex);
149 defaults->get(string, esound_out_server);
150 sprintf(string, "ESOUND_OUT_PORT_%d", duplex);
151 esound_out_port = defaults->get(string, esound_out_port);
153 sprintf(string, "AFIREWIRE_OUT_CHANNEL");
154 firewire_channel = defaults->get(string, firewire_channel);
155 sprintf(string, "AFIREWIRE_OUT_PORT");
156 firewire_port = defaults->get(string, firewire_port);
157 sprintf(string, "AFIREWIRE_OUT_PATH");
158 defaults->get(string, firewire_path);
159 sprintf(string, "AFIREWIRE_OUT_SYT");
160 firewire_syt = defaults->get(string, firewire_syt);
162 sprintf(string, "ADV1394_OUT_CHANNEL");
163 dv1394_channel = defaults->get(string, dv1394_channel);
164 sprintf(string, "ADV1394_OUT_PORT");
165 dv1394_port = defaults->get(string, dv1394_port);
166 sprintf(string, "ADV1394_OUT_PATH");
167 defaults->get(string, dv1394_path);
168 sprintf(string, "ADV1394_OUT_SYT");
169 dv1394_syt = defaults->get(string, dv1394_syt);
174 int AudioOutConfig::save_defaults(BC_Hash *defaults)
176 char string[BCTEXTLEN];
178 defaults->update("FRAGMENT_SIZE", fragment_size);
179 defaults->update("AUDIO_OFFSET", audio_offset);
181 sprintf(string, "AUDIO_OUT_DRIVER_%d", duplex);
182 defaults->update(string, driver);
184 for(int i = 0; i < MAXDEVICES; i++)
186 sprintf(string, "OSS_ENABLE_%d_%d", i, duplex);
187 defaults->update(string, oss_enable[i]);
188 sprintf(string, "OSS_OUT_DEVICE_%d_%d", i, duplex);
189 defaults->update(string, oss_out_device[i]);
191 sprintf(string, "OSS_OUT_BITS_%d", duplex);
192 defaults->update(string, oss_out_bits);
195 defaults->update("ALSA_OUT_DEVICE", alsa_out_device);
196 defaults->update("ALSA_OUT_BITS", alsa_out_bits);
197 defaults->update("ALSA_INTERRUPT_WORKAROUND", interrupt_workaround);
199 sprintf(string, "ESOUND_OUT_SERVER_%d", duplex);
200 defaults->update(string, esound_out_server);
201 sprintf(string, "ESOUND_OUT_PORT_%d", duplex);
202 defaults->update(string, esound_out_port);
204 sprintf(string, "AFIREWIRE_OUT_CHANNEL");
205 defaults->update(string, firewire_channel);
206 sprintf(string, "AFIREWIRE_OUT_PORT");
207 defaults->update(string, firewire_port);
208 sprintf(string, "AFIREWIRE_OUT_PATH");
209 defaults->update(string, firewire_path);
210 sprintf(string, "AFIREWIRE_OUT_SYT");
211 defaults->update(string, firewire_syt);
214 sprintf(string, "ADV1394_OUT_CHANNEL");
215 defaults->update(string, dv1394_channel);
216 sprintf(string, "ADV1394_OUT_PORT");
217 defaults->update(string, dv1394_port);
218 sprintf(string, "ADV1394_OUT_PATH");
219 defaults->update(string, dv1394_path);
220 sprintf(string, "ADV1394_OUT_SYT");
221 defaults->update(string, dv1394_syt);
235 VideoOutConfig::VideoOutConfig()
237 sprintf(lml_out_device, "/dev/mvideo/stream");
238 sprintf(buz_out_device, "/dev/video0");
239 driver = PLAYBACK_X11_XV;
240 for(int i = 0; i < MAX_CHANNELS; i++) do_channel[i] = 0;
243 sprintf(x11_host, "");
244 x11_use_fields = USE_NO_FIELDS;
246 firewire_channel = 63;
248 strcpy(firewire_path, "/dev/video1394");
249 firewire_syt = 30000;
253 strcpy(dv1394_path, "/dev/dv1394");
263 VideoOutConfig::~VideoOutConfig()
268 int VideoOutConfig::operator!=(VideoOutConfig &that)
270 return !(*this == that);
273 int VideoOutConfig::operator==(VideoOutConfig &that)
275 return (driver == that.driver) &&
276 !strcmp(lml_out_device, that.lml_out_device) &&
277 !strcmp(buz_out_device, that.buz_out_device) &&
278 (buz_out_channel == that.buz_out_channel) &&
279 (buz_swap_fields == that.buz_swap_fields) &&
280 !strcmp(x11_host, that.x11_host) &&
281 (x11_use_fields == that.x11_use_fields) &&
282 (brightness == that.brightness) &&
284 (color == that.color) &&
285 (contrast == that.contrast) &&
286 (whiteness == that.whiteness) &&
288 (firewire_channel == that.firewire_channel) &&
289 (firewire_port == that.firewire_port) &&
290 !strcmp(firewire_path, that.firewire_path) &&
291 (firewire_syt == that.firewire_syt) &&
293 (dv1394_channel == that.dv1394_channel) &&
294 (dv1394_port == that.dv1394_port) &&
295 !strcmp(dv1394_path, that.dv1394_path) &&
296 (dv1394_syt == that.dv1394_syt);
304 VideoOutConfig& VideoOutConfig::operator=(VideoOutConfig &that)
310 void VideoOutConfig::copy_from(VideoOutConfig *src)
312 this->driver = src->driver;
313 strcpy(this->lml_out_device, src->lml_out_device);
314 strcpy(this->buz_out_device, src->buz_out_device);
315 this->buz_out_channel = src->buz_out_channel;
316 this->buz_swap_fields = src->buz_swap_fields;
317 strcpy(this->x11_host, src->x11_host);
318 this->x11_use_fields = src->x11_use_fields;
319 for(int i = 0; i < MAX_CHANNELS; i++)
320 this->do_channel[i] = src->do_channel[i];
322 firewire_channel = src->firewire_channel;
323 firewire_port = src->firewire_port;
324 strcpy(firewire_path, src->firewire_path);
325 firewire_syt = src->firewire_syt;
327 dv1394_channel = src->dv1394_channel;
328 dv1394_port = src->dv1394_port;
329 strcpy(dv1394_path, src->dv1394_path);
330 dv1394_syt = src->dv1394_syt;
333 char* VideoOutConfig::get_path()
338 return buz_out_device;
341 case PLAYBACK_X11_XV:
344 case PLAYBACK_DV1394:
347 case PLAYBACK_FIREWIRE:
348 return firewire_path;
351 return buz_out_device;
354 int VideoOutConfig::load_defaults(BC_Hash *defaults)
356 char string[BCTEXTLEN];
357 sprintf(string, "VIDEO_OUT_DRIVER");
358 driver = defaults->get(string, driver);
359 sprintf(string, "LML_OUT_DEVICE");
360 defaults->get(string, lml_out_device);
361 sprintf(string, "BUZ_OUT_DEVICE");
362 defaults->get(string, buz_out_device);
363 sprintf(string, "BUZ_OUT_CHANNEL");
364 buz_out_channel = defaults->get(string, buz_out_channel);
365 sprintf(string, "BUZ_SWAP_FIELDS");
366 buz_swap_fields = defaults->get(string, buz_swap_fields);
367 sprintf(string, "X11_OUT_DEVICE");
368 defaults->get(string, x11_host);
369 x11_use_fields = defaults->get("X11_USE_FIELDS", x11_use_fields);
373 sprintf(string, "VFIREWIRE_OUT_CHANNEL");
374 firewire_channel = defaults->get(string, firewire_channel);
375 sprintf(string, "VFIREWIRE_OUT_PORT");
376 firewire_port = defaults->get(string, firewire_port);
377 sprintf(string, "VFIREWIRE_OUT_PATH");
378 defaults->get(string, firewire_path);
379 sprintf(string, "VFIREWIRE_OUT_SYT");
380 firewire_syt = defaults->get(string, firewire_syt);
382 sprintf(string, "VDV1394_OUT_CHANNEL");
383 dv1394_channel = defaults->get(string, dv1394_channel);
384 sprintf(string, "VDV1394_OUT_PORT");
385 dv1394_port = defaults->get(string, dv1394_port);
386 sprintf(string, "VDV1394_OUT_PATH");
387 defaults->get(string, dv1394_path);
388 sprintf(string, "VDV1394_OUT_SYT");
389 dv1394_syt = defaults->get(string, dv1394_syt);
393 int VideoOutConfig::save_defaults(BC_Hash *defaults)
395 char string[BCTEXTLEN];
396 sprintf(string, "VIDEO_OUT_DRIVER");
397 defaults->update(string, driver);
398 sprintf(string, "LML_OUT_DEVICE");
399 defaults->update(string, lml_out_device);
400 sprintf(string, "BUZ_OUT_DEVICE");
401 defaults->update(string, buz_out_device);
402 sprintf(string, "BUZ_OUT_CHANNEL");
403 defaults->update(string, buz_out_channel);
404 sprintf(string, "BUZ_SWAP_FIELDS");
405 defaults->update(string, buz_swap_fields);
406 sprintf(string, "X11_OUT_DEVICE");
407 defaults->update(string, x11_host);
408 defaults->update("X11_USE_FIELDS", x11_use_fields);
410 sprintf(string, "VFIREWIRE_OUT_CHANNEL");
411 defaults->update(string, firewire_channel);
412 sprintf(string, "VFIREWIRE_OUT_PORT");
413 defaults->update(string, firewire_port);
414 sprintf(string, "VFIREWIRE_OUT_PATH");
415 defaults->update(string, firewire_path);
416 sprintf(string, "VFIREWIRE_OUT_SYT");
417 defaults->update(string, firewire_syt);
419 sprintf(string, "VDV1394_OUT_CHANNEL");
420 defaults->update(string, dv1394_channel);
421 sprintf(string, "VDV1394_OUT_PORT");
422 defaults->update(string, dv1394_port);
423 sprintf(string, "VDV1394_OUT_PATH");
424 defaults->update(string, dv1394_path);
425 sprintf(string, "VDV1394_OUT_SYT");
426 defaults->update(string, dv1394_syt);
430 int VideoOutConfig::total_playable_channels()
433 for(int i = 0; i < MAXCHANNELS; i++)
434 if(do_channel[i]) result++;
446 PlaybackConfig::PlaybackConfig()
448 aconfig = new AudioOutConfig(0);
449 vconfig = new VideoOutConfig;
450 sprintf(hostname, "localhost");
454 PlaybackConfig::~PlaybackConfig()
460 PlaybackConfig& PlaybackConfig::operator=(PlaybackConfig &that)
466 void PlaybackConfig::copy_from(PlaybackConfig *src)
468 aconfig->copy_from(src->aconfig);
469 vconfig->copy_from(src->vconfig);
470 strcpy(hostname, src->hostname);
474 int PlaybackConfig::load_defaults(BC_Hash *defaults)
477 sprintf(string, "PLAYBACK_HOSTNAME");
478 defaults->get(string, hostname);
479 sprintf(string, "PLAYBACK_PORT");
480 port = defaults->get(string, port);
481 aconfig->load_defaults(defaults);
482 vconfig->load_defaults(defaults);
486 int PlaybackConfig::save_defaults(BC_Hash *defaults)
489 sprintf(string, "PLAYBACK_HOSTNAME");
490 defaults->update(string, hostname);
491 sprintf(string, "PLAYBACK_PORT");
492 defaults->update(string, port);
493 aconfig->save_defaults(defaults);
494 vconfig->save_defaults(defaults);