1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-30 04:50:08 +00:00

Switched to much more logical shared_ptr ownership of PCMSegmentEventSources by Periods.

This commit is contained in:
Thomas Harte 2016-12-20 18:13:10 -05:00
parent 497b2ae4dd
commit 6f17076003
2 changed files with 5 additions and 6 deletions

View File

@ -22,11 +22,11 @@ PCMPatchedTrack::PCMPatchedTrack(std::shared_ptr<Track> underlying_track) :
void PCMPatchedTrack::add_segment(const Time &start_time, const PCMSegment &segment)
{
event_sources_.emplace_back(segment);
std::shared_ptr<PCMSegmentEventSource> event_source(new PCMSegmentEventSource(segment));
Time zero(0);
Time end_time = start_time + event_sources_.back().get_length();
Period insertion_period(start_time, end_time, zero, &event_sources_.back());
Time end_time = start_time + event_source->get_length();
Period insertion_period(start_time, end_time, zero, event_source);
// the new segment may wrap around, so divide it up into track-length parts if required
Time one = Time(1);

View File

@ -38,14 +38,13 @@ class PCMPatchedTrack: public Track {
private:
std::shared_ptr<Track> underlying_track_;
std::vector<PCMSegmentEventSource> event_sources_;
struct Period {
Time start_time, end_time;
Time segment_start_time;
PCMSegmentEventSource *event_source; // nullptr => use the underlying track
std::shared_ptr<PCMSegmentEventSource> event_source; // nullptr => use the underlying track
Period(const Time &start_time, const Time &end_time, const Time &segment_start_time, PCMSegmentEventSource *event_source) :
Period(const Time &start_time, const Time &end_time, const Time &segment_start_time, std::shared_ptr<PCMSegmentEventSource> event_source) :
start_time(start_time), end_time(end_time), segment_start_time(segment_start_time), event_source(event_source) {}
};
std::vector<Period> periods_;