From: Yarek on
Hi. I'm trying to figure out how the cddareader works (GPL directshow plugin
for reading audio tracks from a cd-rom).

I got the cddareader inserted into the graph and I invoke the Load function
- part of the implementation below shows what works and what fails:


// WORKS OK
DWORD BytesReturned;
lRes = DeviceIoControl(m_hDrive, IOCTL_CDROM_READ_TOC, NULL, 0, &m_TOC,
sizeof(m_TOC), &BytesReturned, 0);
if(!lRes || !(m_TOC.FirstTrack <= iTrackIndex && iTrackIndex <=
m_TOC.LastTrack))
{
CloseHandle(m_hDrive);
m_hDrive = INVALID_HANDLE_VALUE;
return(false);
}

// MMC-3 Draft Revision 10g: Table 222 – Q Sub-channel control field
m_TOC.TrackData[iTrackIndex-1].Control &= 5;
if(!(m_TOC.TrackData[iTrackIndex-1].Control == 0 ||
m_TOC.TrackData[iTrackIndex-1].Control == 1))
{
CloseHandle(m_hDrive);
m_hDrive = INVALID_HANDLE_VALUE;
return(false);
}

if(m_TOC.TrackData[iTrackIndex-1].Control&8)
m_header.frm.pcm.wf.nChannels = 4;

m_nStartSector = MSF2UINT(m_TOC.TrackData[iTrackIndex-1].Address) -
150;//MSF2UINT(m_TOC.TrackData[0].Address);
m_nStopSector = MSF2UINT(m_TOC.TrackData[iTrackIndex].Address) -
150;//MSF2UINT(m_TOC.TrackData[0].Address);

m_llLength = (m_nStopSector-m_nStartSector)*RAW_SECTOR_SIZE;

m_header.riff.hdr.chunkSize = (long)(m_llLength + sizeof(m_header) - 8);
m_header.data.hdr.chunkSize = (long)(m_llLength);

do
{
DWORD lErr = 0;
CDROM_READ_TOC_EX TOCEx;
memset(&TOCEx, 0, sizeof(TOCEx));
TOCEx.Format = CDROM_READ_TOC_EX_FORMAT_CDTEXT;
TOCEx.SessionTrack = iTrackIndex;
WORD size = 0;
ASSERT(MINIMUM_CDROM_READ_TOC_EX_SIZE == sizeof(size));

// HERE IS THE PROBLEM!!
// WORKS on one laptop with VISTA and fails on othe with VISTA
lRes = DeviceIoControl(m_hDrive, IOCTL_CDROM_READ_TOC_EX, &TOCEx,
sizeof(TOCEx), &size, sizeof(size), &BytesReturned, 0);
if(!lRes){
lErr = ::GetLastError();
break;
}
// END PROBLEM

size = ((size>>8)|(size<<8)) + sizeof(size);

CAutoVectorPtr<BYTE> pCDTextData;
pCDTextData.Allocate(size);
memset(pCDTextData, 0, size);

// end code
I'm wondering what could cause such issue. I'm trying to read the contents
of the CD-ROM (with audio cd inserted). , just a the do loop exits via
'break' - DeviceIoControl returns 0 and GetLastError returns 1.

Any suggestions what could cause such issue?
Kind Regards,
Yarek