fix reading with negative offsets - #62
Conversation
|
@buddyabaddon: do you have any thoughts or objections to this? |
|
I am not so sure filling missing samples with silence is the correct approach. I do not have optical drive hardware to test this with the CD Audio album I know that has Track 00 audio, Blind Melon / Soup. |
|
I don't think I have that specific album, but I will check if I have any with track 0. |
|
It turns out I don't have a CD that has a track 0 (I only found one with and extra track on the end), so I can't verify it. Based on cdda_track_firstsector() that handles track 0 case I assume that even if track 0 exist that just shifts the other tracks forward. libcdio-paranoia/lib/cdda_interface/toc.c Lines 45 to 54 in 307fa2e So track 0 would still start at LBA 0 instead of being on some negative LBA address. That is the same case with track 1 as you can read LBA 0 fine and insert silence if there is need to read before that as most of the drives are incapable of reading negative LBA addresses. So effectively track 0 and track 1 handling seems same to me. |
I was certainly looking for someone who owned a drive with a negative read offset when I originally fixed the large offset bug: #14 (comment) . Unfortunately, no one came forward at the time who owned such a drive. I had suspected there were some issues with the logic for this use case. Well, it seems @MmAaXx500 has such a drive! If the --force-overread option is not specified -and- the drive has a negative offset, I do expect that the right thing to do here is to advance i_first_lsn to 0 and fill the unreadable samples with 0's... You'll certainly want to make sure all the existing tests still pass ('make test'). I'd also look at verifying that things still work as expected with the --force-overread option (that the logic still attempts to read into the leadin/leadout despite your drive not supporting reading into negative sector indices). Other than some semantic naming clarification, I can't see anything I dislike about this approach. I'll need to do some testing to ensure it still works with positive offset drives. I encourage you to also ask folk to give this fix a try so you can get a variety of results from drives with differing read offsets. I do worry about unknown corner cases and CDDA shenanigans (hidden first tracks, etc.) but this looks to be a real bug for folk with negative offset drives. Had I had such a drive (or identified someone with one) when I made my changes, I certainly would have considered this case. Thanks for coming forward with a negative offset drive @MmAaXx500. Give me some time and I can try your changes out and report back with my results. |
@MmAaXx500 does
Thanks @buddyabaddon for looking and the information. I'd appreciate it if you try out the changes and let us all know. |
@buddyabaddon Please add a review comment on them and suggest a better name. What I also dislike myself is
It does locally, it also passed as part of the CI.
Running Running with |
Okay. Good to hear. We'll wait a little bit for @buddyabaddon to test, and then this will probably merge as is. |
When --sample-offset is negative, toc_offset can push i_first_lsn
below sector 0, resulting in an invalid READ CD command.
INFO: ioctl CDROM_SEND_PACKET for command READ CD (0xbe) failed:
Input/output error
- clamp i_first_lsn to 0 (unless force_overread)
- fill missing samples with silence in the pregap
d4eb2ff to
dcd4ab2
Compare
|
@buddyabaddon Do you still need more time to test, or should we merge this? |
|
@rocky - Sorry, I haven't had a chance to mess with this locally yet; been one of those weeks. If you're itching to merge, don't wait on me. |
I totally understand.
Not itching, but letting things go on for a while isn't good either. So let's merge, and if there are changes down the line, we can do that in future PRs. |
When --sample-offset is negative, toc_offset can push i_first_lsn below sector 0, resulting in an invalid READ CD command.
I tested the changes with 2 drives
Test with libcdio-paranoia
Ripped the 1st, 2nd, and last track of the same CD with the drives. The results are identical.
Test with whipper
Tested if whipper can correctly identify the drive's offset, and it was able to determine the correct offset for LG CRD-8522B as -491.
Also ripped the CD with both drives and accuraterip reported correct rip in both cases.
Note: I used AI and Actual Intelligence to make this PR
Fixes #61