m_stMediaEntry is of kind
MEDIA_ENTRY.
m_bProcessing is an instance-variable, set by the dialogs cancel-button...
for ease (temporary), I only process Audio-Tracks...
m_iTracks is a variable to hold the number of grabed tracks (might differ from
m_stMediaEntry.stTOC_INFORMATION.m__UCHAR__NumberOfTracks because of filtering the Data-Tracks)
As you can see, I "abuse" my own
CopyCallback-Function and send a
TrackBegin/TrackEnd notification (it's "historical" - I once grabbed the whole disc...)
1) creating wav's (simple)
Code:
nEXCEPTION_NUMBER = StarBurn_CdvdBurnerGrabber_Create( &astCDEntry[ m_iSourceDrive ].pvDiscObject,
( PCHAR )( &szExceptionText ),
sizeof( szExceptionText ),
&lStatus,
&stCDB_FAILURE_INFORMATION,
( PCALLBACK )( CopyCallback ),
this,
astCDEntry[ m_iSourceDrive ].ucPortID,
astCDEntry[ m_iSourceDrive ].ucBusID,
astCDEntry[ m_iSourceDrive ].ucTargetID,
astCDEntry[ m_iSourceDrive ].ucLUN,
0 /* DEFAULT_CACHE_SIZE_IN_MBS */ );
if ( nEXCEPTION_NUMBER != EN_SUCCESS || astCDEntry[ m_iSourceDrive ].pvDiscObject == NULL )
{
break;
}
lStatus = ERROR_SUCCESS;
nEXCEPTION_NUMBER = StarBurn_CdvdBurnerGrabber_SetSpeeds( astCDEntry[ m_iSourceDrive ].pvDiscObject,
( PCHAR )( &szExceptionText ),
sizeof( szExceptionText ),
&lStatus,
&stCDB_FAILURE_INFORMATION,
m_pSettings->uiCopyCDReadSpeed,
0xFFFF );
if ( nEXCEPTION_NUMBER != EN_SUCCESS )
{
break;
}
lStatus = ERROR_SUCCESS;
nEXCEPTION_NUMBER = StarBurn_CdvdBurnerGrabber_Lock( astCDEntry[ m_iSourceDrive ].pvDiscObject,
( PCHAR )( &szExceptionText ),
sizeof( szExceptionText ),
&lStatus,
&stCDB_FAILURE_INFORMATION );
if ( nEXCEPTION_NUMBER != EN_SUCCESS )
{
break;
}
for ( int i = 0; m_bProcessing && i < m_stMediaEntry.stTOC_INFORMATION.m__UCHAR__NumberOfTracks; i++ )
{
if ( m_stMediaEntry.stTOC_INFORMATION.m__TOC_ENTRY[ i ].m__BOOLEAN__IsValid )
{
if ( m_stMediaEntry.stTOC_INFORMATION.m__TOC_ENTRY[ i ].m__BOOLEAN__IsAudio )
{
// grab this track
char szFilename[ MAX_PATH ];
sprintf( szFilename, "%s\\Track%02i.wav", m_pSettings->szCopyCDBufferPath, i + 1 );
ULONG ulTrack = i + 1;
CopyCallback( CN_CDVD_TRACK_BEGIN, this, ( PVOID )&ulTrack, NULL );
lStatus = ERROR_SUCCESS;
nEXCEPTION_NUMBER = StarBurn_CdvdBurnerGrabber_GrabTrack( astCDEntry[ m_iSourceDrive ].pvDiscObject,
( PCHAR )( &szExceptionText ),
sizeof( szExceptionText ),
&lStatus,
&stCDB_FAILURE_INFORMATION,
i + 1,
szFilename,
10, //+++NUMBER_OF_READ_RETRIES,
FALSE, //+++ IsBadBlockIgnore
FALSE, //+++ IsSingleLBTransferForced
1 ); //+++READ_REPORT_DELAY_IN_SECONDS
CopyCallback( CN_CDVD_TRACK_END, this, ( PVOID )&ulTrack, NULL );
m_iTracks++;
}
}
StarBurn_CdvdBurnerGrabber_Release( astCDEntry[ m_iSourceDrive ].pvDiscObject,
( PCHAR )( &szExceptionText ),
sizeof( szExceptionText ),
&lStatus,
&stCDB_FAILURE_INFORMATION );
if ( m_iDestinationDrive == m_iSourceDrive )
{
StarBurn_CdvdBurnerGrabber_Eject( astCDEntry[ m_iSourceDrive ].pvDiscObject,
( PCHAR )( &szExceptionText ),
sizeof( szExceptionText ),
&lStatus,
&stCDB_FAILURE_INFORMATION );
CString s;
s.Format( "Please remove the source-disc from drive %s and insert a blank disc!", astCDEntry[ m_iSourceDrive ].szDeviceName );
if ( AfxMessageBox( s, MB_OKCANCEL ) != IDOK )
{
break;
}
}
StarBurn_Destroy( &astCDEntry[ m_iSourceDrive ].pvDiscObject );
astCDEntry[ m_iSourceDrive ].pvDiscObject = NULL;
2) write them to disc (also simple)
Code:
nEXCEPTION_NUMBER = StarBurn_CdvdBurnerGrabber_Create( &astCDEntry[ m_iDestinationDrive ].pvDiscObject,
( PCHAR )( &szExceptionText ),
sizeof( szExceptionText ),
&lStatus,
&stCDB_FAILURE_INFORMATION,
( PCALLBACK )( WriteCallback ),
this,
astCDEntry[ m_iDestinationDrive ].ucPortID,
astCDEntry[ m_iDestinationDrive ].ucBusID,
astCDEntry[ m_iDestinationDrive ].ucTargetID,
astCDEntry[ m_iDestinationDrive ].ucLUN,
0 /* DEFAULT_CACHE_SIZE_IN_MBS */ );
if ( nEXCEPTION_NUMBER != EN_SUCCESS || astCDEntry[ m_iDestinationDrive ].pvDiscObject == NULL )
{
break;
}
lStatus = ERROR_SUCCESS;
nEXCEPTION_NUMBER = StarBurn_CdvdBurnerGrabber_SetSpeeds( astCDEntry[ m_iDestinationDrive ].pvDiscObject,
( PCHAR )( &szExceptionText ),
sizeof( szExceptionText ),
&lStatus,
&stCDB_FAILURE_INFORMATION,
0xFFFF,
m_pSettings->uiCopyCDWriteSpeed );
lStatus = ERROR_SUCCESS;
nEXCEPTION_NUMBER = StarBurn_CdvdBurnerGrabber_Lock( astCDEntry[ m_iDestinationDrive ].pvDiscObject,
( PCHAR )( &szExceptionText ),
sizeof( szExceptionText ),
&lStatus,
&stCDB_FAILURE_INFORMATION );
nEXCEPTION_NUMBER = StarBurn_CdvdBurnerGrabber_GetBUP( astCDEntry[ m_iDestinationDrive ].pvDiscObject,
( PCHAR )( &szExceptionText ),
sizeof( szExceptionText ),
&lStatus,
&stCDB_FAILURE_INFORMATION,
&bBUPEnabled,
&bBUPSupported );
if ( nEXCEPTION_NUMBER != EN_SUCCESS )
{
break;
}
if ( bBUPSupported && !bBUPEnabled )
{
nEXCEPTION_NUMBER = StarBurn_CdvdBurnerGrabber_SetBUP( astCDEntry[ m_iDestinationDrive ].pvDiscObject,
( PCHAR )( &szExceptionText ),
sizeof( szExceptionText ),
&lStatus,
&stCDB_FAILURE_INFORMATION,
TRUE );
if ( nEXCEPTION_NUMBER != EN_SUCCESS )
{
break;
}
}
//
// Try to send OPC
//
nEXCEPTION_NUMBER = StarBurn_CdvdBurnerGrabber_SendOPC( astCDEntry[ m_iDestinationDrive ].pvDiscObject,
( PCHAR )( &szExceptionText ),
sizeof( szExceptionText ),
&lStatus,
&stCDB_FAILURE_INFORMATION );
if ( nEXCEPTION_NUMBER != EN_SUCCESS )
{
//+++ don't break!
//break;
}
for ( int i = 0; m_bProcessing && i < m_iTracks; i++ )
{
char szFilename[ MAX_PATH ];
sprintf( szFilename, "%s\\Track%02i.wav", m_pSettings->szCopyCDBufferPath, i + 1 );
lStatus = ERROR_SUCCESS;
nEXCEPTION_NUMBER = StarBurn_CdvdBurnerGrabber_TrackAtOnceFromFile( astCDEntry[ m_iDestinationDrive ].pvDiscObject,
( PCHAR )( &szExceptionText ),
sizeof( szExceptionText ),
&lStatus,
&stCDB_FAILURE_INFORMATION,
szFilename,
FALSE, // CD-X
FALSE, // test
TRUE, // next session
1,
1 );
if ( nEXCEPTION_NUMBER != EN_SUCCESS )
{
break;
}
DoMessageLoop( this );
}
nEXCEPTION_NUMBER = StarBurn_CdvdBurnerGrabber_CloseSession( astCDEntry[ m_iDestinationDrive ].pvDiscObject,
( PCHAR )( &szExceptionText ),
sizeof( szExceptionText ),
&lStatus,
&stCDB_FAILURE_INFORMATION );
and so on...destroying objects...
between the code-fragments may be some more code (testing for success and some more GUI-stuff, of course)
why does the resulting disc have 1 session with 0 tracks???