void
ExportDialog::end_dialog ()
{
-
if (spec.running) {
spec.stop = true;
}
}
- session->engine().freewheel (false);
+ session->finalize_audio_export ();
hide_all ();
Locations::LocationList::iterator locationIter;
current_range_marker_index = 0;
init_progress_computing(locations);
-
+
for (locationIter = locations.begin(); locationIter != locations.end(); ++locationIter) {
Location *currentLocation = (*locationIter);
// wait until export of this range finished
gtk_main_iteration();
- while(spec.running){
+
+ while (spec.running){
if(gtk_events_pending()){
gtk_main_iteration();
}else {
{
double progress = 0.0;
- cerr << "Progress timeout, total = " << total_duration << " index = " << current_range_marker_index
- << " current = " << range_markers_durations[current_range_marker_index]
- << " agg = " << range_markers_durations_aggregated[current_range_marker_index]
- << " prog = " << spec.progress
- << endl;
-
if (current_range_marker_index >= range_markers_durations.size()){
progress = 1.0;
} else{
/* shared between UI thread and audio thread */
- float progress; /* audio thread sets this */
- bool stop; /* UI sets this */
- bool running; /* audio thread sets to false when export is done */
+ volatile float progress; /* audio thread sets this */
+ volatile bool stop; /* UI sets this */
+ volatile bool running; /* audio thread sets to false when export is done */
int status;
int start_audio_export (ARDOUR::AudioExportSpecification&);
int stop_audio_export (ARDOUR::AudioExportSpecification&);
-
+ void finalize_audio_export ();
+
void add_source (boost::shared_ptr<Source>);
void remove_source (boost::weak_ptr<Source>);
Sample* buf2 = 0;
nframes_t to_do;
uint32_t peaks_computed;
- PeakData* peakbuf;
+ PeakData* peakbuf = 0;
int ret = -1;
nframes_t current_frame;
nframes_t frames_done;
float *data = 0;
Sample **channel_data = 0;
long nfiles = 0;
- long n;
string basepath;
string sounds_dir;
nframes_t so_far;
importable = new ImportableSource (in, &info);
}
- for (n = 0; n < info.channels; ++n) {
+ for (int n = 0; n < info.channels; ++n) {
newfiles.push_back (boost::shared_ptr<AudioFileSource>());
}
sounds_dir = discover_best_sound_dir ();
basepath = PBD::basename_nosuffix (status.paths.front());
- for (n = 0; n < info.channels; ++n) {
+ for (int n = 0; n < info.channels; ++n) {
bool goodfile = false;
snprintf (buf, sizeof(buf), "%s/%s-R.wav", sounds_dir.c_str(), basepath.c_str());
}
} else if (info.channels > 1) {
- snprintf (buf, sizeof(buf), "%s/%s-c%lu.wav", sounds_dir.c_str(), basepath.c_str(), n+1);
+ snprintf (buf, sizeof(buf), "%s/%s-c%d.wav", sounds_dir.c_str(), basepath.c_str(), n+1);
} else {
snprintf (buf, sizeof(buf), "%s/%s.wav", sounds_dir.c_str(), basepath.c_str());
}
data = new float[nframes * info.channels];
channel_data = new Sample * [ info.channels ];
- for (n = 0; n < info.channels; ++n) {
+ for (int n = 0; n < info.channels; ++n) {
channel_data[n] = new Sample[nframes];
}
/* de-interleave */
for (chn = 0; chn < info.channels; ++chn) {
-
+
+ nframes_t n;
for (x = chn, n = 0; n < nfread; x += info.channels, ++n) {
channel_data[chn][n] = (Sample) data[x];
}
if (status.multichan) {
/* all sources are used in a single multichannel region */
- for (n = 0; n < nfiles && !status.cancel; ++n) {
+ for (int n = 0; n < nfiles && !status.cancel; ++n) {
/* flush the final length to the header */
newfiles[n]->update_header(0, *now, xnow);
sources.push_back(newfiles[n]);
status.new_regions.push_back (r);
} else {
- for (n = 0; n < nfiles && !status.cancel; ++n) {
+ for (int n = 0; n < nfiles && !status.cancel; ++n) {
/* flush the final length to the header */
}
if (channel_data) {
- for (n = 0; n < info.channels; ++n) {
+ for (int n = 0; n < info.channels; ++n) {
delete [] channel_data[n];
}
delete [] channel_data;
void
find_peaks (ARDOUR::Sample *buf, nframes_t nframes, float *min, float *max)
{
- long i;
+ nframes_t i;
float a, b;
a = *max;
for (boost::dynamic_bitset<uint32_t>::size_type n = 0; n < insert_bitset.size(); ++n) {
if (!insert_bitset[n]) {
insert_bitset[n] = true;
- cerr << "Returning " << n << " as insert ID\n";
return n;
}
for (boost::dynamic_bitset<uint32_t>::size_type n = 0; n < send_bitset.size(); ++n) {
if (!send_bitset[n]) {
send_bitset[n] = true;
- cerr << "Returning " << n << " as send ID\n";
return n;
}
char errbuf[256];
nframes_t to_write = 0;
int cnt = 0;
-
+
do {
/* now do sample rate conversion */
int
Session::start_audio_export (AudioExportSpecification& spec)
{
- int ret;
-
if (spec.prepare (current_block_size, frame_rate())) {
return -1;
}
spec.pos = spec.start_frame;
spec.end_frame = spec.end_frame;
spec.total_frames = spec.end_frame - spec.start_frame;
+ spec.running = true;
+ spec.do_freewheel = false; /* force a call to ::prepare_to_export() before proceeding to normal operation */
spec.freewheel_connection = _engine.Freewheel.connect (sigc::bind (mem_fun (*this, &Session::process_export), &spec));
- if ((ret = _engine.freewheel (true)) == 0) {
- spec.running = true;
- spec.do_freewheel = false;
- }
-
- return ret;
+ return _engine.freewheel (true);
}
int
Session::stop_audio_export (AudioExportSpecification& spec)
{
- /* can't use stop_transport() here because we need
- an immediate halt and don't require all the declick
- stuff that stop_transport() implements.
- */
-
- realtime_stop (true);
- schedule_butler_transport_work ();
-
- /* restart slaving */
+ /* don't stop freewheeling but do stop paying attention to it for now */
- if (post_export_slave != None) {
- Config->set_slave_source (post_export_slave);
- } else {
- locate (post_export_position, false, false, false);
- }
-
- spec.clear ();
- _exporting = false;
-
- spec.running = false;
+ spec.freewheel_connection.disconnect ();
+ spec.clear (); /* resets running/stop etc */
return 0;
}
return ret;
}
+void
+Session::finalize_audio_export ()
+{
+ _engine.freewheel (false);
+ _exporting = false;
+
+ /* can't use stop_transport() here because we need
+ an immediate halt and don't require all the declick
+ stuff that stop_transport() implements.
+ */
+
+ realtime_stop (true);
+ schedule_butler_transport_work ();
+
+ /* restart slaving */
+
+ if (post_export_slave != None) {
+ Config->set_slave_source (post_export_slave);
+ } else {
+ locate (post_export_position, false, false, false);
+ }
+}
}
RequestBufferVector vec;
+ vec.buf[0] = 0;
+ vec.buf[1] = 0;
rbuf->get_write_vector (&vec);
printf ("Obtained %zd stack frames.\n", size);
- for (i = 0; i < size && (levels == 0 || i < levels); i++) {
+ for (i = 0; i < size && (levels == 0 || i < size_t(levels)); i++) {
out << strings[i] << std::endl;
}
}
for (ustring::size_type n = 0; n < len; ++n) {
- if (str[n] == splitchar) {
+ if (str[n] == gunichar(splitchar)) {
cnt++;
}
}
// Returns nonzero if there aren't any samples available for outputting.
-uint RateTransposer::isEmpty()
+int RateTransposer::isEmpty() const
{
int res;
void clear();
/// Returns nonzero if there aren't any samples available for outputting.
- uint isEmpty();
+ int isEmpty() const;
};
}
-// Calculates the x having the closest 2^x value for the given value
-static int _getClosest2Power(double value)
-{
- return (int)(log(value) / log(2.0) + 0.5);
-}
-
-
// Sets routine control parameters. These control are certain time constants
// defining how the sound is stretched to the desired duration.