Clean up.
git-svn-id: svn://localhost/ardour2/branches/3.0@4572 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
5d519f8bb1
commit
41ac4afff5
@ -54,16 +54,6 @@ class SMFSource : public MidiSource, public Evoral::SMF {
|
||||
|
||||
virtual ~SMFSource ();
|
||||
|
||||
/* this block of methods do nothing for regular file sources, but are significant
|
||||
for files used in destructive recording.
|
||||
*/
|
||||
// FIXME and thus are useless for MIDI.. but make MidiDiskstream compile easier! :)
|
||||
|
||||
virtual nframes_t last_capture_start_frame() const { return 0; }
|
||||
virtual void mark_capture_start (nframes_t) {}
|
||||
virtual void mark_capture_end () {}
|
||||
virtual void clear_capture_marks() {}
|
||||
|
||||
bool set_name (const std::string& newname) { return (set_source_name(newname, false) == 0); }
|
||||
int set_source_name (string newname, bool destructive);
|
||||
|
||||
@ -98,7 +88,6 @@ class SMFSource : public MidiSource, public Evoral::SMF {
|
||||
void flush_midi();
|
||||
|
||||
private:
|
||||
|
||||
int init (string idstr, bool must_exist);
|
||||
|
||||
nframes_t read_unlocked (
|
||||
|
@ -1642,9 +1642,10 @@ AudioDiskstream::transport_stopped (struct tm& when, time_t twhen, bool abort_ca
|
||||
*/
|
||||
|
||||
try {
|
||||
boost::shared_ptr<Region> rx (RegionFactory::create (srcs, c->front()->write_source->last_capture_start_frame(), total_capture,
|
||||
whole_file_region_name,
|
||||
0, AudioRegion::Flag (AudioRegion::DefaultFlags|AudioRegion::Automatic|AudioRegion::WholeFile)));
|
||||
boost::shared_ptr<Region> rx (RegionFactory::create (srcs,
|
||||
c->front()->write_source->last_capture_start_frame(), total_capture,
|
||||
whole_file_region_name, 0,
|
||||
Region::Flag (Region::DefaultFlags|Region::Automatic|Region::WholeFile)));
|
||||
|
||||
region = boost::dynamic_pointer_cast<AudioRegion> (rx);
|
||||
region->special_set_position (capture_info.front()->start);
|
||||
|
@ -990,9 +990,9 @@ MidiDiskstream::transport_stopped (struct tm& when, time_t twhen, bool abort_cap
|
||||
*/
|
||||
|
||||
try {
|
||||
boost::shared_ptr<Region> rx (RegionFactory::create (srcs, _write_source->last_capture_start_frame(), total_capture,
|
||||
whole_file_region_name,
|
||||
0, Region::Flag (Region::DefaultFlags|Region::Automatic|Region::WholeFile)));
|
||||
boost::shared_ptr<Region> rx (RegionFactory::create (srcs, 0,
|
||||
total_capture, whole_file_region_name, 0,
|
||||
Region::Flag (Region::DefaultFlags|Region::Automatic|Region::WholeFile)));
|
||||
|
||||
region = boost::dynamic_pointer_cast<MidiRegion> (rx);
|
||||
region->special_set_position (capture_info.front()->start);
|
||||
@ -1011,7 +1011,7 @@ MidiDiskstream::transport_stopped (struct tm& when, time_t twhen, bool abort_cap
|
||||
XMLNode &before = _playlist->get_state();
|
||||
_playlist->freeze ();
|
||||
|
||||
for (buffer_position = _write_source->last_capture_start_frame(), ci = capture_info.begin(); ci != capture_info.end(); ++ci) {
|
||||
for (buffer_position = 0, ci = capture_info.begin(); ci != capture_info.end(); ++ci) {
|
||||
|
||||
string region_name;
|
||||
|
||||
|
@ -51,11 +51,11 @@ string SMFSource::_search_path;
|
||||
SMFSource::SMFSource(Session& s, std::string path, Flag flags)
|
||||
: MidiSource(s, region_name_from_path(path, false))
|
||||
, Evoral::SMF()
|
||||
, _flags (Flag(flags | Writable)) // FIXME: this needs to be writable for now
|
||||
, _flags(flags)
|
||||
, _allow_remove_if_empty(true)
|
||||
, _last_ev_time(0)
|
||||
{
|
||||
/* constructor used for new internal-to-session files. file cannot exist */
|
||||
/* Constructor used for new internal-to-session files. File cannot exist. */
|
||||
|
||||
if (init(path, false)) {
|
||||
throw failed_constructor ();
|
||||
@ -74,7 +74,7 @@ SMFSource::SMFSource (Session& s, const XMLNode& node)
|
||||
, _allow_remove_if_empty(true)
|
||||
, _last_ev_time(0)
|
||||
{
|
||||
/* constructor used for existing internal-to-session files. file must exist */
|
||||
/* Constructor used for existing internal-to-session files. File must exist. */
|
||||
|
||||
if (set_state(node)) {
|
||||
throw failed_constructor ();
|
||||
@ -125,7 +125,8 @@ SMFSource::init (string pathstr, bool must_exist)
|
||||
|
||||
/** All stamps in audio frames */
|
||||
nframes_t
|
||||
SMFSource::read_unlocked (MidiRingBuffer<nframes_t>& dst, nframes_t start, nframes_t cnt, nframes_t stamp_offset, nframes_t negative_stamp_offset) const
|
||||
SMFSource::read_unlocked (MidiRingBuffer<nframes_t>& dst, nframes_t start, nframes_t cnt,
|
||||
nframes_t stamp_offset, nframes_t negative_stamp_offset) const
|
||||
{
|
||||
//cerr << "SMF read_unlocked " << name() << " read "
|
||||
//<< start << ", count=" << cnt << ", offset=" << stamp_offset << endl;
|
||||
@ -173,19 +174,21 @@ SMFSource::read_unlocked (MidiRingBuffer<nframes_t>& dst, nframes_t start, nfram
|
||||
const nframes_t ev_frame_time = (nframes_t)(
|
||||
((time / (double)ppqn()) * frames_per_beat)) + stamp_offset;
|
||||
|
||||
if (ev_frame_time <= start + cnt)
|
||||
if (ev_frame_time <= start + cnt) {
|
||||
dst.write(ev_frame_time - negative_stamp_offset, ev_type, ev_size, ev_buffer);
|
||||
else
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
_read_data_count += ev_size;
|
||||
|
||||
if (ev_size > scratch_size)
|
||||
if (ev_size > scratch_size) {
|
||||
scratch_size = ev_size;
|
||||
else
|
||||
} else {
|
||||
ev_size = scratch_size; // minimize realloc in read_event
|
||||
}
|
||||
}
|
||||
|
||||
return cnt;
|
||||
}
|
||||
@ -203,19 +206,22 @@ SMFSource::write_unlocked (MidiRingBuffer<nframes_t>& src, nframes_t cnt)
|
||||
size_t buf_capacity = 4;
|
||||
uint8_t* buf = (uint8_t*)malloc(buf_capacity);
|
||||
|
||||
if (_model && ! _model->writing())
|
||||
if (_model && ! _model->writing()) {
|
||||
_model->start_write();
|
||||
}
|
||||
|
||||
Evoral::MIDIEvent<double> ev(0, 0.0, 4, NULL, true);
|
||||
|
||||
while (true) {
|
||||
bool ret = src.peek_time(&time);
|
||||
if (!ret || time - _timeline_position > _length + cnt)
|
||||
if (!ret || time - _timeline_position > _length + cnt) {
|
||||
break;
|
||||
}
|
||||
|
||||
ret = src.read_prefix(&time, &type, &size);
|
||||
if (!ret)
|
||||
if (!ret) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (size > buf_capacity) {
|
||||
buf_capacity = size;
|
||||
@ -275,8 +281,7 @@ SMFSource::append_event_unlocked(EventTimeUnit unit, const Evoral::Event<double>
|
||||
name().c_str(), ev.time(), ev.size());
|
||||
for (size_t i=0; i < ev.size(); ++i) {
|
||||
printf("%X ", ev.buffer()[i]);
|
||||
}
|
||||
printf("\n");
|
||||
} printf("\n");
|
||||
*/
|
||||
|
||||
assert(ev.time() >= 0);
|
||||
@ -327,15 +332,11 @@ SMFSource::set_state (const XMLNode& node)
|
||||
}
|
||||
|
||||
if ((prop = node.property (X_("flags"))) != 0) {
|
||||
|
||||
int ival;
|
||||
sscanf (prop->value().c_str(), "0x%x", &ival);
|
||||
_flags = Flag (ival);
|
||||
|
||||
} else {
|
||||
|
||||
_flags = Flag (0);
|
||||
|
||||
}
|
||||
|
||||
assert(_name.find("/") == string::npos);
|
||||
@ -439,19 +440,7 @@ SMFSource::move_to_trash (const string trash_dir_name)
|
||||
<< endmsg;
|
||||
return -1;
|
||||
}
|
||||
#if 0
|
||||
if (::unlink (peakpath.c_str()) != 0) {
|
||||
PBD::error << string_compose (_("cannot remove peakfile %1 for %2 (%3)"),
|
||||
peakpath, _path, strerror (errno))
|
||||
<< endmsg;
|
||||
/* try to back out */
|
||||
rename (newpath.c_str(), _path.c_str());
|
||||
return -1;
|
||||
}
|
||||
|
||||
_path = newpath;
|
||||
peakpath = "";
|
||||
#endif
|
||||
/* file can not be removed twice, since the operation is not idempotent */
|
||||
|
||||
_flags = Flag (_flags & ~(RemoveAtDestroy|Removable|RemovableIfEmpty));
|
||||
@ -606,7 +595,7 @@ SMFSource::set_source_name (string newname, bool destructive)
|
||||
_name = Glib::path_get_basename (newpath);
|
||||
_path = newpath;
|
||||
|
||||
return 0;//rename_peakfile (peak_path (_path));
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
|
Loading…
Reference in New Issue
Block a user