cdriso: handle no disk state better
authornotaz <notasas@gmail.com>
Thu, 14 Mar 2013 23:49:37 +0000 (01:49 +0200)
committernotaz <notasas@gmail.com>
Fri, 15 Mar 2013 00:19:21 +0000 (02:19 +0200)
libpcsxcore/cdriso.c

index 21203da..dde21bc 100644 (file)
@@ -1316,8 +1316,12 @@ static long CALLBACK ISOclose(void) {
                }
        }
        numtracks = 0;
+       ti[1].type = 0;
        UnloadSBI();
 
+       memset(cdbuffer, 0, sizeof(cdbuffer));
+       CDR_getBuffer = ISOgetBuffer;
+
        return 0;
 }
 
@@ -1400,6 +1404,7 @@ static void DecodeRawSubData(void) {
 // uses bcd format
 static long CALLBACK ISOreadTrack(unsigned char *time) {
        int sector = MSF2SECT(btoi(time[0]), btoi(time[1]), btoi(time[2]));
+       long ret;
 
        if (cdHandle == NULL) {
                return -1;
@@ -1414,7 +1419,9 @@ static long CALLBACK ISOreadTrack(unsigned char *time) {
                }
        }
 
-       cdimg_read_func(cdHandle, 0, cdbuffer, sector);
+       ret = cdimg_read_func(cdHandle, 0, cdbuffer, sector);
+       if (ret < 0)
+               return -1;
 
        if (subHandle != NULL) {
                fseek(subHandle, sector * SUB_FRAMESIZE, SEEK_SET);