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

This commit is contained in:
SND\weimingzhi_cp 2009-08-31 11:20:03 +00:00
parent d772714e45
commit 507ff7fa3c
6 changed files with 127 additions and 32 deletions

View File

@ -1,3 +1,14 @@
August 30, 2009 Wei Mingzhi <weimingzhi@gmail.com>
* libpcsxcore/cdriso.c: Implemented CDDA playing via SPUplayCDDAchannel().
Now CD tracks can be played directly via a SPU plugin which implements the
SPUplayCDDAchannel() function, e.g., spuEternal.
* libpcsxcore/cdriso.h: Removed unused prototypes.
* doc/tweaks.txt: Removed obsolete information.
* win32/pcsx.dsp: Use Multithreaded instead of Singlethreaded.
* plugins/dfsound/alsa.c: Set the buffer_time and period_time manually,
hopefully the "lagging" issue can be fixed.
August 29, 2009 Wei Mingzhi <weimingzhi@gmail.com>
* plugins/dfcdrom/cdr.c: Don't restart the track if play was called with

View File

@ -23,10 +23,3 @@ function. These can all be found at Configuration -> CPU.
* Enable Interpreter CPU:
Enables interpretive emulation.
This is often more compatible, but at the price of emulation speed.
Currently, PCSX-Reloaded does not support CD-DA tracks when loading
image files. In this case, to experience music in games such as Tekken
and Wipeout 2097, a CD emulation software should be used in conjunction
with the emulator. DAEMON Tools (http://www.daemon-tools.cc) and CDEmu
(http://cdemu.sourceforge.net) were tested to work under Windows and
GNU/Linux respectively.

View File

@ -18,11 +18,17 @@
* 51 Franklin Steet, Fifth Floor, Boston, MA 02111-1307 USA. *
***************************************************************************/
// TODO: implement CDDA support.
#include "psxcommon.h"
#include "plugins.h"
#ifdef _WIN32
#include <process.h>
#include <windows.h>
#else
#include <pthread.h>
#include <sys/time.h>
#endif
#define MSF2SECT(m, s, f) (((m) * 60 + (s) - 2) * 75 + (f))
#define btoi(b) ((b) / 16 * 10 + (b) % 16) /* BCD to u_char */
@ -32,11 +38,22 @@
#define SUB_FRAMESIZE 96
FILE *cdHandle = NULL;
FILE *cddaHandle = NULL;
FILE *subHandle = NULL;
static unsigned char cdbuffer[DATA_SIZE];
static unsigned char subbuffer[SUB_FRAMESIZE];
static unsigned char sndbuffer[CD_FRAMESIZE_RAW * 10];
#ifdef _WIN32
static HANDLE threadid;
#else
static pthread_t threadid;
#endif
static int initial_offset = 0;
static int playing = 0;
char* CALLBACK CDR__getDriveLetter(void);
long CALLBACK CDR__configure(void);
long CALLBACK CDR__test(void);
@ -71,17 +88,6 @@ static void sec2msf(unsigned int s, char *msf) {
msf[2] = s;
}
// get size of a track given the sector
unsigned int ISOgetTrackLength(unsigned int s) {
int i = 1;
while ((msf2sec(ti[i].start) < s) && i <= numtracks) {
i++;
}
return msf2sec(ti[--i].length);
}
// divide a string of xx:yy:zz into m, s, f
static void tok2msf(char *time, char *msf) {
char *token;
@ -111,12 +117,103 @@ static void tok2msf(char *time, char *msf) {
}
}
// start the CDDA playback
static void startCDDA(unsigned int offset) {
#ifndef _WIN32
static long GetTickCount(void) {
struct timeval now;
gettimeofday(&now, NULL);
return now.tv_sec * 1000L + now.tv_usec / 1000L;
}
#endif
// this thread plays audio data
#ifdef _WIN32
static void playthread(void *param)
#else
static void *playthread(void *param)
#endif
{
time_t t;
long d;
t = 0;
while (playing) {
d = (long)t - GetTickCount();
if (d > 0) {
#ifdef _WIN32
Sleep(d);
#else
usleep(d);
#endif
}
t = GetTickCount() + 1000 * (sizeof(sndbuffer) / CD_FRAMESIZE_RAW) / 75;
if ((d = fread(sndbuffer, 1, sizeof(sndbuffer), cddaHandle)) == 0) {
playing = 0;
fclose(cddaHandle);
cddaHandle = NULL;
initial_offset = 0;
break;
}
SPU_playCDDAchannel((short *)sndbuffer, d);
}
#ifdef _WIN32
_endthread();
#else
pthread_exit(0);
return NULL;
#endif
}
// stop the CDDA playback
static void stopCDDA() {
if (!playing) {
return;
}
playing = 0;
#ifdef _WIN32
WaitForSingleObject(threadid, INFINITE);
#else
pthread_join(threadid, NULL);
#endif
if (cddaHandle != NULL) {
fclose(cddaHandle);
cddaHandle = NULL;
}
initial_offset = 0;
}
// start the CDDA playback
static void startCDDA(unsigned int offset) {
if (playing) {
if (initial_offset == offset) {
return;
}
stopCDDA();
}
cddaHandle = fopen(cdrfilename, "rb");
if (cddaHandle == NULL) {
return;
}
initial_offset = offset;
fseek(cddaHandle, initial_offset, SEEK_SET);
offset /= CD_FRAMESIZE_RAW;
playing = 1;
#ifdef _WIN32
threadid = (HANDLE)_beginthread(playthread, 0, NULL);
#else
pthread_create(&threadid, NULL, playthread, NULL);
#endif
}
// this function tries to get the .toc file of the given .bin
@ -325,7 +422,7 @@ static int parseccd(const char *isofile) {
}
if (msf2sec(ti[numtracks].gap) != 0) {
sec2msf(t - msf2sec(ti[numtracks].gap), ti[numtracks].gap);
sec2msf(t - msf2sec(ti[numtracks].gap), ti[numtracks].gap);
}
t += msf2sec(ti[numtracks].gap);
@ -505,7 +602,6 @@ static unsigned char * CALLBACK ISOgetBuffer(void) {
// does NOT uses bcd format
static long CALLBACK ISOplay(unsigned char *time) {
if (SPU_playCDDAchannel != NULL) {
SysPrintf("Starting cdda-audio (%i:%i:%i)...\n", time[0], time[1], time[2]);
startCDDA(MSF2SECT(time[0], time[1], time[2]) * CD_FRAMESIZE_RAW);
}
return 0;

View File

@ -22,6 +22,5 @@
#define CDRISO_H
int imageReaderInit(void);
unsigned int ISOgetTrackLength(unsigned int s);
#endif

View File

@ -39,10 +39,8 @@ void SetupSound(void)
int pspeed;
int pchannels;
int format;
#if 0
int buffer_time = 500000;
int buffer_time = 50000;
int period_time = buffer_time / 4;
#endif
int err;
if (iDisStereo) pchannels = 1;
@ -96,7 +94,6 @@ void SetupSound(void)
return;
}
#if 0
if((err=snd_pcm_hw_params_set_buffer_time_near(handle, hwparams, &buffer_time, 0))<0)
{
printf("Buffer time error: %s\n", snd_strerror(err));
@ -108,7 +105,6 @@ void SetupSound(void)
printf("Period time error: %s\n", snd_strerror(err));
return;
}
#endif
if((err=snd_pcm_hw_params(handle, hwparams))<0)
{

View File

@ -43,7 +43,7 @@ RSC=rc.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
# ADD CPP /nologo /G6 /Zp16 /W3 /GX /O2 /Op /Ob2 /I "../" /I "./zlib" /I "../libpcsxcore" /I "./glue" /I "./" /I "./gui" /I "./intl" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "__WIN32__" /D "_MSC_VER_" /D PCSX_VERSION=\"1.5\" /D "__i386__" /D "ENABLE_NLS" /D PACKAGE=\"pcsx\" /D inline=__forceinline /FR /FD /Zm200 /c
# ADD CPP /nologo /G6 /Zp16 /MT /W3 /GX /O2 /Op /Ob2 /I "../" /I "./zlib" /I "../libpcsxcore" /I "./glue" /I "./" /I "./gui" /I "./intl" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "__WIN32__" /D "_MSC_VER_" /D PCSX_VERSION=\"1.5\" /D "__i386__" /D "ENABLE_NLS" /D PACKAGE=\"pcsx\" /D inline=__forceinline /FR /FD /Zm200 /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x408 /d "NDEBUG"
@ -69,7 +69,7 @@ LINK32=link.exe
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D PCSX_VERSION=\"1.3\" /YX /FD /GZ /c
# ADD CPP /nologo /W3 /GX /ZI /Od /I "../" /I "./zlib" /I "../libpcsxcore" /I "./glue" /I "./" /I "./gui" /I "./intl" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "__WIN32__" /D "__i386__" /D PCSX_VERSION=\"1.5\" /D "ENABLE_NLS" /D PACKAGE=\"pcsx\" /D inline= /FR /FD /GZ /Zm200 /c
# ADD CPP /nologo /MTd /W3 /GX /ZI /Od /I "../" /I "./zlib" /I "../libpcsxcore" /I "./glue" /I "./" /I "./gui" /I "./intl" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "__WIN32__" /D "__i386__" /D PCSX_VERSION=\"1.5\" /D "ENABLE_NLS" /D PACKAGE=\"pcsx\" /D inline= /FR /FD /GZ /Zm200 /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x408 /d "_DEBUG"