From 6658ddcf5dec8d6e22363fb435c48dfe4ce1e7f8 Mon Sep 17 00:00:00 2001 From: notaz Date: Tue, 7 Jun 2022 01:59:51 +0300 Subject: [PATCH] cdriso: hack .chd track handling to match .cue libretro/pcsx_rearmed#648 --- libpcsxcore/cdriso.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/libpcsxcore/cdriso.c b/libpcsxcore/cdriso.c index 4c8d30fb..6b6cefd3 100644 --- a/libpcsxcore/cdriso.c +++ b/libpcsxcore/cdriso.c @@ -936,6 +936,9 @@ fail_io: #ifdef HAVE_CHD static int handlechd(const char *isofile) { + int frame_offset = 150; + int file_offset = 0; + chd_img = calloc(1, sizeof(*chd_img)); if (chd_img == NULL) goto fail_io; @@ -958,8 +961,6 @@ static int handlechd(const char *isofile) { cddaBigEndian = TRUE; numtracks = 0; - int frame_offset = 0; - int file_offset = 0; memset(ti, 0, sizeof(ti)); while (1) @@ -987,25 +988,23 @@ static int handlechd(const char *isofile) { SysPrintf("chd: %s\n", meta); if (md.track == 1) { - md.pregap = 150; if (!strncmp(md.subtype, "RW", 2)) { subChanMixed = TRUE; if (!strcmp(md.subtype, "RW_RAW")) subChanRaw = TRUE; } } - else - sec2msf(msf2sec(ti[md.track-1].length) + md.pregap, ti[md.track-1].length); ti[md.track].type = !strncmp(md.type, "AUDIO", 5) ? CDDA : DATA; sec2msf(frame_offset + md.pregap, ti[md.track].start); sec2msf(md.frames, ti[md.track].length); - ti[md.track].start_offset = file_offset; + ti[md.track].start_offset = file_offset + md.pregap; - frame_offset += md.pregap + md.frames + md.postgap; - file_offset += md.frames + md.postgap; + // XXX: what about postgap? + frame_offset += md.frames; + file_offset += md.frames; numtracks++; } -- 2.39.5