4 * Copyright (C) 2010 Adam Williams <broadcast at earthling dot net>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 #include "adeviceprefs.h"
23 #include "audioconfig.h"
24 #include "audiodevice.inc"
25 #include "bcsignals.h"
29 #include "edlsession.h"
31 #include "mainsession.h"
33 #include "overlayframe.inc"
34 #include "playbackprefs.h"
35 #include "preferences.h"
37 #include "vdeviceprefs.h"
38 #include "videodevice.inc"
42 PlaybackPrefs::PlaybackPrefs(MWindow *mwindow, PreferencesWindow *pwindow, int config_number)
43 : PreferencesDialog(mwindow, pwindow)
45 this->config_number = config_number;
50 // *** CONTEXT_HELP ***
51 context_help_set_keyword("Playback A \\/ Playback B");
54 PlaybackPrefs::~PlaybackPrefs()
62 void PlaybackPrefs::create_objects()
64 int xs5 = xS(5), xs10 = xS(10), xs30 = xS(30);
65 int ys5 = yS(5), ys30 = yS(30);
67 char string[BCTEXTLEN];
68 BC_WindowBase *window;
71 playback_config = pwindow->thread->edl->session->playback_config;
73 x = mwindow->theme->preferencesoptions_x;
74 y = mwindow->theme->preferencesoptions_y;
75 int margin = mwindow->theme->widget_border;
78 BC_Title *title1, *title2;
79 add_subwindow(title1 = new BC_Title(x, y, _("Audio Out"), LARGEFONT));
80 title1->context_help_set_keyword("Audio Out section");
81 y += title1->get_h() + margin;
82 add_subwindow(title2 = new BC_Title(x, y, _("Playback buffer samples:"), MEDIUMFONT));
83 title2->context_help_set_keyword("Audio Out section");
84 x2 = title2->get_x() + title2->get_w() + margin;
87 sprintf(string, "%d", playback_config->aconfig->fragment_size);
88 PlaybackModuleFragment *menu;
89 add_subwindow(menu = new PlaybackModuleFragment(x2, y, pwindow, this, string));
90 menu->add_item(new BC_MenuItem("1024"));
91 menu->add_item(new BC_MenuItem("2048"));
92 menu->add_item(new BC_MenuItem("4096"));
93 menu->add_item(new BC_MenuItem("8192"));
94 menu->add_item(new BC_MenuItem("16384"));
95 menu->add_item(new BC_MenuItem("32768"));
96 menu->add_item(new BC_MenuItem("65536"));
97 menu->add_item(new BC_MenuItem("131072"));
98 menu->add_item(new BC_MenuItem("262144"));
99 menu->context_help_set_keyword("Audio Out section");
101 y += menu->get_h() + ys5;
103 add_subwindow(title1 = new BC_Title(x2, y, _("Audio offset (sec):")));
104 title1->context_help_set_keyword("Audio Out section");
105 x2 += title1->get_w() + xs5;
106 audio_offset = new PlaybackAudioOffset(pwindow, this, x2, y);
107 audio_offset->create_objects();
108 y += audio_offset->get_h() + ys5;
111 add_subwindow(new PlaybackViewFollows(pwindow,
112 pwindow->thread->edl->session->view_follows_playback, y));
114 add_subwindow(new PlaybackSoftwareTimer(pwindow,
115 pwindow->thread->edl->session->playback_software_position, y));
117 add_subwindow(new PlaybackRealTime(pwindow,
118 pwindow->thread->edl->session->real_time_playback, y));
120 PlaybackMap51_2 *map51_2 = new PlaybackMap51_2(pwindow, this,
121 playback_config->aconfig->map51_2, y);
122 add_subwindow(map51_2);
123 map51_2->context_help_set_keyword("Audio Out section");
124 x2 = map51_2->get_x() + map51_2->get_w() + xS(15);
125 y2 = y + BC_TextBox::calculate_h(this,MEDIUMFONT,1,1) - get_text_height(MEDIUMFONT);
127 add_subwindow(title2 = new BC_Title(x2, y2, _("Gain:")));
128 title2->context_help_set_keyword("Audio Out section");
129 x2 += title2->get_w() + xS(8);
130 play_gain = new PlaybackGain(x2, y, pwindow, this);
131 play_gain->create_objects();
133 add_subwindow(title1 = new BC_Title(x, y, _("Audio Driver:")));
134 title1->context_help_set_keyword("Audio Out section");
135 audio_device = new ADevicePrefs(x + xS(100), y, pwindow,
136 this, playback_config->aconfig, 0, MODEPLAY);
137 audio_device->initialize(0);
140 y += audio_device->get_h(0) + margin;
143 add_subwindow(new BC_Bar(x, y, get_w() - x * 2));
147 add_subwindow(title1 = new BC_Title(x, y, _("Video Out"), LARGEFONT));
148 title1->context_help_set_keyword("Video Out section");
149 y += title1->get_h() + margin;
152 add_subwindow(window = new VideoEveryFrame(pwindow, this, x, y));
153 window->context_help_set_keyword("Video Out section");
154 int x1 = x + window->get_w() + xs30;
155 const char *txt = _("Framerate achieved:");
156 int y1 = y + (window->get_h() - BC_Title::calculate_h(this, txt)) / 2;
157 add_subwindow(title1 = new BC_Title(x1, y1, txt));
158 title1->context_help_set_keyword("Video Out section");
159 x1 += title1->get_w() + margin;
160 add_subwindow(framerate_title = new BC_Title(x1, y1, "--", MEDIUMFONT, RED));
162 framerate_title->context_help_set_keyword("Video Out section");
163 y += window->get_h() + 2*margin;
165 // add_subwindow(asynchronous = new VideoAsynchronous(pwindow, x, y));
166 // y += asynchronous->get_h() + ys10;
169 add_subwindow(title1 = new BC_Title(x, y, _("Scaling equation: Enlarge / Reduce ")));
170 title1->context_help_set_keyword("Video Out section");
171 VScalingEquation *vscaling_equation =
172 new VScalingEquation(x + title1->get_w() + xS(65), y,
173 &pwindow->thread->edl->session->interpolation_type);
174 add_subwindow(vscaling_equation);
175 vscaling_equation->create_objects();
176 vscaling_equation->context_help_set_keyword("Video Out section");
180 add_subwindow(title1 = new BC_Title(x, y, _("DVD Subtitle to display:")));
181 title1->context_help_set_keyword("Video Out section");
182 PlaybackSubtitleNumber *subtitle_number;
183 x1 = x + title1->get_w() + margin;
184 subtitle_number = new PlaybackSubtitleNumber(x1, y, pwindow, this);
185 subtitle_number->create_objects();
187 x2 = x + title1->get_w() + xs10 + subtitle_number->get_w() + xS(85);
188 PlaybackSubtitle *subtitle_toggle;
189 x1 += subtitle_number->get_w() + margin;
190 add_subwindow(subtitle_toggle = new PlaybackSubtitle(x2, y, pwindow, this));
191 subtitle_toggle->context_help_set_keyword("Video Out section");
192 y += subtitle_toggle->get_h();
194 PlaybackLabelCells *label_cells_toggle;
195 add_subwindow(label_cells_toggle = new PlaybackLabelCells(x2, y, pwindow, this));
196 label_cells_toggle->context_help_set_keyword("Video Out section");
197 y2 = y + label_cells_toggle->get_h();
199 add_subwindow(title1=new BC_Title(x2, y2, _("TOC Program No:"), MEDIUMFONT));
200 title1->context_help_set_keyword("Video Out section");
201 PlaybackProgramNumber *program_number;
202 program_number = new PlaybackProgramNumber(
203 x2 + title1->get_w() + xs10, y2, pwindow, this);
204 program_number->create_objects();
206 add_subwindow(interpolate_raw = new PlaybackInterpolateRaw( x, y,
208 interpolate_raw->context_help_set_keyword("Video Out section");
209 y += interpolate_raw->get_h() + margin;
211 add_subwindow(white_balance_raw = new PlaybackWhiteBalanceRaw(x, y,
213 if(!pwindow->thread->edl->session->interpolate_raw)
214 white_balance_raw->disable();
215 white_balance_raw->context_help_set_keyword("Video Out section");
216 y += white_balance_raw->get_h() + margin;
218 add_subwindow(vdevice_title = new BC_Title(x, y, _("Video Driver:")));
219 vdevice_title->context_help_set_keyword("Video Out section");
220 y += vdevice_title->get_h() + margin;
221 video_device = new VDevicePrefs(x, y, pwindow, this,
222 playback_config->vconfig, 0, MODEPLAY);
223 video_device->initialize(0);
227 int PlaybackPrefs::draw_framerate(int flush)
229 //printf("PlaybackPrefs::draw_framerate 1 %f\n", mwindow->session->actual_frame_rate);
230 char string[BCTEXTLEN];
231 sprintf(string, "%.4f", mwindow->session->actual_frame_rate);
232 framerate_title->update(string, flush);
238 PlaybackAudioOffset::PlaybackAudioOffset(PreferencesWindow *pwindow,
239 PlaybackPrefs *playback, int x, int y)
240 : BC_TumbleTextBox(playback, playback->playback_config->aconfig->audio_offset,
241 -10.0, 10.0, x, y, xS(100))
243 this->pwindow = pwindow;
244 this->playback = playback;
249 int PlaybackAudioOffset::handle_event()
251 playback->playback_config->aconfig->audio_offset = atof(get_text());
258 PlaybackModuleFragment::PlaybackModuleFragment(int x, int y,
259 PreferencesWindow *pwindow, PlaybackPrefs *playback, char *text)
260 : BC_PopupMenu(x, y, xS(100), text, 1)
262 this->pwindow = pwindow;
263 this->playback = playback;
266 int PlaybackModuleFragment::handle_event()
268 playback->playback_config->aconfig->fragment_size = atol(get_text());
273 PlaybackViewFollows::PlaybackViewFollows(PreferencesWindow *pwindow, int value, int y)
274 : BC_CheckBox(xS(10), y, value, _("View follows playback"))
276 this->pwindow = pwindow;
277 // *** CONTEXT_HELP ***
278 context_help_set_keyword("Audio Out section");
281 int PlaybackViewFollows::handle_event()
283 pwindow->thread->edl->session->view_follows_playback = get_value();
288 PlaybackSoftwareTimer::PlaybackSoftwareTimer(PreferencesWindow *pwindow, int value, int y)
289 : BC_CheckBox(xS(10), y, value, _("Disable hardware synchronization"))
291 this->pwindow = pwindow;
292 // *** CONTEXT_HELP ***
293 context_help_set_keyword("Audio Out section");
296 int PlaybackSoftwareTimer::handle_event()
298 pwindow->thread->edl->session->playback_software_position = get_value();
303 PlaybackRealTime::PlaybackRealTime(PreferencesWindow *pwindow, int value, int y)
304 : BC_CheckBox(xS(10), y, value, _("Audio playback in real time priority (root only)"))
306 this->pwindow = pwindow;
307 // *** CONTEXT_HELP ***
308 context_help_set_keyword("Audio Out section");
311 int PlaybackRealTime::handle_event()
313 pwindow->thread->edl->session->real_time_playback = get_value();
318 PlaybackMap51_2::PlaybackMap51_2(PreferencesWindow *pwindow,
319 PlaybackPrefs *playback_prefs, int value, int y)
320 : BC_CheckBox(xS(10), y, value, _("Map 5.1->2"))
322 this->pwindow = pwindow;
323 this->playback_prefs = playback_prefs;
326 int PlaybackMap51_2::handle_event()
328 playback_prefs->playback_config->aconfig->map51_2 = get_value();
333 PlaybackInterpolateRaw::PlaybackInterpolateRaw( int x, int y,
334 PreferencesWindow *pwindow, PlaybackPrefs *playback)
335 : BC_CheckBox(x, y, pwindow->thread->edl->session->interpolate_raw,
336 _("Interpolate CR2 images"))
338 this->pwindow = pwindow;
339 this->playback = playback;
342 int PlaybackInterpolateRaw::handle_event()
344 pwindow->thread->edl->session->interpolate_raw = get_value();
345 if( !pwindow->thread->edl->session->interpolate_raw ) {
346 playback->white_balance_raw->update(0, 0);
347 playback->white_balance_raw->disable();
350 playback->white_balance_raw->update(pwindow->thread->edl->session->white_balance_raw, 0);
351 playback->white_balance_raw->enable();
356 PlaybackWhiteBalanceRaw::PlaybackWhiteBalanceRaw( int x, int y,
357 PreferencesWindow *pwindow, PlaybackPrefs *playback)
359 pwindow->thread->edl->session->interpolate_raw &&
360 pwindow->thread->edl->session->white_balance_raw,
361 _("White balance CR2 images"))
363 this->pwindow = pwindow;
364 this->playback = playback;
365 if(!pwindow->thread->edl->session->interpolate_raw) disable();
368 int PlaybackWhiteBalanceRaw::handle_event()
370 pwindow->thread->edl->session->white_balance_raw = get_value();
374 // VideoAsynchronous::VideoAsynchronous(PreferencesWindow *pwindow, int x, int y)
375 // : BC_CheckBox(x, y,
376 // pwindow->thread->edl->session->video_every_frame &&
377 // pwindow->thread->edl->session->video_asynchronous,
378 // _("Decode frames asynchronously"))
380 // this->pwindow = pwindow;
381 // if(!pwindow->thread->edl->session->video_every_frame)
385 // int VideoAsynchronous::handle_event()
387 // pwindow->thread->edl->session->video_asynchronous = get_value();
392 VideoEveryFrame::VideoEveryFrame(PreferencesWindow *pwindow,
393 PlaybackPrefs *playback_prefs, int x, int y)
394 : BC_CheckBox(x, y, pwindow->thread->edl->session->video_every_frame, _("Play every frame"))
396 this->pwindow = pwindow;
397 this->playback_prefs = playback_prefs;
400 int VideoEveryFrame::handle_event()
402 pwindow->thread->edl->session->video_every_frame = get_value();
403 // if(!pwindow->thread->edl->session->video_every_frame) {
404 // playback_prefs->asynchronous->update(0, 0);
405 // playback_prefs->asynchronous->disable();
408 // playback_prefs->asynchronous->update(pwindow->thread->edl->session->video_asynchronous, 0);
409 // playback_prefs->asynchronous->enable();
415 PlaybackSubtitle::PlaybackSubtitle(int x, int y,
416 PreferencesWindow *pwindow, PlaybackPrefs *playback)
418 pwindow->thread->edl->session->decode_subtitles,
419 _("Enable subtitles/captioning"))
421 this->pwindow = pwindow;
422 this->playback = playback;
425 int PlaybackSubtitle::handle_event()
427 pwindow->thread->edl->session->decode_subtitles = get_value();
432 PlaybackSubtitleNumber::PlaybackSubtitleNumber(int x, int y,
433 PreferencesWindow *pwindow, PlaybackPrefs *playback)
434 : BC_TumbleTextBox(playback, pwindow->thread->edl->session->subtitle_number,
437 this->pwindow = pwindow;
438 this->playback = playback;
441 int PlaybackSubtitleNumber::handle_event()
443 pwindow->thread->edl->session->subtitle_number = atoi(get_text());
448 PlaybackLabelCells::PlaybackLabelCells(int x, int y,
449 PreferencesWindow *pwindow, PlaybackPrefs *playback)
451 pwindow->thread->edl->session->label_cells,
454 this->pwindow = pwindow;
455 this->playback = playback;
458 int PlaybackLabelCells::handle_event()
460 pwindow->thread->edl->session->label_cells = get_value();
465 PlaybackProgramNumber::PlaybackProgramNumber(int x, int y,
466 PreferencesWindow *pwindow, PlaybackPrefs *playback)
467 : BC_TumbleTextBox(playback,
468 pwindow->thread->edl->session->program_no,
471 this->pwindow = pwindow;
472 this->playback = playback;
475 int PlaybackProgramNumber::handle_event()
477 pwindow->thread->edl->session->program_no = atoi(get_text());
481 PlaybackGain::PlaybackGain(int x, int y,
482 PreferencesWindow *pwindow, PlaybackPrefs *playback)
483 : BC_TumbleTextBox(playback,
484 pwindow->thread->edl->session->playback_config->aconfig->play_gain,
485 0.0001f, 10000.0f, x, y, xS(72))
487 this->pwindow = pwindow;
488 this->set_increment(0.1);
491 int PlaybackGain::handle_event()
493 pwindow->thread->edl->session->playback_config->
494 aconfig->play_gain = atof(get_text());