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()
63 char string[BCTEXTLEN];
64 BC_WindowBase *window;
67 playback_config = pwindow->thread->edl->session->playback_config;
69 x = mwindow->theme->preferencesoptions_x;
70 y = mwindow->theme->preferencesoptions_y;
71 //int margin = mwindow->theme->widget_border;
74 add_subwindow(new BC_Title(x,
80 y += get_text_height(LARGEFONT) + 5;
83 BC_Title *title1, *title2;
84 add_subwindow(title2 = new BC_Title(x, y, _("Playback buffer samples:"), MEDIUMFONT));
85 x2 = MAX(title2->get_w(), title2->get_w()) + 10;
88 sprintf(string, "%d", playback_config->aconfig->fragment_size);
89 PlaybackModuleFragment *menu;
90 add_subwindow(menu = new PlaybackModuleFragment(x2,
95 menu->add_item(new BC_MenuItem("1024"));
96 menu->add_item(new BC_MenuItem("2048"));
97 menu->add_item(new BC_MenuItem("4096"));
98 menu->add_item(new BC_MenuItem("8192"));
99 menu->add_item(new BC_MenuItem("16384"));
100 menu->add_item(new BC_MenuItem("32768"));
101 menu->add_item(new BC_MenuItem("65536"));
102 menu->add_item(new BC_MenuItem("131072"));
103 menu->add_item(new BC_MenuItem("262144"));
105 y += menu->get_h() + 5;
107 add_subwindow(title1 = new BC_Title(x2, y, _("Audio offset (sec):")));
108 x2 += title1->get_w() + 5;
109 audio_offset = new PlaybackAudioOffset(pwindow, this, x2, y);
110 audio_offset->create_objects();
111 y += audio_offset->get_h() + 5;
114 add_subwindow(new PlaybackViewFollows(pwindow,
115 pwindow->thread->edl->session->view_follows_playback, y));
117 add_subwindow(new PlaybackSoftwareTimer(pwindow,
118 pwindow->thread->edl->session->playback_software_position, y));
120 add_subwindow(new PlaybackRealTime(pwindow,
121 pwindow->thread->edl->session->real_time_playback, y));
123 PlaybackMap51_2 *map51_2 = new PlaybackMap51_2(pwindow, this,
124 playback_config->aconfig->map51_2, y);
125 add_subwindow(map51_2);
126 x2 = map51_2->get_x() + map51_2->get_w() + 15;
127 y2 = y + BC_TextBox::calculate_h(this,MEDIUMFONT,1,1) - get_text_height(MEDIUMFONT);
129 add_subwindow(title2 = new BC_Title(x2, y2, _("Gain:")));
130 x2 += title2->get_w() + 8;
131 play_gain = new PlaybackGain(x2, y, pwindow, this);
132 play_gain->create_objects();
134 add_subwindow(new BC_Title(x, y, _("Audio Driver:")));
135 audio_device = new ADevicePrefs(x + 100, y, pwindow,
136 this, playback_config->aconfig, 0, MODEPLAY);
137 audio_device->initialize(0);
144 y += audio_device->get_h();
147 add_subwindow(new BC_Bar(5, y, get_w() - 10));
151 add_subwindow(new BC_Title(x, y, _("Video Out"), LARGEFONT));
155 add_subwindow(window = new VideoEveryFrame(pwindow, this, x, y));
157 add_subwindow(new BC_Title(x + 200, y + 5, _("Framerate achieved:")));
158 add_subwindow(framerate_title = new BC_Title(x + 350, y + 5, "--", MEDIUMFONT, RED));
160 y += window->get_h() + 5;
162 add_subwindow(asynchronous = new VideoAsynchronous(pwindow, x, y));
163 y += asynchronous->get_h() + 10;
166 add_subwindow(title1 = new BC_Title(x, y, _("Scaling equation: Enlarge / Reduce ")));
167 VScalingEquation *vscaling_equation =
168 new VScalingEquation(x + title1->get_w() + 10, y,
169 &pwindow->thread->edl->session->interpolation_type);
170 add_subwindow(vscaling_equation);
171 vscaling_equation->create_objects();
175 add_subwindow(title1 = new BC_Title(x, y, _("DVD Subtitle to display:")));
176 PlaybackSubtitleNumber *subtitle_number;
177 subtitle_number = new PlaybackSubtitleNumber(x + title1->get_w() + 10,
181 subtitle_number->create_objects();
183 x2 = x + title1->get_w() + 10 + subtitle_number->get_w() + 30;
184 PlaybackSubtitle *subtitle_toggle;
185 add_subwindow(subtitle_toggle = new PlaybackSubtitle(x2, y, pwindow, this));
186 y += subtitle_toggle->get_h();
188 PlaybackLabelCells *label_cells_toggle;
189 add_subwindow(label_cells_toggle = new PlaybackLabelCells(x2, y, pwindow, this));
190 y2 = y + label_cells_toggle->get_h();
192 add_subwindow(title1=new BC_Title(x2, y2, _("TOC Program No:"), MEDIUMFONT));
193 PlaybackProgramNumber *program_number;
194 program_number = new PlaybackProgramNumber(
195 x2 + title1->get_w() + 10, y2, pwindow, this);
196 program_number->create_objects();
198 add_subwindow(interpolate_raw = new PlaybackInterpolateRaw( x, y,
200 y += interpolate_raw->get_h();
202 add_subwindow(white_balance_raw = new PlaybackWhiteBalanceRaw( x, y,
204 y += white_balance_raw->get_h() + 10;
205 if(!pwindow->thread->edl->session->interpolate_raw)
206 white_balance_raw->disable();
208 y += white_balance_raw->get_h() + 5;
209 add_subwindow(vdevice_title = new BC_Title(x, y, _("Video Driver:")));
210 video_device = new VDevicePrefs(x + vdevice_title->get_w() + 10, y,
211 pwindow, this, playback_config->vconfig, 0, MODEPLAY);
212 video_device->initialize(0);
216 int PlaybackPrefs::draw_framerate(int flush)
218 //printf("PlaybackPrefs::draw_framerate 1 %f\n", mwindow->session->actual_frame_rate);
219 char string[BCTEXTLEN];
220 sprintf(string, "%.4f", mwindow->session->actual_frame_rate);
221 framerate_title->update(string, flush);
227 PlaybackAudioOffset::PlaybackAudioOffset(PreferencesWindow *pwindow,
228 PlaybackPrefs *playback, int x, int y)
229 : BC_TumbleTextBox(playback, playback->playback_config->aconfig->audio_offset,
230 -10.0, 10.0, x, y, 100)
232 this->pwindow = pwindow;
233 this->playback = playback;
238 int PlaybackAudioOffset::handle_event()
240 playback->playback_config->aconfig->audio_offset = atof(get_text());
247 PlaybackModuleFragment::PlaybackModuleFragment(int x, int y,
248 PreferencesWindow *pwindow, PlaybackPrefs *playback, char *text)
249 : BC_PopupMenu(x, y, 100, text, 1)
251 this->pwindow = pwindow;
252 this->playback = playback;
255 int PlaybackModuleFragment::handle_event()
257 playback->playback_config->aconfig->fragment_size = atol(get_text());
262 PlaybackViewFollows::PlaybackViewFollows(PreferencesWindow *pwindow, int value, int y)
263 : BC_CheckBox(10, y, value, _("View follows playback"))
265 this->pwindow = pwindow;
268 int PlaybackViewFollows::handle_event()
270 pwindow->thread->edl->session->view_follows_playback = get_value();
275 PlaybackSoftwareTimer::PlaybackSoftwareTimer(PreferencesWindow *pwindow, int value, int y)
276 : BC_CheckBox(10, y, value, _("Disable hardware synchronization"))
278 this->pwindow = pwindow;
281 int PlaybackSoftwareTimer::handle_event()
283 pwindow->thread->edl->session->playback_software_position = get_value();
288 PlaybackRealTime::PlaybackRealTime(PreferencesWindow *pwindow, int value, int y)
289 : BC_CheckBox(10, y, value, _("Audio playback in real time priority (root only)"))
291 this->pwindow = pwindow;
294 int PlaybackRealTime::handle_event()
296 pwindow->thread->edl->session->real_time_playback = get_value();
301 PlaybackMap51_2::PlaybackMap51_2(PreferencesWindow *pwindow,
302 PlaybackPrefs *playback_prefs, int value, int y)
303 : BC_CheckBox(10, y, value, _("Map 5.1->2"))
305 this->pwindow = pwindow;
306 this->playback_prefs = playback_prefs;
309 int PlaybackMap51_2::handle_event()
311 playback_prefs->playback_config->aconfig->map51_2 = get_value();
316 PlaybackInterpolateRaw::PlaybackInterpolateRaw( int x, int y,
317 PreferencesWindow *pwindow, PlaybackPrefs *playback)
320 pwindow->thread->edl->session->interpolate_raw,
321 _("Interpolate CR2 images"))
323 this->pwindow = pwindow;
324 this->playback = playback;
327 int PlaybackInterpolateRaw::handle_event()
329 pwindow->thread->edl->session->interpolate_raw = get_value();
330 if(!pwindow->thread->edl->session->interpolate_raw) {
331 playback->white_balance_raw->update(0, 0);
332 playback->white_balance_raw->disable();
335 playback->white_balance_raw->update(pwindow->thread->edl->session->white_balance_raw, 0);
336 playback->white_balance_raw->enable();
342 PlaybackWhiteBalanceRaw::PlaybackWhiteBalanceRaw( int x, int y,
343 PreferencesWindow *pwindow, PlaybackPrefs *playback)
346 pwindow->thread->edl->session->interpolate_raw &&
347 pwindow->thread->edl->session->white_balance_raw,
348 _("White balance CR2 images"))
350 this->pwindow = pwindow;
351 this->playback = playback;
352 if(!pwindow->thread->edl->session->interpolate_raw) disable();
355 int PlaybackWhiteBalanceRaw::handle_event()
357 pwindow->thread->edl->session->white_balance_raw = get_value();
362 VideoAsynchronous::VideoAsynchronous(PreferencesWindow *pwindow, int x, int y)
364 pwindow->thread->edl->session->video_every_frame &&
365 pwindow->thread->edl->session->video_asynchronous,
366 _("Decode frames asynchronously"))
368 this->pwindow = pwindow;
369 if(!pwindow->thread->edl->session->video_every_frame)
373 int VideoAsynchronous::handle_event()
375 pwindow->thread->edl->session->video_asynchronous = get_value();
380 VideoEveryFrame::VideoEveryFrame(PreferencesWindow *pwindow,
381 PlaybackPrefs *playback_prefs, int x, int y)
382 : BC_CheckBox(x, y, pwindow->thread->edl->session->video_every_frame, _("Play every frame"))
384 this->pwindow = pwindow;
385 this->playback_prefs = playback_prefs;
388 int VideoEveryFrame::handle_event()
390 pwindow->thread->edl->session->video_every_frame = get_value();
391 if(!pwindow->thread->edl->session->video_every_frame) {
392 playback_prefs->asynchronous->update(0, 0);
393 playback_prefs->asynchronous->disable();
396 playback_prefs->asynchronous->update(pwindow->thread->edl->session->video_asynchronous, 0);
397 playback_prefs->asynchronous->enable();
403 PlaybackSubtitle::PlaybackSubtitle(int x, int y,
404 PreferencesWindow *pwindow, PlaybackPrefs *playback)
406 pwindow->thread->edl->session->decode_subtitles,
407 _("Enable subtitles/captioning"))
409 this->pwindow = pwindow;
410 this->playback = playback;
413 int PlaybackSubtitle::handle_event()
415 pwindow->thread->edl->session->decode_subtitles = get_value();
420 PlaybackSubtitleNumber::PlaybackSubtitleNumber(int x, int y,
421 PreferencesWindow *pwindow, PlaybackPrefs *playback)
422 : BC_TumbleTextBox(playback, pwindow->thread->edl->session->subtitle_number,
425 this->pwindow = pwindow;
426 this->playback = playback;
429 int PlaybackSubtitleNumber::handle_event()
431 pwindow->thread->edl->session->subtitle_number = atoi(get_text());
436 PlaybackLabelCells::PlaybackLabelCells(int x, int y,
437 PreferencesWindow *pwindow, PlaybackPrefs *playback)
439 pwindow->thread->edl->session->label_cells,
442 this->pwindow = pwindow;
443 this->playback = playback;
446 int PlaybackLabelCells::handle_event()
448 pwindow->thread->edl->session->label_cells = get_value();
453 PlaybackProgramNumber::PlaybackProgramNumber(int x, int y,
454 PreferencesWindow *pwindow, PlaybackPrefs *playback)
455 : BC_TumbleTextBox(playback,
456 pwindow->thread->edl->session->program_no,
459 this->pwindow = pwindow;
460 this->playback = playback;
463 int PlaybackProgramNumber::handle_event()
465 pwindow->thread->edl->session->program_no = atoi(get_text());
469 PlaybackGain::PlaybackGain(int x, int y,
470 PreferencesWindow *pwindow, PlaybackPrefs *playback)
471 : BC_TumbleTextBox(playback,
472 pwindow->thread->edl->session->playback_config->aconfig->play_gain,
473 0.0001f, 10000.0f, x, y, 72)
475 this->pwindow = pwindow;
476 this->set_increment(0.1);
479 int PlaybackGain::handle_event()
481 pwindow->thread->edl->session->playback_config->
482 aconfig->play_gain = atof(get_text());