U
uuid
Unregistered / Unconfirmed
GUEST, unregistred user!
将下面代码转到Delphi:
int PLAYER_write(int handle, unsigned char*buffer,int size ,unsigned int waitTime);
FILE* in;
HANDLE begin
PlayEvent;
bool begin
=false;
bool discardData=false;
HANDLE hInputThread;
DWORD WINAPI inputThreadFunc(LPVOID lpParam)
{
char buf[80000];
int number=fread(buf,1 ,642,in);
int count=0;
WaitForSingleObject(begin
PlayEvent,-1);
ResetEvent(begin
PlayEvent);
for(int j=0;j<1000;j++)
{
while(number&&
begin
)
{
int count = number;
int size;
unsigned char* ptr = (unsigned char*)buf;
while(count)
{
size = PLAYER_write(playerId, ptr, count, -1);
count -= size;
ptr= ((unsigned char*)buf) + size;
if(!begin
)break;
}
if(discardData)
{
fread(buf,1,1,in);
discardData=false;
}
number=fread(buf,1,1000,in);
}
fseek(in,642,SEEK_SET);
number=fread(buf,1,1000,in);
if(!begin
)break;
}
return 1;
}
char fileName[128];
in=fopen(fileName,"rb");
if(in)...
begin
PlayEvent=CreateEvent(NULL,true,false,NULL);
DWORD dwThreadId;
hInputThread=CreateThread(NULL,0,inputThreadFunc,0,0,&dwThreadId);
int PLAYER_write(int handle, unsigned char*buffer,int size ,unsigned int waitTime);
FILE* in;
HANDLE begin
PlayEvent;
bool begin
=false;
bool discardData=false;
HANDLE hInputThread;
DWORD WINAPI inputThreadFunc(LPVOID lpParam)
{
char buf[80000];
int number=fread(buf,1 ,642,in);
int count=0;
WaitForSingleObject(begin
PlayEvent,-1);
ResetEvent(begin
PlayEvent);
for(int j=0;j<1000;j++)
{
while(number&&
begin
)
{
int count = number;
int size;
unsigned char* ptr = (unsigned char*)buf;
while(count)
{
size = PLAYER_write(playerId, ptr, count, -1);
count -= size;
ptr= ((unsigned char*)buf) + size;
if(!begin
)break;
}
if(discardData)
{
fread(buf,1,1,in);
discardData=false;
}
number=fread(buf,1,1000,in);
}
fseek(in,642,SEEK_SET);
number=fread(buf,1,1000,in);
if(!begin
)break;
}
return 1;
}
char fileName[128];
in=fopen(fileName,"rb");
if(in)...
begin
PlayEvent=CreateEvent(NULL,true,false,NULL);
DWORD dwThreadId;
hInputThread=CreateThread(NULL,0,inputThreadFunc,0,0,&dwThreadId);