Actually I just added that before my calles to GetDiscInformation and GetTOCInformation. Still never exits StarBurn_CdvdBurnerGrabber_GrabTrack.
Below is my RunGrabTracksThread and GrabTracks subroutines. RunGrabTracksThread is run in a seperate thread from my main application.
Code:
void CDVDBurnerGrabber::RunGrabTracksThread()
{
UINT retval=ERRNORMAL;
if(Load()){
if(TestUnitReady()){
SetSpeeds(CDVD_SPEED_IS_KBPS_MAXIMUM,CDVD_SPEED_IS_KBPS_MAXIMUM);
GetSpeeds(g_Drives[m_DriveIndex].l__ULONG__CurrentReadSpeed,
g_Drives[m_DriveIndex].l__ULONG__MaximumReadSpeed,
g_Drives[m_DriveIndex].l__ULONG__CurrentWriteSpeed,
g_Drives[m_DriveIndex].l__ULONG__MaximumWriteSpeed);
StarBurn_SetFastReadTOC( /* FALSE */ TRUE );
DISC_INFORMATION DiscInformation;
RtlZeroMemory(
&DiscInformation,
sizeof(DiscInformation)
);
TOC_INFORMATION TOCInformation;
RtlZeroMemory(
&TOCInformation,
sizeof(TOCInformation)
);
if(GetDiscInformation(&DiscInformation)){
GetTOCInformation(&TOCInformation);
if(TOCInformation.m__BOOLEAN__IsDVD){
m_ReadSpeed=m_DVDReadSpeed;
m_WriteSpeed=m_DVDWriteSpeed;
}
else{
m_ReadSpeed=m_CDReadSpeed;
m_WriteSpeed=m_CDWriteSpeed;
}
SetSpeeds(m_ReadSpeed,m_WriteSpeed);
GetSpeeds(g_Drives[m_DriveIndex].l__ULONG__CurrentReadSpeed,
g_Drives[m_DriveIndex].l__ULONG__MaximumReadSpeed,
g_Drives[m_DriveIndex].l__ULONG__CurrentWriteSpeed,
g_Drives[m_DriveIndex].l__ULONG__MaximumWriteSpeed);
if(DiscInformation.m__UCHAR__DiscStatus!=DISC_STATUS_EMPTY){
if(TOCInformation.m__UCHAR__NumberOfTracks){
CArray<CString,CString> filenames;
if(TOCInformation.m__TOC_ENTRY[1].m__BOOLEAN__IsAudio){
if(GetCDDBInfo()){
for(UCHAR count=0;count<TOCInformation.m__UCHAR__NumberOfTracks;count++){
CString name="";
filenames.Add(m_RipDirectory + m_CDTextArtist[1] + "_" + m_CDTextTitle[1] + "_" + m_TrackNames[count] + ".wav");
} ;
}
else{
SYSTEMTIME st;
GetSystemTime(&st);// gets current time
CString uniqueID;
uniqueID.Format("%2.2u%2.2u%2.2u%2.2u%2.2u%2.2u",(int)st.wHour,(int)st.wMinute,(int)st.wSecond,(int)st.wYear,(int)st.wMonth,(int)st.wDay);
for(UCHAR count=0;count<TOCInformation.m__UCHAR__NumberOfTracks;count++){
CString track="";
if(TOCInformation.m__UCHAR__NumberOfTracks>1)
track.Format("_Track%u",count);
filenames.Add(m_RipDirectory + uniqueID + track + ".wav");
}
}
}
else{
CString volumename,filesystem;
char string[1024];
DWORD serial,maxlength,flags;
if(GetVolumeInformation(m_VolumePath,string,1024,&serial,&maxlength,&flags,filesystem.GetBuffer(1024),1024)){
volumename = string;
for(UCHAR count=0;count<TOCInformation.m__UCHAR__NumberOfTracks;count++){
CString track="";
if(TOCInformation.m__UCHAR__NumberOfTracks>1)
track.Format("_Track%u",count);
filenames.Add(m_RipDirectory + volumename + track + ".iso");
}
}
else{
SYSTEMTIME st;
GetSystemTime(&st);// gets current time
CString uniqueID;
uniqueID.Format("%2.2u%2.2u%2.2u%2.2u%2.2u%2.2u",(int)st.wHour,(int)st.wMinute,(int)st.wSecond,(int)st.wYear,(int)st.wMonth,(int)st.wDay);
for(UCHAR count=0;count<TOCInformation.m__UCHAR__NumberOfTracks;count++){
CString track="";
if(TOCInformation.m__UCHAR__NumberOfTracks>1)
track.Format("_Track%u",count);
filenames.Add(m_RipDirectory + uniqueID + track + ".iso");
}
}
}
if(GrabTracks(filenames,
TOCInformation,
NUMBER_OF_READ_RETRIES,
TRUE,
FALSE,
READ_REPORT_DELAY_IN_SECONDS)){
if(!Eject()){
retval=ERREJECT;
}
}
else{
Eject();
retval=ERRDISC;
}
}
else{
Eject();
retval=ERRDISC;
}
}
else{
Eject();
retval=ERRDISC;
}
}
else{
Eject();
retval=ERRDISC;
}
}
else{
Eject();
retval=ERRDISC;
}
}
else{
retval=ERRLOAD;
}
FinishThread(retval);
}
BOOL CDVDBurnerGrabber::GrabTracks(CArray<CString,CString> &FileNames,
TOC_INFORMATION TOCInformation,
LONG Retries,
BOOLEAN IsBadBlockIgnore,
BOOLEAN IsSingleLBTransferForced,
ULONG ReadReportDelayInSeconds)
{
if(FileNames.GetSize()<TOCInformation.m__UCHAR__NumberOfTracks)
return FALSE;
for(UCHAR track=0;track<TOCInformation.m__UCHAR__NumberOfTracks;track++){
m_pCallback(m_Index,m_Drive,0x10000 | ((track+1)&0xFF) | ((TOCInformation.m__UCHAR__NumberOfTracks&0xFF)<<8));
if(m_bIsCreated && IsUpStart()){
l__EXCEPTION_NUMBER =
StarBurn_CdvdBurnerGrabber_GrabTrack(
l__PVOID__CdvdBurnerGrabber,
( PCHAR )( &l__CHAR__ExceptionText ),
sizeof( l__CHAR__ExceptionText ),
&l__ULONG__SystemError,
&l__CDB_FAILURE_INFORMATION,
track+1,
FileNames[track].GetBuffer(FileNames[track].GetLength()),
Retries,
IsBadBlockIgnore,
IsSingleLBTransferForced,
ReadReportDelayInSeconds
);
//Never gets here
// Check for correct reply
if ( l__EXCEPTION_NUMBER != EN_SUCCESS )
{
WriteExceptionLog(l__EXCEPTION_NUMBER,l__ULONG__SystemError);
return FALSE;
}
}
else{
return FALSE;
}
}
return TRUE;
}