git-svn-id: https://pcsxr.svn.codeplex.com/svn/pcsxr@38307 e17a0e51-4ae3-4d35-97c3-1a29b211df97

This commit is contained in:
SND\weimingzhi_cp 2009-11-27 08:19:43 +00:00
parent 24054df7ea
commit d4ce960b51
3 changed files with 64 additions and 58 deletions

View File

@ -1,3 +1,11 @@
November 28, 2009 Wei Mingzhi <weimingzhi@gmail.com>
* plugins/dfcdrom/cdr-linux.c: Don't return NULL when CDRgetBuffer() is
called more than once without another CDRreadTrack() call in threaded
mode, which solves the problem with Final Fantasy 6 (maybe other games
too).
* plugins/dfcdrom/cdr.h: Moved global variables into cdr-linux.c.
November 27, 2009 Wei Mingzhi <weimingzhi@gmail.com>
* plugins/dfcdrom/cdrcfg-0.1df/main.c: Rewritten the configuration utility

View File

@ -30,6 +30,18 @@ int initial_time = 0;
pthread_mutex_t mut = PTHREAD_MUTEX_INITIALIZER;
pthread_cond_t cond = PTHREAD_COND_INITIALIZER;
CacheData *cdcache;
unsigned char *cdbuffer;
int cacheaddr;
crdata cr;
unsigned char lastTime[3];
int cdHandle;
pthread_t thread;
int subqread;
volatile int stopth, found, locked, playing;
long (*ReadTrackT[])() = {
ReadNormal,
ReadThreaded,
@ -247,7 +259,7 @@ long ReadThreaded() {
unsigned char* GetBThreaded() {
PRINTF("threadc %d\n", found);
if (found == 1) { found = 0; return cdbuffer; }
if (found == 1) { /*found = 0;*/ return cdbuffer; }
cdbuffer = cdcache[0].cr.buf + 12;
while (btoi(cdbuffer[0]) != cr.msf.cdmsf_min0 ||
btoi(cdbuffer[1]) != cr.msf.cdmsf_sec0 ||
@ -260,6 +272,49 @@ unsigned char* GetBThreaded() {
return cdbuffer;
}
void *CdrThread(void *arg) {
unsigned char curTime[3];
int i;
for (;;) {
locked = 1;
pthread_mutex_lock(&mut);
pthread_cond_wait(&cond, &mut);
if (stopth == 2) pthread_exit(NULL);
// refill the buffer
cacheaddr = msf_to_lba(cr.msf.cdmsf_min0, cr.msf.cdmsf_sec0, cr.msf.cdmsf_frame0);
memcpy(curTime, &cr.msf, 3);
PRINTF("start thc %d:%d:%d\n", curTime[0], curTime[1], curTime[2]);
for (i = 0; i < CacheSize; i++) {
memcpy(&cdcache[i].cr.msf, curTime, 3);
PRINTF("reading %d:%d:%d\n", curTime[0], curTime[1], curTime[2]);
cdcache[i].ret = ioctl(cdHandle, CDROMREADRAW, &cdcache[i].cr);
PRINTF("readed %x:%x:%x\n", cdcache[i].cr.buf[12], cdcache[i].cr.buf[13], cdcache[i].cr.buf[14]);
if (cdcache[i].ret == -1) break;
curTime[2]++;
if (curTime[2] == 75) {
curTime[2] = 0;
curTime[1]++;
if (curTime[1] == 60) {
curTime[1] = 0;
curTime[0]++;
}
}
if (stopth) break;
}
pthread_mutex_unlock(&mut);
}
return NULL;
}
// read track
// time:
@ -285,50 +340,6 @@ long CDRreadTrack(unsigned char *time) {
return fReadTrack();
}
void *CdrThread(void *arg) {
unsigned char curTime[3];
int i;
for (;;) {
locked = 1;
pthread_mutex_lock(&mut);
pthread_cond_wait(&cond, &mut);
if (stopth == 2) pthread_exit(NULL);
// refill the buffer
cacheaddr = msf_to_lba(cr.msf.cdmsf_min0, cr.msf.cdmsf_sec0, cr.msf.cdmsf_frame0);
memcpy(curTime, &cr.msf, 3);
PRINTF("start thc %d:%d:%d\n", curTime[0], curTime[1], curTime[2]);
for (i=0; i<CacheSize; i++) {
memcpy(&cdcache[i].cr.msf, curTime, 3);
PRINTF("reading %d:%d:%d\n", crp.msf.cdmsf_min0, crp.msf.cdmsf_sec0, crp.msf.cdmsf_frame0);
cdcache[i].ret = ioctl(cdHandle, CDROMREADRAW, &cdcache[i].cr);
PRINTF("readed %x:%x:%x\n", crd.buf[12], crd.buf[13], crd.buf[14]);
if (cdcache[i].ret == -1) break;
curTime[2]++;
if (curTime[2] == 75) {
curTime[2] = 0;
curTime[1]++;
if (curTime[1] == 60) {
curTime[1] = 0;
curTime[0]++;
}
}
if (stopth) break;
}
pthread_mutex_unlock(&mut);
}
return NULL;
}
// return readed track
unsigned char *CDRgetBuffer(void) {
return fGetBuffer();

View File

@ -48,24 +48,11 @@ typedef union {
unsigned char buf[CD_FRAMESIZE_RAW];
} crdata;
crdata cr;
typedef struct {
crdata cr;
int ret;
} CacheData;
CacheData *cdcache;
unsigned char *cdbuffer;
int cacheaddr;
unsigned char lastTime[3];
int cdHandle;
pthread_t thread;
int subqread, stopth;
int found, locked;
int playing;
long ReadNormal();
long ReadThreaded();
unsigned char* GetBNormal();