/* prevent any write sources from being created */
in_set_state = true;
+
+
+
init (flag);
use_new_playlist ();
in_set_state = false;
DiskStream::use_destructive_playlist ()
{
/* use the sources associated with the single full-extent region */
+
+ Playlist::RegionList* rl = _playlist->regions_at (0);
+
+ if (rl->empty()) {
+ throw failed_constructor();
+ }
+
+ AudioRegion* region = dynamic_cast<AudioRegion*> (rl->front());
+
+ if (region == 0) {
+ throw failed_constructor();
+ }
+
+ delete rl;
- AudioRegion* region = dynamic_cast<AudioRegion*> (_playlist->regions_at (0)->front());
uint32_t n;
ChannelList::iterator chan;
for (n = 0, chan = channels.begin(); chan != channels.end(); ++chan, ++n) {
(*chan).write_source = dynamic_cast<FileSource*>(®ion->source (n));
+ (*chan).write_source->set_allow_remove_if_empty (false);
}
/* the source list will never be reset for a destructive track */
set_align_style_from_io ();
}
-void
+int
DiskStream::set_name (string str, void *src)
{
if (str != _name) {
_name = str;
if (!in_set_state && recordable()) {
-
- /* open new capture files so that they have the correct name */
-
- reset_write_sources (false);
+ /* rename existing capture files so that they have the correct name */
+ return rename_write_sources ();
+ } else {
+ return -1;
}
}
+
+ return 0;
}
void
if (!had_playlist) {
_playlist->set_orig_diskstream_id (_id);
}
-
- if (capture_pending_node) {
+
+ if (!destructive() && capture_pending_node) {
+ /* destructive streams have one and only one source per channel,
+ and so they never end up in pending capture in any useful
+ sense.
+ */
use_pending_capture_data (*capture_pending_node);
}
chan.write_source->use ();
+ /* do not remove destructive files even if they are empty */
+
+ chan.write_source->set_allow_remove_if_empty (!destructive());
+
return 0;
}
}
}
+int
+DiskStream::rename_write_sources ()
+{
+ ChannelList::iterator chan;
+ uint32_t n;
+
+ for (chan = channels.begin(), n = 0; chan != channels.end(); ++chan, ++n) {
+ if ((*chan).write_source != 0) {
+ (*chan).write_source->set_name (_name, destructive());
+ /* XXX what to do if one of them fails ? */
+ }
+ }
+
+ return 0;
+}
+
void
DiskStream::set_block_size (jack_nframes_t nframes)
{