1 #include "adeviceprefs.h"
2 #include "adrivermenu.h"
3 #include "audioconfig.h"
4 #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()
43 BC_PopupTextBox *popup;
45 //printf("PlaybackPrefs::create_objects 1\n");
46 current_head = mwindow->defaults->get("PLAYBACK_HEAD", 0);
47 strategies.append(new BC_ListBoxItem(_("Local Host")));
48 strategies.append(new BC_ListBoxItem(_("Multihead")));
49 strategies.append(new BC_ListBoxItem(_("Blond Symphony")));
51 // add_subwindow(new BC_Title(x, y, _("Playback"), LARGEFONT, BLACK));
53 // add_subwindow(new BC_Title(x, y, _("Strategy:")));
54 // popup = new PlaybackStrategy(this, x + 70, y);
55 // popup->create_objects();
57 // y += popup->get_h() + 30;
59 // Global playback options
61 // All strategies use these
62 add_subwindow(new BC_Title(x, y, _("Audio Out"), LARGEFONT, BLACK));
64 add_subwindow(new BC_Title(x, y, _("Samples to read from disk at a time:"), MEDIUMFONT, BLACK));
65 sprintf(string, "%d", pwindow->thread->edl->session->audio_read_length);
66 add_subwindow(new PlaybackReadLength(x + 275, y, pwindow, this, string));
68 add_subwindow(new BC_Title(x, y, _("Samples to send to console at a time:"), MEDIUMFONT, BLACK));
69 sprintf(string, "%d", pwindow->thread->edl->session->audio_module_fragment);
70 add_subwindow(new PlaybackModuleFragment(x + 275, y, pwindow, this, string));
72 // add_subwindow(new PlaybackDisableNoEdits(pwindow, pwindow->thread->edl->session->test_playback_edits, y));
74 add_subwindow(new PlaybackViewFollows(pwindow, pwindow->thread->edl->session->view_follows_playback, y));
76 add_subwindow(new PlaybackSoftwareTimer(pwindow, pwindow->thread->edl->session->playback_software_position, y));
78 add_subwindow(new PlaybackRealTime(pwindow, pwindow->thread->edl->session->real_time_playback, y));
80 add_subwindow(new BC_Title(x, y, _("Audio Driver:")));
81 audio_device = new ADevicePrefs(x + 100,
85 current_config()->aconfig,
88 audio_device->initialize();
90 // Strategic playback options created here
91 set_strategy(pwindow->thread->edl->session->playback_strategy);
93 // add_subwindow(new BC_Title(x, y, _("Playback driver:"), MEDIUMFONT, BLACK));
94 // add_subwindow(new AudioDriverMenu(x, y + 20, out_device, &(pwindow->thread->preferences->aconfig->audio_out_driver), 0, 1));
97 add_subwindow(new BC_Title(x, y, _("Video Out"), LARGEFONT, BLACK));
100 add_subwindow(new VideoEveryFrame(pwindow, x, y));
102 add_subwindow(new BC_Title(x + 200, y + 10, _("Framerate achieved:")));
103 add_subwindow(framerate_title = new BC_Title(x + 350, y + 10, _("--"), MEDIUMFONT, RED));
107 add_subwindow(new BC_Title(x, y, _("Scaling equation:")));
109 add_subwindow(nearest_neighbor = new PlaybackNearest(pwindow,
111 pwindow->thread->edl->session->interpolation_type == NEAREST_NEIGHBOR,
115 add_subwindow(cubic_linear = new PlaybackBicubicBilinear(pwindow,
117 pwindow->thread->edl->session->interpolation_type == CUBIC_LINEAR,
121 add_subwindow(linear_linear = new PlaybackBilinearBilinear(pwindow,
123 pwindow->thread->edl->session->interpolation_type == LINEAR_LINEAR,
128 add_subwindow(new BC_Title(x, y, _("Preload buffer for Quicktime:"), MEDIUMFONT, BLACK));
129 sprintf(string, "%d", pwindow->thread->edl->session->playback_preload);
130 add_subwindow(new PlaybackPreload(x + 210, y, pwindow, this, string));
133 // add_subwindow(new PlaybackDeblock(pwindow, 10, y));
136 add_subwindow(vdevice_title = new BC_Title(x, y, _("Video Driver:")));
137 video_device = new VDevicePrefs(x + 100,
141 current_config()->vconfig,
144 video_device->initialize();
146 // Strategic playback options created here
147 // set_strategy(pwindow->thread->edl->session->playback_strategy, y);
153 char* PlaybackPrefs::strategy_to_string(int strategy)
157 case PLAYBACK_LOCALHOST:
158 return _("Local Host");
160 case PLAYBACK_MULTIHEAD:
161 return _("Multihead");
163 case PLAYBACK_BLONDSYMPHONY:
164 return _("Blond Symphony");
167 return _("Local Host");
170 // Delete strategy dependant objects
171 void PlaybackPrefs::delete_strategy()
187 delete head_count_title;
188 delete head_count_text;
193 delete vdevice_title;
199 int PlaybackPrefs::set_strategy(int strategy)
201 int x = 350, x1 = 450, y = 10;
204 pwindow->thread->edl->session->playback_strategy = strategy;
207 case PLAYBACK_LOCALHOST:
209 case PLAYBACK_MULTIHEAD:
210 add_subwindow(head_title = new BC_Title(x, y, _("Head:")));
211 head_text = new PlaybackHead(this, x1, y);
212 head_text->create_objects();
214 add_subwindow(head_count_title = new BC_Title(x, y, _("Total Heads:")));
215 head_count_text = new PlaybackHeadCount(this, x1, y);
216 head_count_text->create_objects();
219 add_subwindow(vdevice_title = new BC_Title(x, y, _("Video Driver:")));
220 video_device = new VDevicePrefs(x + 100,
224 current_config()->vconfig,
227 video_device->initialize();
229 case PLAYBACK_BLONDSYMPHONY:
230 add_subwindow(head_title = new BC_Title(x, y, _("Head:")));
231 head_text = new PlaybackHead(this, x1, y);
232 head_text->create_objects();
234 add_subwindow(head_count_title = new BC_Title(x, y, _("Total Heads:")));
235 head_count_text = new PlaybackHeadCount(this, x1, y);
236 head_count_text->create_objects();
238 add_subwindow(host_title = new BC_Title(x, y, _("Hostname:")));
239 add_subwindow(host_text = new PlaybackHost(this, x1, y));
242 add_subwindow(vdevice_title = new BC_Title(x, y, _("Video Driver:")));
243 video_device = new VDevicePrefs(x + 100,
247 current_config()->vconfig,
250 video_device->initialize();
257 ArrayList<PlaybackConfig*>* PlaybackPrefs::current_config_list()
259 return &pwindow->thread->edl->session->playback_config[pwindow->thread->edl->session->playback_strategy];
262 PlaybackConfig* PlaybackPrefs::current_config()
264 return current_config_list()->values[current_head];
268 void PlaybackPrefs::update(int interpolation)
270 pwindow->thread->edl->session->interpolation_type = interpolation;
271 nearest_neighbor->update(interpolation == NEAREST_NEIGHBOR);
272 // cubic_cubic->update(interpolation == CUBIC_CUBIC);
273 cubic_linear->update(interpolation == CUBIC_LINEAR);
274 linear_linear->update(interpolation == LINEAR_LINEAR);
278 int PlaybackPrefs::get_buffer_bytes()
280 // return pwindow->thread->edl->aconfig->oss_out_bits / 8 * pwindow->thread->preferences->aconfig->oss_out_channels * pwindow->thread->preferences->playback_buffer;
283 int PlaybackPrefs::draw_framerate()
285 //printf("PlaybackPrefs::draw_framerate 1 %f\n", pwindow->thread->edl->session->actual_frame_rate);
286 char string[BCTEXTLEN];
287 sprintf(string, "%.4f", pwindow->thread->edl->session->actual_frame_rate);
288 framerate_title->update(string);
296 PlaybackStrategy::PlaybackStrategy(PlaybackPrefs *prefs,
299 : BC_PopupTextBox(prefs,
301 prefs->strategy_to_string(prefs->pwindow->thread->edl->session->playback_strategy),
310 int PlaybackStrategy::handle_event()
312 prefs->set_strategy(get_number());
320 PlaybackHead::PlaybackHead(PlaybackPrefs *prefs,
323 : BC_TumbleTextBox(prefs,
326 (int64_t)prefs->current_config_list()->total - 1,
334 int PlaybackHead::handle_event()
339 PlaybackHeadCount::PlaybackHeadCount(PlaybackPrefs *prefs,
342 : BC_TumbleTextBox(prefs,
343 prefs->current_config_list()->total,
353 int PlaybackHeadCount::handle_event()
360 PlaybackHost::PlaybackHost(PlaybackPrefs *prefs, int x, int y)
361 : BC_TextBox(x, y, 100, 1, prefs->current_config()->hostname)
366 int PlaybackHost::handle_event()
368 strcpy(prefs->current_config()->hostname, get_text());
375 PlaybackReadLength::PlaybackReadLength(int x, int y, PreferencesWindow *pwindow, PlaybackPrefs *playback, char *text)
376 : BC_TextBox(x, y, 100, 1, text)
378 this->pwindow = pwindow;
379 this->playback = playback;
382 int PlaybackReadLength::handle_event()
384 pwindow->thread->edl->session->audio_read_length = atol(get_text());
391 PlaybackModuleFragment::PlaybackModuleFragment(int x, int y, PreferencesWindow *pwindow, PlaybackPrefs *playback, char *text)
392 : BC_TextBox(x, y, 100, 1, text)
394 this->pwindow = pwindow;
397 int PlaybackModuleFragment::handle_event()
399 pwindow->thread->edl->session->audio_module_fragment = atol(get_text());
406 PlaybackBufferSize::PlaybackBufferSize(int x, int y, PreferencesWindow *pwindow, PlaybackPrefs *playback, char *text)
407 : BC_TextBox(x, y, 100, 1, text)
409 this->pwindow = pwindow;
410 this->playback = playback;
413 int PlaybackBufferSize::handle_event()
415 pwindow->thread->edl->session->playback_buffer = atol(get_text());
419 PlaybackBufferBytes::PlaybackBufferBytes(int x, int y, PreferencesWindow *pwindow, PlaybackPrefs *playback, char *text)
420 : BC_Title(x, y, text)
422 this->pwindow = pwindow;
423 this->playback = playback;
425 int PlaybackBufferBytes::update_bytes()
427 sprintf(string, "%d", playback->get_buffer_bytes());
432 PlaybackDisableNoEdits::PlaybackDisableNoEdits(PreferencesWindow *pwindow, int value, int y)
433 : BC_CheckBox(10, y, value, _("Disable tracks when no edits."))
435 this->pwindow = pwindow;
438 int PlaybackDisableNoEdits::handle_event()
440 pwindow->thread->edl->session->test_playback_edits = get_value();
447 PlaybackViewFollows::PlaybackViewFollows(PreferencesWindow *pwindow, int value, int y)
448 : BC_CheckBox(10, y, value, _("View follows playback"))
450 this->pwindow = pwindow;
453 int PlaybackViewFollows::handle_event()
455 pwindow->thread->edl->session->view_follows_playback = get_value();
462 PlaybackSoftwareTimer::PlaybackSoftwareTimer(PreferencesWindow *pwindow, int value, int y)
463 : BC_CheckBox(10, y, value, _("Use software for positioning information"))
465 this->pwindow = pwindow;
468 int PlaybackSoftwareTimer::handle_event()
470 pwindow->thread->edl->session->playback_software_position = get_value();
477 PlaybackRealTime::PlaybackRealTime(PreferencesWindow *pwindow, int value, int y)
478 : BC_CheckBox(10, y, value, _("Audio playback in real time priority (root only)"))
480 this->pwindow = pwindow;
483 int PlaybackRealTime::handle_event()
485 pwindow->thread->edl->session->real_time_playback = get_value();
495 PlaybackNearest::PlaybackNearest(PreferencesWindow *pwindow, PlaybackPrefs *prefs, int value, int x, int y)
496 : BC_Radial(x, y, value, _("Nearest neighbor enlarge and reduce"))
498 this->pwindow = pwindow;
501 int PlaybackNearest::handle_event()
503 prefs->update(NEAREST_NEIGHBOR);
511 PlaybackBicubicBicubic::PlaybackBicubicBicubic(PreferencesWindow *pwindow, PlaybackPrefs *prefs, int value, int x, int y)
512 : BC_Radial(x, y, value, _("Bicubic enlarge and reduce"))
514 this->pwindow = pwindow;
517 int PlaybackBicubicBicubic::handle_event()
519 prefs->update(CUBIC_CUBIC);
526 PlaybackBicubicBilinear::PlaybackBicubicBilinear(PreferencesWindow *pwindow, PlaybackPrefs *prefs, int value, int x, int y)
527 : BC_Radial(x, y, value, _("Bicubic enlarge and bilinear reduce"))
529 this->pwindow = pwindow;
532 int PlaybackBicubicBilinear::handle_event()
534 prefs->update(CUBIC_LINEAR);
539 PlaybackBilinearBilinear::PlaybackBilinearBilinear(PreferencesWindow *pwindow,
540 PlaybackPrefs *prefs,
544 : BC_Radial(x, y, value, _("Bilinear enlarge and bilinear reduce"))
546 this->pwindow = pwindow;
549 int PlaybackBilinearBilinear::handle_event()
551 prefs->update(LINEAR_LINEAR);
556 PlaybackPreload::PlaybackPreload(int x,
558 PreferencesWindow *pwindow,
559 PlaybackPrefs *playback,
561 : BC_TextBox(x, y, 100, 1, text)
563 this->pwindow = pwindow;
564 this->playback = playback;
567 int PlaybackPreload::handle_event()
569 pwindow->thread->edl->session->playback_preload = atol(get_text());
575 VideoEveryFrame::VideoEveryFrame(PreferencesWindow *pwindow, int x, int y)
576 : BC_CheckBox(x, y, pwindow->thread->edl->session->video_every_frame, _("Play every frame"))
578 this->pwindow = pwindow;
581 int VideoEveryFrame::handle_event()
583 pwindow->thread->edl->session->video_every_frame = get_value();
591 // PlaybackDeblock::PlaybackDeblock(PreferencesWindow *pwindow, int x, int y)
594 // pwindow->thread->edl->session->mpeg4_deblock,
595 // _("MPEG-4 Deblocking"))
597 // this->pwindow = pwindow;
600 // int PlaybackDeblock::handle_event()
602 // pwindow->thread->edl->session->mpeg4_deblock = get_value();