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;
52 PlaybackPrefs::~PlaybackPrefs()
60 void PlaybackPrefs::create_objects()
62 int xs5 = xS(5), xs10 = xS(10), xs30 = xS(30);
63 int ys5 = yS(5), ys30 = yS(30);
65 char string[BCTEXTLEN];
66 BC_WindowBase *window;
69 playback_config = pwindow->thread->edl->session->playback_config;
71 x = mwindow->theme->preferencesoptions_x;
72 y = mwindow->theme->preferencesoptions_y;
73 int margin = mwindow->theme->widget_border;
76 BC_Title *title1, *title2;
77 add_subwindow(title1 = new BC_Title(x, y, _("Audio Out"), LARGEFONT));
78 y += title1->get_h() + margin;
79 add_subwindow(title2 = new BC_Title(x, y, _("Playback buffer samples:"), MEDIUMFONT));
80 x2 = title2->get_x() + title2->get_w() + margin;
83 sprintf(string, "%d", playback_config->aconfig->fragment_size);
84 PlaybackModuleFragment *menu;
85 add_subwindow(menu = new PlaybackModuleFragment(x2, y, pwindow, this, string));
86 menu->add_item(new BC_MenuItem("1024"));
87 menu->add_item(new BC_MenuItem("2048"));
88 menu->add_item(new BC_MenuItem("4096"));
89 menu->add_item(new BC_MenuItem("8192"));
90 menu->add_item(new BC_MenuItem("16384"));
91 menu->add_item(new BC_MenuItem("32768"));
92 menu->add_item(new BC_MenuItem("65536"));
93 menu->add_item(new BC_MenuItem("131072"));
94 menu->add_item(new BC_MenuItem("262144"));
96 y += menu->get_h() + ys5;
98 add_subwindow(title1 = new BC_Title(x2, y, _("Audio offset (sec):")));
99 x2 += title1->get_w() + xs5;
100 audio_offset = new PlaybackAudioOffset(pwindow, this, x2, y);
101 audio_offset->create_objects();
102 y += audio_offset->get_h() + ys5;
105 add_subwindow(new PlaybackViewFollows(pwindow,
106 pwindow->thread->edl->session->view_follows_playback, y));
108 add_subwindow(new PlaybackSoftwareTimer(pwindow,
109 pwindow->thread->edl->session->playback_software_position, y));
111 add_subwindow(new PlaybackRealTime(pwindow,
112 pwindow->thread->edl->session->real_time_playback, y));
114 PlaybackMap51_2 *map51_2 = new PlaybackMap51_2(pwindow, this,
115 playback_config->aconfig->map51_2, y);
116 add_subwindow(map51_2);
117 x2 = map51_2->get_x() + map51_2->get_w() + xS(15);
118 y2 = y + BC_TextBox::calculate_h(this,MEDIUMFONT,1,1) - get_text_height(MEDIUMFONT);
120 add_subwindow(title2 = new BC_Title(x2, y2, _("Gain:")));
121 x2 += title2->get_w() + xS(8);
122 play_gain = new PlaybackGain(x2, y, pwindow, this);
123 play_gain->create_objects();
125 add_subwindow(new BC_Title(x, y, _("Audio Driver:")));
126 audio_device = new ADevicePrefs(x + xS(100), y, pwindow,
127 this, playback_config->aconfig, 0, MODEPLAY);
128 audio_device->initialize(0);
131 y += audio_device->get_h(0) + margin;
134 add_subwindow(new BC_Bar(x, y, get_w() - x * 2));
138 add_subwindow(title1 = new BC_Title(x, y, _("Video Out"), LARGEFONT));
139 y += title1->get_h() + margin;
142 add_subwindow(window = new VideoEveryFrame(pwindow, this, x, y));
143 int x1 = x + window->get_w() + xs30;
144 const char *txt = _("Framerate achieved:");
145 int y1 = y + (window->get_h() - BC_Title::calculate_h(this, txt)) / 2;
146 add_subwindow(title1 = new BC_Title(x1, y1, txt));
147 x1 += title1->get_w() + margin;
148 add_subwindow(framerate_title = new BC_Title(x1, y1, "--", MEDIUMFONT, RED));
150 y += window->get_h() + 2*margin;
152 // add_subwindow(asynchronous = new VideoAsynchronous(pwindow, x, y));
153 // y += asynchronous->get_h() + ys10;
156 add_subwindow(title1 = new BC_Title(x, y, _("Scaling equation: Enlarge / Reduce ")));
157 VScalingEquation *vscaling_equation =
158 new VScalingEquation(x + title1->get_w() + xS(65), y,
159 &pwindow->thread->edl->session->interpolation_type);
160 add_subwindow(vscaling_equation);
161 vscaling_equation->create_objects();
165 add_subwindow(title1 = new BC_Title(x, y, _("DVD Subtitle to display:")));
166 PlaybackSubtitleNumber *subtitle_number;
167 x1 = x + title1->get_w() + margin;
168 subtitle_number = new PlaybackSubtitleNumber(x1, y, pwindow, this);
169 subtitle_number->create_objects();
171 x2 = x + title1->get_w() + xs10 + subtitle_number->get_w() + xS(85);
172 PlaybackSubtitle *subtitle_toggle;
173 x1 += subtitle_number->get_w() + margin;
174 add_subwindow(subtitle_toggle = new PlaybackSubtitle(x2, y, pwindow, this));
175 y += subtitle_toggle->get_h();
177 PlaybackLabelCells *label_cells_toggle;
178 add_subwindow(label_cells_toggle = new PlaybackLabelCells(x2, y, pwindow, this));
179 y2 = y + label_cells_toggle->get_h();
181 add_subwindow(title1=new BC_Title(x2, y2, _("TOC Program No:"), MEDIUMFONT));
182 PlaybackProgramNumber *program_number;
183 program_number = new PlaybackProgramNumber(
184 x2 + title1->get_w() + xs10, y2, pwindow, this);
185 program_number->create_objects();
187 add_subwindow(interpolate_raw = new PlaybackInterpolateRaw( x, y,
189 y += interpolate_raw->get_h() + margin;
191 add_subwindow(white_balance_raw = new PlaybackWhiteBalanceRaw(x, y,
193 if(!pwindow->thread->edl->session->interpolate_raw)
194 white_balance_raw->disable();
195 y += white_balance_raw->get_h() + margin;
197 add_subwindow(vdevice_title = new BC_Title(x, y, _("Video Driver:")));
198 y += vdevice_title->get_h() + margin;
199 video_device = new VDevicePrefs(x, y, pwindow, this,
200 playback_config->vconfig, 0, MODEPLAY);
201 video_device->initialize(0);
205 int PlaybackPrefs::draw_framerate(int flush)
207 //printf("PlaybackPrefs::draw_framerate 1 %f\n", mwindow->session->actual_frame_rate);
208 char string[BCTEXTLEN];
209 sprintf(string, "%.4f", mwindow->session->actual_frame_rate);
210 framerate_title->update(string, flush);
216 PlaybackAudioOffset::PlaybackAudioOffset(PreferencesWindow *pwindow,
217 PlaybackPrefs *playback, int x, int y)
218 : BC_TumbleTextBox(playback, playback->playback_config->aconfig->audio_offset,
219 -10.0, 10.0, x, y, xS(100))
221 this->pwindow = pwindow;
222 this->playback = playback;
227 int PlaybackAudioOffset::handle_event()
229 playback->playback_config->aconfig->audio_offset = atof(get_text());
236 PlaybackModuleFragment::PlaybackModuleFragment(int x, int y,
237 PreferencesWindow *pwindow, PlaybackPrefs *playback, char *text)
238 : BC_PopupMenu(x, y, xS(100), text, 1)
240 this->pwindow = pwindow;
241 this->playback = playback;
244 int PlaybackModuleFragment::handle_event()
246 playback->playback_config->aconfig->fragment_size = atol(get_text());
251 PlaybackViewFollows::PlaybackViewFollows(PreferencesWindow *pwindow, int value, int y)
252 : BC_CheckBox(xS(10), y, value, _("View follows playback"))
254 this->pwindow = pwindow;
257 int PlaybackViewFollows::handle_event()
259 pwindow->thread->edl->session->view_follows_playback = get_value();
264 PlaybackSoftwareTimer::PlaybackSoftwareTimer(PreferencesWindow *pwindow, int value, int y)
265 : BC_CheckBox(xS(10), y, value, _("Disable hardware synchronization"))
267 this->pwindow = pwindow;
270 int PlaybackSoftwareTimer::handle_event()
272 pwindow->thread->edl->session->playback_software_position = get_value();
277 PlaybackRealTime::PlaybackRealTime(PreferencesWindow *pwindow, int value, int y)
278 : BC_CheckBox(xS(10), y, value, _("Audio playback in real time priority (root only)"))
280 this->pwindow = pwindow;
283 int PlaybackRealTime::handle_event()
285 pwindow->thread->edl->session->real_time_playback = get_value();
290 PlaybackMap51_2::PlaybackMap51_2(PreferencesWindow *pwindow,
291 PlaybackPrefs *playback_prefs, int value, int y)
292 : BC_CheckBox(xS(10), y, value, _("Map 5.1->2"))
294 this->pwindow = pwindow;
295 this->playback_prefs = playback_prefs;
298 int PlaybackMap51_2::handle_event()
300 playback_prefs->playback_config->aconfig->map51_2 = get_value();
305 PlaybackInterpolateRaw::PlaybackInterpolateRaw( int x, int y,
306 PreferencesWindow *pwindow, PlaybackPrefs *playback)
307 : BC_CheckBox(x, y, pwindow->thread->edl->session->interpolate_raw,
308 _("Interpolate CR2 images"))
310 this->pwindow = pwindow;
311 this->playback = playback;
314 int PlaybackInterpolateRaw::handle_event()
316 pwindow->thread->edl->session->interpolate_raw = get_value();
317 if( !pwindow->thread->edl->session->interpolate_raw ) {
318 playback->white_balance_raw->update(0, 0);
319 playback->white_balance_raw->disable();
322 playback->white_balance_raw->update(pwindow->thread->edl->session->white_balance_raw, 0);
323 playback->white_balance_raw->enable();
328 PlaybackWhiteBalanceRaw::PlaybackWhiteBalanceRaw( int x, int y,
329 PreferencesWindow *pwindow, PlaybackPrefs *playback)
331 pwindow->thread->edl->session->interpolate_raw &&
332 pwindow->thread->edl->session->white_balance_raw,
333 _("White balance CR2 images"))
335 this->pwindow = pwindow;
336 this->playback = playback;
337 if(!pwindow->thread->edl->session->interpolate_raw) disable();
340 int PlaybackWhiteBalanceRaw::handle_event()
342 pwindow->thread->edl->session->white_balance_raw = get_value();
346 // VideoAsynchronous::VideoAsynchronous(PreferencesWindow *pwindow, int x, int y)
347 // : BC_CheckBox(x, y,
348 // pwindow->thread->edl->session->video_every_frame &&
349 // pwindow->thread->edl->session->video_asynchronous,
350 // _("Decode frames asynchronously"))
352 // this->pwindow = pwindow;
353 // if(!pwindow->thread->edl->session->video_every_frame)
357 // int VideoAsynchronous::handle_event()
359 // pwindow->thread->edl->session->video_asynchronous = get_value();
364 VideoEveryFrame::VideoEveryFrame(PreferencesWindow *pwindow,
365 PlaybackPrefs *playback_prefs, int x, int y)
366 : BC_CheckBox(x, y, pwindow->thread->edl->session->video_every_frame, _("Play every frame"))
368 this->pwindow = pwindow;
369 this->playback_prefs = playback_prefs;
372 int VideoEveryFrame::handle_event()
374 pwindow->thread->edl->session->video_every_frame = get_value();
375 // if(!pwindow->thread->edl->session->video_every_frame) {
376 // playback_prefs->asynchronous->update(0, 0);
377 // playback_prefs->asynchronous->disable();
380 // playback_prefs->asynchronous->update(pwindow->thread->edl->session->video_asynchronous, 0);
381 // playback_prefs->asynchronous->enable();
387 PlaybackSubtitle::PlaybackSubtitle(int x, int y,
388 PreferencesWindow *pwindow, PlaybackPrefs *playback)
390 pwindow->thread->edl->session->decode_subtitles,
391 _("Enable subtitles/captioning"))
393 this->pwindow = pwindow;
394 this->playback = playback;
397 int PlaybackSubtitle::handle_event()
399 pwindow->thread->edl->session->decode_subtitles = get_value();
404 PlaybackSubtitleNumber::PlaybackSubtitleNumber(int x, int y,
405 PreferencesWindow *pwindow, PlaybackPrefs *playback)
406 : BC_TumbleTextBox(playback, pwindow->thread->edl->session->subtitle_number,
409 this->pwindow = pwindow;
410 this->playback = playback;
413 int PlaybackSubtitleNumber::handle_event()
415 pwindow->thread->edl->session->subtitle_number = atoi(get_text());
420 PlaybackLabelCells::PlaybackLabelCells(int x, int y,
421 PreferencesWindow *pwindow, PlaybackPrefs *playback)
423 pwindow->thread->edl->session->label_cells,
426 this->pwindow = pwindow;
427 this->playback = playback;
430 int PlaybackLabelCells::handle_event()
432 pwindow->thread->edl->session->label_cells = get_value();
437 PlaybackProgramNumber::PlaybackProgramNumber(int x, int y,
438 PreferencesWindow *pwindow, PlaybackPrefs *playback)
439 : BC_TumbleTextBox(playback,
440 pwindow->thread->edl->session->program_no,
443 this->pwindow = pwindow;
444 this->playback = playback;
447 int PlaybackProgramNumber::handle_event()
449 pwindow->thread->edl->session->program_no = atoi(get_text());
453 PlaybackGain::PlaybackGain(int x, int y,
454 PreferencesWindow *pwindow, PlaybackPrefs *playback)
455 : BC_TumbleTextBox(playback,
456 pwindow->thread->edl->session->playback_config->aconfig->play_gain,
457 0.0001f, 10000.0f, x, y, xS(72))
459 this->pwindow = pwindow;
460 this->set_increment(0.1);
463 int PlaybackGain::handle_event()
465 pwindow->thread->edl->session->playback_config->
466 aconfig->play_gain = atof(get_text());