From 2219b9aa66f2932df3c7c9935b6246fb029bc79e Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Sun, 20 Sep 2020 11:55:43 +1000 Subject: [PATCH] CDImageCue: Work around broken (old) dumps with missing pregap Some people have broken (older) dumps where a two second pregap was implicit but not specified in the cuesheet. The problem is we can't tell between a missing implicit two second pregap and a zero second pregap. --- src/common/cd_image_cue.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/common/cd_image_cue.cpp b/src/common/cd_image_cue.cpp index 88c093ede..96a58d533 100644 --- a/src/common/cd_image_cue.cpp +++ b/src/common/cd_image_cue.cpp @@ -129,10 +129,15 @@ bool CDImageCueSheet::OpenAndParse(const char* filename) track_length = file_size - track_start; } - // two seconds pregap for track 1 is assumed if not specified + // Two seconds pregap for track 1 is assumed if not specified. + // Some people have broken (older) dumps where a two second pregap was implicit but not specified in the cuesheet. + // The problem is we can't tell between a missing implicit two second pregap and a zero second pregap. Most of these + // seem to be a single bin file for all tracks. So if this is the case, we add the two seconds in if it's not + // specified. long pregap_frames = track_get_zero_pre(track); - bool pregap_in_file = pregap_frames > 0 && track_start >= pregap_frames; - if (track_num == 1 && pregap_frames < 0) + const bool pregap_in_file = pregap_frames > 0 && track_start >= pregap_frames; + const bool is_multi_track_bin = (track_num > 1 && track_file_index == m_indices[0].file_index); + if ((track_num == 1 || is_multi_track_bin) && pregap_frames < 0) pregap_frames = 2 * FRAMES_PER_SECOND; // create the index for the pregap