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 PCMSegmentEventSource
s by Period
s.
This commit is contained in:
parent
497b2ae4dd
commit
6f17076003
@ -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);
|
||||
|
@ -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_;
|
||||
|
Loading…
Reference in New Issue
Block a user