Skip to content
This repository has been archived by the owner on Feb 28, 2023. It is now read-only.

Commit

Permalink
Disabled per track methods for now.
Browse files Browse the repository at this point in the history
This needs a better API.
  • Loading branch information
phw committed May 4, 2019
1 parent 50f163b commit 18b7070
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 39 deletions.
12 changes: 6 additions & 6 deletions examples/readdiscid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ fn print_disc_info(disc: DiscId) {
println!("Last track : {}", disc.last_track_num());
println!("Sectors : {}\n", disc.sectors());

for i in 1..disc.last_track_num() + 1 {
println!("Track #{}", i);
println!(" ISRC : {}", disc.track_isrc(i));
println!(" Offset : {}", disc.track_offset(i));
println!(" Sectors: {}", disc.track_length(i));
}
// for i in 1..disc.last_track_num() + 1 {
// println!("Track #{}", i);
// println!(" ISRC : {}", disc.track_isrc(i));
// println!(" Offset : {}", disc.track_offset(i));
// println!(" Sectors: {}", disc.track_length(i));
// }
}
66 changes: 33 additions & 33 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,27 +287,27 @@ impl DiscId {
unsafe { discid_get_sectors(self.handle.as_ptr()) }
}

/// Returns the offset in sectors for a certain track number (starting at 1).
pub fn track_offset(&self, track_num: i32) -> i32 {
unsafe { discid_get_track_offset(self.handle.as_ptr(), track_num) }
}

/// Returns the length (in sectors) for a certain track number (starting at 1).
pub fn track_length(&self, track_num: i32) -> i32 {
unsafe { discid_get_track_length(self.handle.as_ptr(), track_num) }
}
// /// Returns the offset in sectors for a certain track number (starting at 1).
// pub fn track_offset(&self, track_num: i32) -> i32 {
// unsafe { discid_get_track_offset(self.handle.as_ptr(), track_num) }
// }
//
// /// Returns the length (in sectors) for a certain track number (starting at 1).
// pub fn track_length(&self, track_num: i32) -> i32 {
// unsafe { discid_get_track_length(self.handle.as_ptr(), track_num) }
// }

/// The media catalogue number on the disc, if present.
pub fn mcn(&self) -> String {
let str_ptr = unsafe { discid_get_mcn(self.handle.as_ptr()) };
to_str(str_ptr)
}

/// Returns the ISRC for a certain track number (starting at 1).
pub fn track_isrc(&self, track_num: i32) -> String {
let str_ptr = unsafe { discid_get_track_isrc(self.handle.as_ptr(), track_num) };
to_str(str_ptr)
}
// /// Returns the ISRC for a certain track number (starting at 1).
// pub fn track_isrc(&self, track_num: i32) -> String {
// let str_ptr = unsafe { discid_get_track_isrc(self.handle.as_ptr(), track_num) };
// to_str(str_ptr)
// }
}

impl Drop for DiscId {
Expand Down Expand Up @@ -364,25 +364,25 @@ mod tests {
assert_eq!(
"http://musicbrainz.org/cdtoc/attach?id=Wn8eRBtfLDfM0qjYPdxrz.Zjs_U-&tracks=10&toc=1+10+206535+150+18901+39738+59557+79152+100126+124833+147278+166336+182560",
disc.submission_url());
for i in first..last_track + 1 {
let offset = offsets[i as usize];
let next = if i < last_track { i + 1 } else { 0 };
let length = offsets[next as usize] - offset;
assert_eq!(
offset,
disc.track_offset(i),
"track {} expected offset {}",
i,
offset
);
assert_eq!(
length,
disc.track_length(i),
"track {} expected length {}",
i,
length
);
}
// for i in first..last_track + 1 {
// let offset = offsets[i as usize];
// let next = if i < last_track { i + 1 } else { 0 };
// let length = offsets[next as usize] - offset;
// assert_eq!(
// offset,
// disc.track_offset(i),
// "track {} expected offset {}",
// i,
// offset
// );
// assert_eq!(
// length,
// disc.track_length(i),
// "track {} expected length {}",
// i,
// length
// );
// }
}

#[test]
Expand Down

0 comments on commit 18b7070

Please sign in to comment.