r125: This commit was manufactured by cvs2svn to create tag 'r1_1_7-last'.
[cinelerra_cv/mob.git] / hvirtual / cinelerra / playbackprefs.C
blobff7b96833ae294ecdb7ec41135b46f7c0e2c5d9c
1 #include "adeviceprefs.h"
2 #include "adrivermenu.h"
3 #include "audioconfig.h"
4 #include "audiodevice.inc"
5 #include "defaults.h"
6 #include "edl.h"
7 #include "edlsession.h"
8 #include "mwindow.h"
9 #include "overlayframe.inc"
10 #include "playbackprefs.h"
11 #include "preferences.h"
12 #include "vdeviceprefs.h"
13 #include "videodevice.inc"
15 #include <string.h>
16 #include <libintl.h>
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)
25         head_text = 0;
26         head_count_text = 0;
27         host_text = 0;
28         video_device = 0;
31 PlaybackPrefs::~PlaybackPrefs()
33         delete_strategy();
34         mwindow->defaults->update("PLAYBACK_HEAD", current_head);
35         delete audio_device;
36         delete video_device;
39 int PlaybackPrefs::create_objects()
41         int x = 5, y = 5;
42         char string[1024];
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));
52 //      x += 200;
53 //      add_subwindow(new BC_Title(x, y, _("Strategy:")));
54 //      popup = new PlaybackStrategy(this, x + 70, y);
55 //      popup->create_objects();
56 //      x = 10;
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));
63         y += 30;
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));
67         y += 30;
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));
71         y += 30;
72 //      add_subwindow(new PlaybackDisableNoEdits(pwindow, pwindow->thread->edl->session->test_playback_edits, y));
73 //      y += 30;
74         add_subwindow(new PlaybackViewFollows(pwindow, pwindow->thread->edl->session->view_follows_playback, y));
75         y += 30;
76         add_subwindow(new PlaybackSoftwareTimer(pwindow, pwindow->thread->edl->session->playback_software_position, y));
77         y += 30;
78         add_subwindow(new PlaybackRealTime(pwindow, pwindow->thread->edl->session->real_time_playback, y));
79         y += 40;
80         add_subwindow(new BC_Title(x, y, _("Audio Driver:")));
81         audio_device = new ADevicePrefs(x + 100, 
82                 y, 
83                 pwindow, 
84                 this, 
85                 current_config()->aconfig, 
86                 0,
87                 MODEPLAY);
88         audio_device->initialize();
90 // Strategic playback options created here
91         set_strategy(pwindow->thread->edl->session->playback_strategy);
92 // 
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));
95         y += 60;
97         add_subwindow(new BC_Title(x, y, _("Video Out"), LARGEFONT, BLACK));
98         y += 30;
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));
104         draw_framerate();
106         y += 35;
107         add_subwindow(new BC_Title(x, y, _("Scaling equation:")));
108         y += 20;
109         add_subwindow(nearest_neighbor = new PlaybackNearest(pwindow, 
110                 this, 
111                 pwindow->thread->edl->session->interpolation_type == NEAREST_NEIGHBOR, 
112                 10, 
113                 y));
114         y += 20;
115         add_subwindow(cubic_linear = new PlaybackBicubicBilinear(pwindow, 
116                 this, 
117                 pwindow->thread->edl->session->interpolation_type == CUBIC_LINEAR, 
118                 10, 
119                 y));
120         y += 20;
121         add_subwindow(linear_linear = new PlaybackBilinearBilinear(pwindow, 
122                 this, 
123                 pwindow->thread->edl->session->interpolation_type == LINEAR_LINEAR, 
124                 10, 
125                 y));
127         y += 35;
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));
132 //      y += 30;
133 //      add_subwindow(new PlaybackDeblock(pwindow, 10, y));
135         y += 35;
136         add_subwindow(vdevice_title = new BC_Title(x, y, _("Video Driver:")));
137         video_device = new VDevicePrefs(x + 100, 
138                 y, 
139                 pwindow, 
140                 this, 
141                 current_config()->vconfig, 
142                 0,
143                 MODEPLAY);
144         video_device->initialize();
146 // Strategic playback options created here
147 //      set_strategy(pwindow->thread->edl->session->playback_strategy, y);
148         
150         return 0;
153 char* PlaybackPrefs::strategy_to_string(int strategy)
155         switch(strategy)
156         {
157                 case PLAYBACK_LOCALHOST:
158                         return _("Local Host");
159                         break;
160                 case PLAYBACK_MULTIHEAD:
161                         return _("Multihead");
162                         break;
163                 case PLAYBACK_BLONDSYMPHONY:
164                         return _("Blond Symphony");
165                         break;
166         }
167         return _("Local Host");
170 // Delete strategy dependant objects
171 void PlaybackPrefs::delete_strategy()
173         if(head_text) 
174         {
175                 delete head_text;
176                 delete head_title;
177                 head_text = 0;
178         }
179         if(host_text)
180         {
181                 delete host_title;
182                 delete host_text;
183                 host_text = 0;
184         }
185         if(head_count_text)
186         {
187                 delete head_count_title;
188                 delete head_count_text;
189                 head_count_text = 0;
190         }
191         if(video_device)
192         {
193                 delete vdevice_title;
194                 delete video_device;
195                 video_device = 0;
196         }
199 int PlaybackPrefs::set_strategy(int strategy)
201         int x = 350, x1 = 450, y = 10;
202         delete_strategy();
204         pwindow->thread->edl->session->playback_strategy = strategy;
205         switch(strategy)
206         {
207                 case PLAYBACK_LOCALHOST:
208                         break;
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();
213                         y += 25;
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();
217                         x = 10;
218                         y = 390;
219                         add_subwindow(vdevice_title = new BC_Title(x, y, _("Video Driver:")));
220                         video_device = new VDevicePrefs(x + 100, 
221                                 y, 
222                                 pwindow, 
223                                 this, 
224                                 current_config()->vconfig, 
225                                 0,
226                                 MODEPLAY);
227                         video_device->initialize();
228                         break;
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();
233                         y += 25;
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();
237                         y += 25;
238                         add_subwindow(host_title = new BC_Title(x, y, _("Hostname:")));
239                         add_subwindow(host_text = new PlaybackHost(this, x1, y));
240                         x = 10;
241                         y = 390;
242                         add_subwindow(vdevice_title = new BC_Title(x, y, _("Video Driver:")));
243                         video_device = new VDevicePrefs(x + 100, 
244                                 y, 
245                                 pwindow, 
246                                 this, 
247                                 current_config()->vconfig,
248                                 0,
249                                 MODEPLAY);
250                         video_device->initialize();
251                         break;
252         }
253         
254         return 1;
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);
289         return 0;
296 PlaybackStrategy::PlaybackStrategy(PlaybackPrefs *prefs, 
297         int x, 
298         int y)
299  : BC_PopupTextBox(prefs, 
300                 &prefs->strategies,
301                 prefs->strategy_to_string(prefs->pwindow->thread->edl->session->playback_strategy),
302                 x, 
303                 y, 
304                 200,
305                 100)
307         this->prefs = prefs;
310 int PlaybackStrategy::handle_event()
312         prefs->set_strategy(get_number());
313         return 1;
320 PlaybackHead::PlaybackHead(PlaybackPrefs *prefs, 
321         int x, 
322         int y)
323  : BC_TumbleTextBox(prefs, 
324                 prefs->current_head,
325                 (int64_t)0, 
326                 (int64_t)prefs->current_config_list()->total - 1, 
327                 x,
328                 y,
329                 100)
331         this->prefs = prefs;
334 int PlaybackHead::handle_event()
336         return 1;
339 PlaybackHeadCount::PlaybackHeadCount(PlaybackPrefs *prefs, 
340         int x, 
341         int y)
342  : BC_TumbleTextBox(prefs, 
343                 prefs->current_config_list()->total, 
344                 1, 
345                 MAX_CHANNELS,
346                 x,
347                 y,
348                 100)
350         this->prefs = prefs;
353 int PlaybackHeadCount::handle_event()
355         return 1;
360 PlaybackHost::PlaybackHost(PlaybackPrefs *prefs, int x, int y)
361  : BC_TextBox(x, y, 100, 1, prefs->current_config()->hostname)
363         this->prefs = prefs; 
366 int PlaybackHost::handle_event() 
368         strcpy(prefs->current_config()->hostname, get_text()); 
369         return 1;
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()); 
385         return 1;
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()); 
400         return 1;
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()); 
416         return 1;
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());
428         update(string);
429         return 1;
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(); 
441         return 1;
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(); 
456         return 1;
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(); 
471         return 1;
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(); 
486         return 1;
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;
499         this->prefs = prefs;
501 int PlaybackNearest::handle_event()
503         prefs->update(NEAREST_NEIGHBOR);
504         return 1;
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;
515         this->prefs = prefs;
517 int PlaybackBicubicBicubic::handle_event()
519         prefs->update(CUBIC_CUBIC);
520         return 1;
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;
530         this->prefs = prefs;
532 int PlaybackBicubicBilinear::handle_event()
534         prefs->update(CUBIC_LINEAR);
535         return 1;
539 PlaybackBilinearBilinear::PlaybackBilinearBilinear(PreferencesWindow *pwindow, 
540         PlaybackPrefs *prefs, 
541         int value, 
542         int x, 
543         int y)
544  : BC_Radial(x, y, value, _("Bilinear enlarge and bilinear reduce"))
546         this->pwindow = pwindow;
547         this->prefs = prefs;
549 int PlaybackBilinearBilinear::handle_event()
551         prefs->update(LINEAR_LINEAR);
552         return 1;
556 PlaybackPreload::PlaybackPreload(int x, 
557         int y, 
558         PreferencesWindow *pwindow, 
559         PlaybackPrefs *playback, 
560         char *text)
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()); 
570         return 1;
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();
584         return 1;
591 // PlaybackDeblock::PlaybackDeblock(PreferencesWindow *pwindow, int x, int y)
592 //  : BC_CheckBox(x, 
593 //      y, 
594 //      pwindow->thread->edl->session->mpeg4_deblock, 
595 //      _("MPEG-4 Deblocking"))
596 // {
597 //      this->pwindow = pwindow;
598 // }
599 // 
600 // int PlaybackDeblock::handle_event()
601 // {
602 //      pwindow->thread->edl->session->mpeg4_deblock = get_value();
603 //      return 1;
604 // }
605 //