mirror of
https://github.com/TomHarte/CLK.git
synced 2025-08-15 14:27:29 +00:00
Ensured the patchable track owns its underlying track.
This commit is contained in:
@@ -13,27 +13,41 @@
|
|||||||
|
|
||||||
@implementation PCMPatchedTrackTests
|
@implementation PCMPatchedTrackTests
|
||||||
|
|
||||||
- (Storage::Disk::PCMTrack)togglingTrack
|
- (std::shared_ptr<Storage::Disk::Track>)togglingTrack
|
||||||
{
|
{
|
||||||
Storage::Disk::PCMSegment segment;
|
Storage::Disk::PCMSegment segment;
|
||||||
segment.data = { 0xff, 0xff, 0xff, 0xff };
|
segment.data = { 0xff, 0xff, 0xff, 0xff };
|
||||||
segment.number_of_bits = 32;
|
segment.number_of_bits = 32;
|
||||||
return Storage::Disk::PCMTrack(segment);
|
return std::shared_ptr<Storage::Disk::Track>(new Storage::Disk::PCMTrack(segment));
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)testUnpatchedTrack
|
- (std::shared_ptr<Storage::Disk::Track>)patchableTogglingTrack
|
||||||
{
|
{
|
||||||
Storage::Disk::PCMTrack track = self.togglingTrack;
|
std::shared_ptr<Storage::Disk::Track> track = self.togglingTrack;
|
||||||
|
return std::shared_ptr<Storage::Disk::Track>(new Storage::Disk::PCMPatchedTrack(track));
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)assertOneThirtyTwosForTrack:(std::shared_ptr<Storage::Disk::Track>)track
|
||||||
|
{
|
||||||
// Confirm that there are now flux transitions (just the first five will do)
|
// Confirm that there are now flux transitions (just the first five will do)
|
||||||
// located 1/32nd of a rotation apart.
|
// located 1/32nd of a rotation apart.
|
||||||
int c = 5;
|
int c = 5;
|
||||||
while(c--)
|
while(c--)
|
||||||
{
|
{
|
||||||
Storage::Disk::Track::Event event = track.get_next_event();
|
Storage::Disk::Track::Event event = track->get_next_event();
|
||||||
Storage::Time simplified_time = event.length.simplify();
|
Storage::Time simplified_time = event.length.simplify();
|
||||||
XCTAssert(simplified_time.length == 1 && simplified_time.clock_rate == 32, "flux transitions should be 1/32nd of a track apart");
|
XCTAssert(simplified_time.length == 1 && simplified_time.clock_rate == 32, "flux transitions should be 1/32nd of a track apart");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)testUnpatchedRawTrack
|
||||||
|
{
|
||||||
|
[self assertOneThirtyTwosForTrack:self.togglingTrack];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)testUnpatchedTrack
|
||||||
|
{
|
||||||
|
[self assertOneThirtyTwosForTrack:self.patchableTogglingTrack];
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
@@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
using namespace Storage::Disk;
|
using namespace Storage::Disk;
|
||||||
|
|
||||||
PCMPatchedTrack::PCMPatchedTrack(Track &underlying_track) :
|
PCMPatchedTrack::PCMPatchedTrack(std::shared_ptr<Track> underlying_track) :
|
||||||
underlying_track_(underlying_track),
|
underlying_track_(underlying_track),
|
||||||
active_patch_((size_t)-1)
|
active_patch_((size_t)-1)
|
||||||
{}
|
{}
|
||||||
@@ -23,10 +23,10 @@ void PCMPatchedTrack::add_segment(const Time &start_position, const PCMSegment &
|
|||||||
Track::Event PCMPatchedTrack::get_next_event()
|
Track::Event PCMPatchedTrack::get_next_event()
|
||||||
{
|
{
|
||||||
// if(active_patch_ == (size_t)-1)
|
// if(active_patch_ == (size_t)-1)
|
||||||
return underlying_track_.get_next_event();
|
return underlying_track_->get_next_event();
|
||||||
}
|
}
|
||||||
|
|
||||||
Storage::Time PCMPatchedTrack::seek_to(const Time &time_since_index_hole)
|
Storage::Time PCMPatchedTrack::seek_to(const Time &time_since_index_hole)
|
||||||
{
|
{
|
||||||
return underlying_track_.seek_to(time_since_index_hole);
|
return underlying_track_->seek_to(time_since_index_hole);
|
||||||
}
|
}
|
||||||
|
@@ -23,7 +23,7 @@ class PCMPatchedTrack: public Track {
|
|||||||
Constructs a @c PCMPatchedTrack that will return events from @c underlying_track in
|
Constructs a @c PCMPatchedTrack that will return events from @c underlying_track in
|
||||||
regions where it has not had alternative PCM data installed.
|
regions where it has not had alternative PCM data installed.
|
||||||
*/
|
*/
|
||||||
PCMPatchedTrack(Track &underlying_track);
|
PCMPatchedTrack(std::shared_ptr<Track> underlying_track);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Replaces whatever is currently on the track from @c start_position to @c start_position + segment length
|
Replaces whatever is currently on the track from @c start_position to @c start_position + segment length
|
||||||
@@ -36,7 +36,7 @@ class PCMPatchedTrack: public Track {
|
|||||||
Time seek_to(const Time &time_since_index_hole);
|
Time seek_to(const Time &time_since_index_hole);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Track &underlying_track_;
|
std::shared_ptr<Track> underlying_track_;
|
||||||
struct Patch {
|
struct Patch {
|
||||||
Time start_position;
|
Time start_position;
|
||||||
PCMSegment segment;
|
PCMSegment segment;
|
||||||
|
Reference in New Issue
Block a user