diff options
| author | SND\notaz_cp <SND\notaz_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97> | 2013-01-12 21:07:44 +0000 |
|---|---|---|
| committer | SND\notaz_cp <SND\notaz_cp@e17a0e51-4ae3-4d35-97c3-1a29b211df97> | 2013-01-12 21:07:44 +0000 |
| commit | 085ec60fd479651cc6653950265086549ca68ec1 (patch) | |
| tree | 9cbeca53a418cf3ed9aeb07d2c6ce8e167b78ec2 | |
| parent | c288a602fc242050515e4ff3753bce02e713077e (diff) | |
| download | pcsxr-085ec60fd479651cc6653950265086549ca68ec1.tar.gz | |
cdriso: improve .toc handling yet more
git-svn-id: https://pcsxr.svn.codeplex.com/svn/pcsxr@82225 e17a0e51-4ae3-4d35-97c3-1a29b211df97
| -rwxr-xr-x | libpcsxcore/cdriso.c | 42 |
1 files changed, 32 insertions, 10 deletions
diff --git a/libpcsxcore/cdriso.c b/libpcsxcore/cdriso.c index b7c4bccb..afbb97d0 100755 --- a/libpcsxcore/cdriso.c +++ b/libpcsxcore/cdriso.c @@ -141,10 +141,11 @@ static void tok2msf(char *time, char *msf) { static int parsetoc(const char *isofile) { char tocname[MAXPATHLEN]; FILE *fi; - char linebuf[256], dummy[256], name[256]; + char linebuf[256], tmp[256], name[256]; char *token; char time[20], time2[20]; unsigned int t, sector_offs, sector_size; + unsigned int current_zero_gap = 0; numtracks = 0; @@ -186,12 +187,15 @@ static int parsetoc(const char *isofile) { // parse the .toc file while (fgets(linebuf, sizeof(linebuf), fi) != NULL) { // search for tracks - strncpy(dummy, linebuf, sizeof(linebuf)); - token = strtok(dummy, " "); + strncpy(tmp, linebuf, sizeof(linebuf)); + token = strtok(tmp, " "); if (token == NULL) continue; if (!strcmp(token, "TRACK")) { + sector_offs += current_zero_gap; + current_zero_gap = 0; + // get type of track token = strtok(NULL, " "); numtracks++; @@ -202,10 +206,11 @@ static int parsetoc(const char *isofile) { // check if this image contains mixed subchannel data token = strtok(NULL, " "); - if (token != NULL && !strncmp(token, "RW_RAW", 6)) { - subChanMixed = TRUE; - subChanRaw = TRUE; + if (token != NULL && !strncmp(token, "RW", 2)) { sector_size = CD_FRAMESIZE_RAW + SUB_FRAMESIZE; + subChanMixed = TRUE; + if (!strncmp(token, "RW_RAW", 6)) + subChanRaw = TRUE; } } else if (!strncmp(token, "AUDIO", 5)) { @@ -234,16 +239,33 @@ static int parsetoc(const char *isofile) { sec2msf(t, (char *)&ti[numtracks].start); tok2msf((char *)&time2, (char *)&ti[numtracks].length); } - else if (!strcmp(token, "ZERO")) { - sscanf(linebuf, "ZERO AUDIO RW_RAW %8s", time); - tok2msf((char *)&time, dummy); - sector_offs += msf2sec(dummy); + else if (!strcmp(token, "ZERO") || !strcmp(token, "SILENCE")) { + // skip unneeded optional fields + while (token != NULL) { + token = strtok(NULL, " "); + if (strchr(token, ':') != NULL) + break; + } + if (token != NULL) { + tok2msf(token, tmp); + current_zero_gap = msf2sec(tmp); + } if (numtracks > 1) { t = ti[numtracks - 1].start_offset; t /= sector_size; pregapOffset = t + msf2sec(ti[numtracks - 1].length); } } + else if (!strcmp(token, "START")) { + token = strtok(NULL, " "); + if (token != NULL && strchr(token, ':')) { + tok2msf(token, tmp); + t = msf2sec(tmp); + ti[numtracks].start_offset += (t - current_zero_gap) * sector_size; + t = msf2sec(ti[numtracks].start) + t; + sec2msf(t, (char *)&ti[numtracks].start); + } + } } fclose(fi); |
