1 #include "adeviceprefs.h"
2 #include "audioconfig.h"
3 #include "audiodevice.inc"
7 #include "edlsession.h"
9 #include "overlayframe.inc"
10 #include "playbackprefs.h"
11 #include "preferences.h"
12 #include "vdeviceprefs.h"
13 #include "videodevice.inc"
17 #define _(String) gettext(String)
18 #define gettext_noop(String) String
19 #define N_(String) gettext_noop (String)
22 PlaybackPrefs::PlaybackPrefs(MWindow *mwindow, PreferencesWindow *pwindow)
23 : PreferencesDialog(mwindow, pwindow)
31 PlaybackPrefs::~PlaybackPrefs()
34 mwindow->defaults->update("PLAYBACK_HEAD", current_head);
39 int PlaybackPrefs::create_objects()
42 char string[BCTEXTLEN];
43 BC_PopupTextBox *popup;
45 current_head = mwindow->defaults->get("PLAYBACK_HEAD", 0);
46 strategies.append(new BC_ListBoxItem(_("Local Host")));
47 strategies.append(new BC_ListBoxItem(_("Multihead")));
48 strategies.append(new BC_ListBoxItem(_("Blond Symphony")));
50 // Global playback options
52 // All strategies use these
53 add_subwindow(new BC_Title(x, y, _("Audio Out"), LARGEFONT, BLACK));
58 BC_Title *title1, *title2;
59 add_subwindow(title1 = new BC_Title(x, y, _("Samples to read from disk at a time:"), MEDIUMFONT, BLACK));
60 add_subwindow(title2 = new BC_Title(x, y + 30, _("Samples to send to console at a time:"), MEDIUMFONT, BLACK));
61 x2 = MAX(title1->get_w(), title2->get_w()) + 10;
63 sprintf(string, "%d", pwindow->thread->edl->session->audio_read_length);
64 add_subwindow(new PlaybackReadLength(x2, y, pwindow, this, string));
65 sprintf(string, "%d", pwindow->thread->edl->session->audio_module_fragment);
66 add_subwindow(new PlaybackModuleFragment(x2, y + 30, pwindow, this, string));
70 add_subwindow(new PlaybackViewFollows(pwindow, pwindow->thread->edl->session->view_follows_playback, y));
72 add_subwindow(new PlaybackSoftwareTimer(pwindow, pwindow->thread->edl->session->playback_software_position, y));
74 add_subwindow(new PlaybackRealTime(pwindow, pwindow->thread->edl->session->real_time_playback, y));
76 add_subwindow(new BC_Title(x, y, _("Audio Driver:")));
77 audio_device = new ADevicePrefs(x + 100,
81 current_config()->aconfig,
84 audio_device->initialize();
86 // Strategic playback options created here
87 set_strategy(pwindow->thread->edl->session->playback_strategy);
89 // add_subwindow(new BC_Title(x, y, _("Playback driver:"), MEDIUMFONT, BLACK));
90 // add_subwindow(new AudioDriverMenu(x, y + 20, out_device, &(pwindow->thread->preferences->aconfig->audio_out_driver), 0, 1));
93 add_subwindow(new BC_Title(x, y, _("Video Out"), LARGEFONT, BLACK));
96 add_subwindow(new VideoEveryFrame(pwindow, x, y));
98 add_subwindow(new BC_Title(x + 200, y + 10, _("Framerate achieved:")));
99 add_subwindow(framerate_title = new BC_Title(x + 350, y + 10, _("--"), MEDIUMFONT, RED));
103 add_subwindow(new BC_Title(x, y, _("Scaling equation:")));
105 add_subwindow(nearest_neighbor = new PlaybackNearest(pwindow,
107 pwindow->thread->edl->session->interpolation_type == NEAREST_NEIGHBOR,
111 add_subwindow(cubic_linear = new PlaybackBicubicBilinear(pwindow,
113 pwindow->thread->edl->session->interpolation_type == CUBIC_LINEAR,
117 add_subwindow(linear_linear = new PlaybackBilinearBilinear(pwindow,
119 pwindow->thread->edl->session->interpolation_type == LINEAR_LINEAR,
124 add_subwindow(new BC_Title(x, y, _("Preload buffer for Quicktime:"), MEDIUMFONT, BLACK));
125 sprintf(string, "%d", pwindow->thread->edl->session->playback_preload);
126 add_subwindow(new PlaybackPreload(x + 210, y, pwindow, this, string));
129 // add_subwindow(new PlaybackDeblock(pwindow, 10, y));
132 add_subwindow(vdevice_title = new BC_Title(x, y, _("Video Driver:")));
133 video_device = new VDevicePrefs(x + 100,
137 current_config()->vconfig,
140 video_device->initialize();
142 // Strategic playback options created here
143 // set_strategy(pwindow->thread->edl->session->playback_strategy, y);
149 char* PlaybackPrefs::strategy_to_string(int strategy)
153 case PLAYBACK_LOCALHOST:
154 return _("Local Host");
156 case PLAYBACK_MULTIHEAD:
157 return _("Multihead");
159 case PLAYBACK_BLONDSYMPHONY:
160 return _("Blond Symphony");
163 return _("Local Host");
166 // Delete strategy dependant objects
167 void PlaybackPrefs::delete_strategy()
183 delete head_count_title;
184 delete head_count_text;
189 delete vdevice_title;
195 int PlaybackPrefs::set_strategy(int strategy)
197 int x = 350, x1 = 450, y = 10;
200 pwindow->thread->edl->session->playback_strategy = strategy;
203 case PLAYBACK_LOCALHOST:
205 case PLAYBACK_MULTIHEAD:
206 add_subwindow(head_title = new BC_Title(x, y, _("Head:")));
207 head_text = new PlaybackHead(this, x1, y);
208 head_text->create_objects();
210 add_subwindow(head_count_title = new BC_Title(x, y, _("Total Heads:")));
211 head_count_text = new PlaybackHeadCount(this, x1, y);
212 head_count_text->create_objects();
215 add_subwindow(vdevice_title = new BC_Title(x, y, _("Video Driver:")));
216 video_device = new VDevicePrefs(x + 100,
220 current_config()->vconfig,
223 video_device->initialize();
225 case PLAYBACK_BLONDSYMPHONY:
226 add_subwindow(head_title = new BC_Title(x, y, _("Head:")));
227 head_text = new PlaybackHead(this, x1, y);
228 head_text->create_objects();
230 add_subwindow(head_count_title = new BC_Title(x, y, _("Total Heads:")));
231 head_count_text = new PlaybackHeadCount(this, x1, y);
232 head_count_text->create_objects();
234 add_subwindow(host_title = new BC_Title(x, y, _("Hostname:")));
235 add_subwindow(host_text = new PlaybackHost(this, x1, y));
238 add_subwindow(vdevice_title = new BC_Title(x, y, _("Video Driver:")));
239 video_device = new VDevicePrefs(x + 100,
243 current_config()->vconfig,
246 video_device->initialize();
253 ArrayList<PlaybackConfig*>* PlaybackPrefs::current_config_list()
255 return &pwindow->thread->edl->session->playback_config[pwindow->thread->edl->session->playback_strategy];
258 PlaybackConfig* PlaybackPrefs::current_config()
260 return current_config_list()->values[current_head];
264 void PlaybackPrefs::update(int interpolation)
266 pwindow->thread->edl->session->interpolation_type = interpolation;
267 nearest_neighbor->update(interpolation == NEAREST_NEIGHBOR);
268 // cubic_cubic->update(interpolation == CUBIC_CUBIC);
269 cubic_linear->update(interpolation == CUBIC_LINEAR);
270 linear_linear->update(interpolation == LINEAR_LINEAR);
274 int PlaybackPrefs::get_buffer_bytes()
276 // return pwindow->thread->edl->aconfig->oss_out_bits / 8 * pwindow->thread->preferences->aconfig->oss_out_channels * pwindow->thread->preferences->playback_buffer;
279 int PlaybackPrefs::draw_framerate()
281 //printf("PlaybackPrefs::draw_framerate 1 %f\n", pwindow->thread->edl->session->actual_frame_rate);
282 char string[BCTEXTLEN];
283 sprintf(string, "%.4f", pwindow->thread->edl->session->actual_frame_rate);
284 framerate_title->update(string);
292 PlaybackStrategy::PlaybackStrategy(PlaybackPrefs *prefs,
295 : BC_PopupTextBox(prefs,
297 prefs->strategy_to_string(prefs->pwindow->thread->edl->session->playback_strategy),
306 int PlaybackStrategy::handle_event()
308 prefs->set_strategy(get_number());
316 PlaybackHead::PlaybackHead(PlaybackPrefs *prefs,
319 : BC_TumbleTextBox(prefs,
322 (int64_t)prefs->current_config_list()->total - 1,
330 int PlaybackHead::handle_event()
335 PlaybackHeadCount::PlaybackHeadCount(PlaybackPrefs *prefs,
338 : BC_TumbleTextBox(prefs,
339 prefs->current_config_list()->total,
349 int PlaybackHeadCount::handle_event()
356 PlaybackHost::PlaybackHost(PlaybackPrefs *prefs, int x, int y)
357 : BC_TextBox(x, y, 100, 1, prefs->current_config()->hostname)
362 int PlaybackHost::handle_event()
364 strcpy(prefs->current_config()->hostname, get_text());
371 PlaybackReadLength::PlaybackReadLength(int x, int y, PreferencesWindow *pwindow, PlaybackPrefs *playback, char *text)
372 : BC_TextBox(x, y, 100, 1, text)
374 this->pwindow = pwindow;
375 this->playback = playback;
378 int PlaybackReadLength::handle_event()
380 pwindow->thread->edl->session->audio_read_length = atol(get_text());
387 PlaybackModuleFragment::PlaybackModuleFragment(int x, int y, PreferencesWindow *pwindow, PlaybackPrefs *playback, char *text)
388 : BC_TextBox(x, y, 100, 1, text)
390 this->pwindow = pwindow;
393 int PlaybackModuleFragment::handle_event()
395 pwindow->thread->edl->session->audio_module_fragment = atol(get_text());
402 PlaybackBufferSize::PlaybackBufferSize(int x, int y, PreferencesWindow *pwindow, PlaybackPrefs *playback, char *text)
403 : BC_TextBox(x, y, 100, 1, text)
405 this->pwindow = pwindow;
406 this->playback = playback;
409 int PlaybackBufferSize::handle_event()
411 pwindow->thread->edl->session->playback_buffer = atol(get_text());
415 PlaybackBufferBytes::PlaybackBufferBytes(int x, int y, PreferencesWindow *pwindow, PlaybackPrefs *playback, char *text)
416 : BC_Title(x, y, text)
418 this->pwindow = pwindow;
419 this->playback = playback;
421 int PlaybackBufferBytes::update_bytes()
423 sprintf(string, "%d", playback->get_buffer_bytes());
428 PlaybackDisableNoEdits::PlaybackDisableNoEdits(PreferencesWindow *pwindow, int value, int y)
429 : BC_CheckBox(10, y, value, _("Disable tracks when no edits."))
431 this->pwindow = pwindow;
434 int PlaybackDisableNoEdits::handle_event()
436 pwindow->thread->edl->session->test_playback_edits = get_value();
443 PlaybackViewFollows::PlaybackViewFollows(PreferencesWindow *pwindow, int value, int y)
444 : BC_CheckBox(10, y, value, _("View follows playback"))
446 this->pwindow = pwindow;
449 int PlaybackViewFollows::handle_event()
451 pwindow->thread->edl->session->view_follows_playback = get_value();
458 PlaybackSoftwareTimer::PlaybackSoftwareTimer(PreferencesWindow *pwindow, int value, int y)
459 : BC_CheckBox(10, y, value, _("Use software for positioning information"))
461 this->pwindow = pwindow;
464 int PlaybackSoftwareTimer::handle_event()
466 pwindow->thread->edl->session->playback_software_position = get_value();
473 PlaybackRealTime::PlaybackRealTime(PreferencesWindow *pwindow, int value, int y)
474 : BC_CheckBox(10, y, value, _("Audio playback in real time priority (root only)"))
476 this->pwindow = pwindow;
479 int PlaybackRealTime::handle_event()
481 pwindow->thread->edl->session->real_time_playback = get_value();
491 PlaybackNearest::PlaybackNearest(PreferencesWindow *pwindow, PlaybackPrefs *prefs, int value, int x, int y)
492 : BC_Radial(x, y, value, _("Nearest neighbor enlarge and reduce"))
494 this->pwindow = pwindow;
497 int PlaybackNearest::handle_event()
499 prefs->update(NEAREST_NEIGHBOR);
507 PlaybackBicubicBicubic::PlaybackBicubicBicubic(PreferencesWindow *pwindow, PlaybackPrefs *prefs, int value, int x, int y)
508 : BC_Radial(x, y, value, _("Bicubic enlarge and reduce"))
510 this->pwindow = pwindow;
513 int PlaybackBicubicBicubic::handle_event()
515 prefs->update(CUBIC_CUBIC);
522 PlaybackBicubicBilinear::PlaybackBicubicBilinear(PreferencesWindow *pwindow, PlaybackPrefs *prefs, int value, int x, int y)
523 : BC_Radial(x, y, value, _("Bicubic enlarge and bilinear reduce"))
525 this->pwindow = pwindow;
528 int PlaybackBicubicBilinear::handle_event()
530 prefs->update(CUBIC_LINEAR);
535 PlaybackBilinearBilinear::PlaybackBilinearBilinear(PreferencesWindow *pwindow,
536 PlaybackPrefs *prefs,
540 : BC_Radial(x, y, value, _("Bilinear enlarge and bilinear reduce"))
542 this->pwindow = pwindow;
545 int PlaybackBilinearBilinear::handle_event()
547 prefs->update(LINEAR_LINEAR);
552 PlaybackPreload::PlaybackPreload(int x,
554 PreferencesWindow *pwindow,
555 PlaybackPrefs *playback,
557 : BC_TextBox(x, y, 100, 1, text)
559 this->pwindow = pwindow;
560 this->playback = playback;
563 int PlaybackPreload::handle_event()
565 pwindow->thread->edl->session->playback_preload = atol(get_text());
571 VideoEveryFrame::VideoEveryFrame(PreferencesWindow *pwindow, int x, int y)
572 : BC_CheckBox(x, y, pwindow->thread->edl->session->video_every_frame, _("Play every frame"))
574 this->pwindow = pwindow;
577 int VideoEveryFrame::handle_event()
579 pwindow->thread->edl->session->video_every_frame = get_value();
587 // PlaybackDeblock::PlaybackDeblock(PreferencesWindow *pwindow, int x, int y)
590 // pwindow->thread->edl->session->mpeg4_deblock,
591 // _("MPEG-4 Deblocking"))
593 // this->pwindow = pwindow;
596 // int PlaybackDeblock::handle_event()
598 // pwindow->thread->edl->session->mpeg4_deblock = get_value();