r125: This commit was manufactured by cvs2svn to create tag 'r1_1_7-last'.
[cinelerra_cv/mob.git] / hvirtual / cinelerra / audiooutprefs.C
blobc86e858fc32d0b393430f31c3b53cfacd94824bc
1 #include "adeviceprefs.h"
2 #include "adrivermenu.h"
3 #include "audioconfig.h"
4 #include "audiodevice.inc"
5 #include "audiooutprefs.h"
6 #include "defaults.h"
7 #include "edl.h"
8 #include "edlsession.h"
9 #include "mwindow.h"
10 #include "preferences.h"
12 #include <string.h>
13 #include <libintl.h>
14 #define _(String) gettext(String)
15 #define gettext_noop(String) String
16 #define N_(String) gettext_noop (String)
19 AudioOutPrefs::AudioOutPrefs(MWindow *mwindow, PreferencesWindow *pwindow)
20  : PreferencesDialog(mwindow, pwindow)
22         head_text = 0;
23         head_count_text = 0;
24         host_text = 0;
25         video_device = 0;
28 AudioOutPrefs::~AudioOutPrefs()
30         delete_strategy();
31         mwindow->defaults->update("PLAYBACK_HEAD", (int)current_head);
32         delete audio_device;
33         delete video_device;
36 int AudioOutPrefs::create_objects()
38         int x = 5, y = 5;
39         char string[1024];
40         BC_PopupTextBox *popup;
42 //printf("AudioOutPrefs::create_objects 1\n");
43         current_head = mwindow->defaults->get("PLAYBACK_HEAD", 0);
44         strategies.append(new BC_ListBoxItem(_("Local Host")));
45         strategies.append(new BC_ListBoxItem(_("Multihead")));
46         strategies.append(new BC_ListBoxItem(_("Blond Symphony")));
48 //      add_subwindow(new BC_Title(x, y, _("Playback"), LARGEFONT, BLACK));
49 //      x += 200;
50 //      add_subwindow(new BC_Title(x, y, _("Strategy:")));
51 //      popup = new PlaybackStrategy(this, x + 70, y);
52 //      popup->create_objects();
53 //      x = 10;
54 //      y += popup->get_h() + 30;
56 // Global playback options
58 // All strategies use these
59         add_subwindow(new BC_Title(x, y, _("Audio Out"), LARGEFONT, BLACK));
60         y += 30;
61         add_subwindow(new BC_Title(x, y, _("Samples to read from disk at a time:"), MEDIUMFONT, BLACK));
62         sprintf(string, "%d", pwindow->thread->edl->session->audio_read_length);
63         add_subwindow(new PlaybackReadLength(x + 275, y, pwindow, this, string));
64         y += 30;
65         add_subwindow(new BC_Title(x, y, _("Samples to send to console at a time:"), MEDIUMFONT, BLACK));
66         sprintf(string, "%d", pwindow->thread->edl->session->audio_module_fragment);
67         add_subwindow(new PlaybackModuleFragment(x + 275, y, pwindow, this, string));
68         y += 30;
69         add_subwindow(new PlaybackDisableNoEdits(pwindow, pwindow->thread->edl->session->test_playback_edits, y));
70         y += 30;
71         add_subwindow(new PlaybackViewFollows(pwindow, pwindow->thread->edl->session->view_follows_playback, y));
72         y += 30;
73         add_subwindow(new PlaybackSoftwareTimer(pwindow, pwindow->thread->edl->session->playback_software_position, y));
74         y += 30;
75         add_subwindow(new PlaybackRealTime(pwindow, pwindow->thread->edl->session->real_time_playback, y));
76         y += 40;
77         add_subwindow(new BC_Title(x, y, _("Audio Driver:")));
78         audio_device = new ADevicePrefs(x + 100, 
79                 y, 
80                 pwindow, 
81                 this, 
82                 current_config()->aconfig, 
83                 0,
84                 MODEPLAY);
85         audio_device->initialize();
87 // Strategic playback options created here
88         set_strategy(pwindow->thread->edl->session->playback_strategy);
89 // 
90 //      add_subwindow(new BC_Title(x, y, _("Playback driver:"), MEDIUMFONT, BLACK));
91 //      add_subwindow(new AudioDriverMenu(x, y + 20, out_device, &(pwindow->thread->preferences->aconfig->audio_out_driver), 0, 1));
92 //      y += 70;
93 // 
94         return 0;
97 char* AudioOutPrefs::strategy_to_string(int strategy)
99         switch(strategy)
100         {
101                 case PLAYBACK_LOCALHOST:
102                         return _("Local Host");
103                         break;
104                 case PLAYBACK_MULTIHEAD:
105                         return _("Multihead");
106                         break;
107                 case PLAYBACK_BLONDSYMPHONY:
108                         return _("Blond Symphony");
109                         break;
110         }
111         return _("Local Host");
114 // Delete strategy dependant objects
115 void AudioOutPrefs::delete_strategy()
117         if(head_text) 
118         {
119                 delete head_text;
120                 delete head_title;
121                 head_text = 0;
122         }
123         if(host_text)
124         {
125                 delete host_title;
126                 delete host_text;
127                 host_text = 0;
128         }
129         if(head_count_text)
130         {
131                 delete head_count_title;
132                 delete head_count_text;
133                 head_count_text = 0;
134         }
135         if(video_device)
136         {
137                 delete vdevice_title;
138                 delete video_device;
139                 video_device = 0;
140         }
143 int AudioOutPrefs::set_strategy(int strategy)
145         int x = 350, x1 = 450, y = 10;
146         delete_strategy();
148         pwindow->thread->edl->session->playback_strategy = strategy;
149         switch(strategy)
150         {
151                 case PLAYBACK_LOCALHOST:
152                         break;
153                 case PLAYBACK_MULTIHEAD:
154                         add_subwindow(head_title = new BC_Title(x, y, _("Head:")));
155                         head_text = new PlaybackHead(this, x1, y);
156                         head_text->create_objects();
157                         y += 25;
158                         add_subwindow(head_count_title = new BC_Title(x, y, _("Total Heads:")));
159                         head_count_text = new PlaybackHeadCount(this, x1, y);
160                         head_count_text->create_objects();
161                         x = 10;
162                         y = 390;
163                         add_subwindow(vdevice_title = new BC_Title(x, y, _("Video Driver:")));
164                         video_device = new VDevicePrefs(x + 100, 
165                                 y, 
166                                 pwindow, 
167                                 this, 
168                                 current_config()->vconfig, 
169                                 0,
170                                 MODEPLAY);
171                         video_device->initialize();
172                         break;
173                 case PLAYBACK_BLONDSYMPHONY:
174                         add_subwindow(head_title = new BC_Title(x, y, _("Head:")));
175                         head_text = new PlaybackHead(this, x1, y);
176                         head_text->create_objects();
177                         y += 25;
178                         add_subwindow(head_count_title = new BC_Title(x, y, _("Total Heads:")));
179                         head_count_text = new PlaybackHeadCount(this, x1, y);
180                         head_count_text->create_objects();
181                         y += 25;
182                         add_subwindow(host_title = new BC_Title(x, y, _("Hostname:")));
183                         add_subwindow(host_text = new PlaybackHost(this, x1, y));
184                         x = 10;
185                         y = 390;
186                         add_subwindow(vdevice_title = new BC_Title(x, y, _("Video Driver:")));
187                         video_device = new VDevicePrefs(x + 100, 
188                                 y, 
189                                 pwindow, 
190                                 this, 
191                                 current_config()->vconfig,
192                                 0,
193                                 MODEPLAY);
194                         video_device->initialize();
195                         break;
196         }
197         
198         return 1;
201 ArrayList<PlaybackConfig*>* AudioOutPrefs::current_config_list()
203         return &pwindow->thread->edl->session->playback_config[pwindow->thread->edl->session->playback_strategy];
206 PlaybackConfig* AudioOutPrefs::current_config()
208         return current_config_list()->values[current_head];
213 int AudioOutPrefs::get_buffer_bytes()
215 //      return pwindow->thread->edl->aconfig->oss_out_bits / 8 * pwindow->thread->preferences->aconfig->oss_out_channels * pwindow->thread->preferences->playback_buffer;
223 PlaybackStrategy::PlaybackStrategy(AudioOutPrefs *prefs, 
224         int x, 
225         int y)
226  : BC_PopupTextBox(prefs, 
227                 &prefs->strategies,
228                 prefs->strategy_to_string(prefs->pwindow->thread->edl->session->playback_strategy),
229                 x, 
230                 y, 
231                 200,
232                 100)
234         this->prefs = prefs;
237 int PlaybackStrategy::handle_event()
239         prefs->set_strategy(get_number());
240         return 1;
247 PlaybackHead::PlaybackHead(AudioOutPrefs *prefs, 
248         int x, 
249         int y)
250  : BC_TumbleTextBox(prefs, 
251                 prefs->current_head,
252                 0, 
253                 prefs->current_config_list()->total - 1, 
254                 x,
255                 y,
256                 100)
258         this->prefs = prefs;
261 int PlaybackHead::handle_event()
263         return 1;
266 PlaybackHeadCount::PlaybackHeadCount(AudioOutPrefs *prefs, 
267         int x, 
268         int y)
269  : BC_TumbleTextBox(prefs, 
270                 prefs->current_config_list()->total, 
271                 1, 
272                 MAX_CHANNELS,
273                 x,
274                 y,
275                 100)
277         this->prefs = prefs;
280 int PlaybackHeadCount::handle_event()
282         return 1;
287 PlaybackHost::PlaybackHost(AudioOutPrefs *prefs, int x, int y)
288  : BC_TextBox(x, y, 100, 1, prefs->current_config()->hostname)
290         this->prefs = prefs; 
293 int PlaybackHost::handle_event() 
295         strcpy(prefs->current_config()->hostname, get_text()); 
296         return 1;
302 PlaybackReadLength::PlaybackReadLength(int x, int y, PreferencesWindow *pwindow, AudioOutPrefs *playback, char *text)
303  : BC_TextBox(x, y, 100, 1, text)
305         this->pwindow = pwindow; 
306         this->playback = playback; 
309 int PlaybackReadLength::handle_event() 
311         pwindow->thread->edl->session->audio_read_length = atol(get_text()); 
312         return 1;
318 PlaybackModuleFragment::PlaybackModuleFragment(int x, int y, PreferencesWindow *pwindow, AudioOutPrefs *playback, char *text)
319  : BC_TextBox(x, y, 100, 1, text)
321         this->pwindow = pwindow; 
324 int PlaybackModuleFragment::handle_event() 
326         pwindow->thread->edl->session->audio_module_fragment = atol(get_text()); 
327         return 1;
333 PlaybackBufferSize::PlaybackBufferSize(int x, int y, PreferencesWindow *pwindow, AudioOutPrefs *playback, char *text)
334  : BC_TextBox(x, y, 100, 1, text)
336         this->pwindow = pwindow; 
337         this->playback = playback; 
340 int PlaybackBufferSize::handle_event() 
342         pwindow->thread->edl->session->playback_buffer = atol(get_text()); 
343         return 1;
346 PlaybackBufferBytes::PlaybackBufferBytes(int x, int y, PreferencesWindow *pwindow, AudioOutPrefs *playback, char *text)
347  : BC_Title(x, y, text)
349         this->pwindow = pwindow; 
350         this->playback = playback;
352 int PlaybackBufferBytes::update_bytes()
354         sprintf(string, "%d", playback->get_buffer_bytes());
355         update(string);
356         return 1;
359 PlaybackDisableNoEdits::PlaybackDisableNoEdits(PreferencesWindow *pwindow, int value, int y)
360  : BC_CheckBox(10, y, value, _("Disable tracks when no edits."))
362         this->pwindow = pwindow; 
365 int PlaybackDisableNoEdits::handle_event() 
367         pwindow->thread->edl->session->test_playback_edits = get_value(); 
368         return 1;
374 PlaybackViewFollows::PlaybackViewFollows(PreferencesWindow *pwindow, int value, int y)
375  : BC_CheckBox(10, y, value, _("View follows playback"))
377         this->pwindow = pwindow; 
380 int PlaybackViewFollows::handle_event() 
382         pwindow->thread->edl->session->view_follows_playback = get_value(); 
383         return 1;
389 PlaybackSoftwareTimer::PlaybackSoftwareTimer(PreferencesWindow *pwindow, int value, int y)
390  : BC_CheckBox(10, y, value, _("Use software for positioning information"))
392         this->pwindow = pwindow; 
395 int PlaybackSoftwareTimer::handle_event() 
397         pwindow->thread->edl->session->playback_software_position = get_value(); 
398         return 1;
404 PlaybackRealTime::PlaybackRealTime(PreferencesWindow *pwindow, int value, int y)
405  : BC_CheckBox(10, y, value, _("Audio playback in real time priority (root only)"))
407         this->pwindow = pwindow; 
410 int PlaybackRealTime::handle_event() 
412         pwindow->thread->edl->session->real_time_playback = get_value(); 
413         return 1;