Heavy-duty abstraction work to split type-specific classes into
[ardour.git] / gtk2_ardour / export_region_dialog.cc
1 /*
2     Copyright (C) 2006 Paul Davis
3     Author: Andre Raue
4
5     This program is free software; you can redistribute it and/or modify
6     it under the terms of the GNU General Public License as published by
7     the Free Software Foundation; either version 2 of the License, or
8     (at your option) any later version.
9
10     This program is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13     GNU General Public License for more details.
14
15     You should have received a copy of the GNU General Public License
16     along with this program; if not, write to the Free Software
17     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18
19 */
20
21 #include <cassert>
22
23 #include <pbd/pthread_utils.h>
24 #include <ardour/audioregion.h>
25
26 #include "export_region_dialog.h"
27
28 #include "i18n.h"
29
30
31 ExportRegionDialog::ExportRegionDialog (PublicEditor& editor, ARDOUR::Region* region) 
32         : ExportDialog(editor)
33 {
34         // FIXME
35         ARDOUR::AudioRegion* audio_region = dynamic_cast<ARDOUR::AudioRegion*>(region);
36         assert(audio_region);
37
38         do_not_allow_track_and_master_selection();
39         do_not_allow_channel_count_selection();
40 }
41
42
43 void
44 ExportRegionDialog::export_audio_data()
45 {
46         pthread_t thr;
47         pthread_create_and_store ("region export", &thr, 0, ExportRegionDialog::_export_region_thread, this);
48
49         gtk_main_iteration ();
50         while (spec.running) {
51                 if (gtk_events_pending()) {
52                         gtk_main_iteration ();
53                 } else {
54                         usleep (10000);
55                 }
56         }
57 }
58
59
60 void*
61 ExportRegionDialog::_export_region_thread (void *arg)
62 {
63         PBD::ThreadCreated (pthread_self(), X_("Export Region"));
64
65         static_cast<ExportRegionDialog*>(arg)->export_region ();
66         return 0;
67 }
68
69 void
70 ExportRegionDialog::export_region ()
71 {
72         audio_region->exportme (getSession(), spec);
73 }