#1 Burning Software

It is currently Thu Mar 28, 2024 8:55 pm

All times are UTC




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: How to cancel burn in progress
PostPosted: Mon Feb 07, 2005 5:50 pm 
Offline

Joined: Fri Jan 28, 2005 7:13 pm
Posts: 11
After I call StarBurn_CdvdBurnerGrabber_Cancel it seems like any other function call I make causes the program to lock up. If I forceable close the my program, I then have to reboot my computer for the CD-Writer (Plextor PX-W5224A) to show up thru StarBurn_FindDevice().

What is the best way to cancel a burn in progress and is there any Callback Numbers I can use to update a progress bar to let the user know something is happening?

Thanks,

Michael


Top
 Profile  
 
 Post subject: Re: How to cancel burn in progress
PostPosted: Tue Feb 08, 2005 7:55 am 
Offline
Site Admin

Joined: Fri Jun 18, 2004 12:03 am
Posts: 4089
Location: British Virgin Islands
1) You're definitely doing something wrong. I'd like to see your source code snippet and know more about general application (threading model f.e) design before telling more what's wrong with your code.

2) I'd recommend you to look thru the console samples. There's more or less generic code for "Callback" function. Just check out how our samples process CN_CDVD_WRITE_PROGRESS, CN_CDVD_BUFFER_STATUS and CN_SYNCHRONIZE_CACHE_XXX callback operation codes.

pipelogix wrote:
After I call StarBurn_CdvdBurnerGrabber_Cancel it seems like any other function call I make causes the program to lock up. If I forceable close the my program, I then have to reboot my computer for the CD-Writer (Plextor PX-W5224A) to show up thru StarBurn_FindDevice().

What is the best way to cancel a burn in progress and is there any Callback Numbers I can use to update a progress bar to let the user know something is happening?

Thanks,

Michael


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 08, 2005 6:52 pm 
Offline

Joined: Fri Jan 28, 2005 7:13 pm
Posts: 11
Here is my code for handling the cancel.

StarBurn_CdvdBurnerGrabber_Cancel(m_CDGrabber);

SetProgressMessage("Closing Disc");

en = StarBurn_CdvdBurnerGrabber_CloseSession(m_CDGrabber,szE,sizeof(szE),&ulStatus,&cdbFailInfo);

SetProgressMessage("Ejecting Disc");

en = StarBurn_CdvdBurnerGrabber_Eject(m_CDGrabber,szE,sizeof(szE),&ulStatus,&cdbFailInfo);

SetProgressMessage updates the text of a static control on a dialog

I am using a Free Threaded model. One thread for the dailog GUI handle then another thread for the actually burning procedure.

No errors occur on calling _Cancel. Once _CloseSession is called everything just hangs. I have also tried called _Eject right after _Cancel with the same result.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 08, 2005 7:20 pm 
Offline

Joined: Mon May 31, 2004 6:22 am
Posts: 134
Hi,

Please, download our Cancel sample:
http://www.rocketdivision.com/downloads/MFCSample.zip
It shows how to update progress bar, how to handle Cancel button.

Contact me, if you will have any questions.

Regards,
Alexey

pipelogix wrote:
Here is my code for handling the cancel.

StarBurn_CdvdBurnerGrabber_Cancel(m_CDGrabber);

SetProgressMessage("Closing Disc");

en = StarBurn_CdvdBurnerGrabber_CloseSession(m_CDGrabber,szE,sizeof(szE),&ulStatus,&cdbFailInfo);

SetProgressMessage("Ejecting Disc");

en = StarBurn_CdvdBurnerGrabber_Eject(m_CDGrabber,szE,sizeof(szE),&ulStatus,&cdbFailInfo);

SetProgressMessage updates the text of a static control on a dialog

I am using a Free Threaded model. One thread for the dailog GUI handle then another thread for the actually burning procedure.

No errors occur on calling _Cancel. Once _CloseSession is called everything just hangs. I have also tried called _Eject right after _Cancel with the same result.


Top
 Profile  
 
 Post subject: Found the issue
PostPosted: Wed Feb 09, 2005 6:50 pm 
Offline

Joined: Fri Jan 28, 2005 7:13 pm
Posts: 11
After looking over the MFC sample code and not seeing any differences in how I was handling the actually cancel, I looked into it further.

The MFC sample uses StarBurn...TrackAtOnceFromTree, I was using StarBurn..SessionAtOnce.

Can you not use StarnBurn_CdvdBurnerGrabber_Cancel to cancel SessionAtOnce?


Top
 Profile  
 
 Post subject: Re: Found the issue
PostPosted: Wed Feb 09, 2005 8:55 pm 
Offline
Site Admin

Joined: Fri Jun 18, 2004 12:03 am
Posts: 4089
Location: British Virgin Islands
1) Is our MFC sample working for you? Please give it a try before we'll continue.

2) You've never mentioned you're working with SAO in your original posts. I've asked for actual source code snippet and not for pseudo-code. You see, it DOES make sense.

3) If you're using SAO you DO NOT NEED to close session manually as you do now. This is BAD thing to do. We've provided you with programming samples and there's no single place where we do what you do now.

4) Alex would be checking cancel code + SAO tomorrow morning. Just to verify there are no problems on our side. If you'd find some time to do 1) would be just great!

Thank you!

pipelogix wrote:
After looking over the MFC sample code and not seeing any differences in how I was handling the actually cancel, I looked into it further.

The MFC sample uses StarBurn...TrackAtOnceFromTree, I was using StarBurn..SessionAtOnce.

Can you not use StarnBurn_CdvdBurnerGrabber_Cancel to cancel SessionAtOnce?


Top
 Profile  
 
 Post subject: Re: Found the issue
PostPosted: Thu Feb 10, 2005 11:42 am 
Offline

Joined: Mon May 31, 2004 6:22 am
Posts: 134
pipelogix wrote:
After looking over the MFC sample code and not seeing any differences in how I was handling the actually cancel, I looked into it further.

The MFC sample uses StarBurn...TrackAtOnceFromTree, I was using StarBurn..SessionAtOnce.

Can you not use StarnBurn_CdvdBurnerGrabber_Cancel to cancel SessionAtOnce?


I have just tested canceling when burning in SAO. It works fine.
But you see, Cancel can't stop the burning process immidiatelly. It should wait until buffer will become empty. It takes over 5 seconds. For small images cancel will not work, when all the data was sent to the buffer.
Here is a code I have tested SAO.

Code:

{-----------------------------------------------------------------------------}
{                                                                             }
{ Copyright (c) Rocket Division Software 2001-2005. All rights reserved.      }
{                                                                             }
{ Module Name:                                                                }
{                                                                             }
{    SessionAtOnceFromFile.dpr                                                }
{                                                                             }
{ Abstract:                                                                   }
{                                                                             }
{    SessionAtOnceFromFile is StarBurn sample application.                    }
{    ISO9660/Joliet/sound image recording to CD/DVD in Session-At-Once mode.  }
{                                                                             }
{    [ This is external sample that has StarBurn toolkit in a separate DLL ]  }
{                                                                             }
{ Author:                                                                     }
{                                                                             }
{    Anton A. Kolomyeytsev                                                    }
{                                                                             }
{    Alexey Popov                                                             }
{                                                                             }
{ Environment:                                                                }
{                                                                             }
{    Windows 95/98/ME/NT/2K/XP/2003 UserMode only                             }
{                                                                             }
{ Notes:                                                                      }
{                                                                             }
{ Known bugs/Illegal behavior:                                                }
{                                                                             }
{ ToDo:                                                                       }
{                                                                             }
{-----------------------------------------------------------------------------}

Program SessionAtOnceFromFile;

{$APPTYPE CONSOLE}

Uses
  Windows, SysUtils, Forms, StarBurn, SamplesTools;

{=============================================================================}
Var
    l__ULONG__Status : DWORD;

    l__CHAR__VendorID : Packed Array[ 1..1024 ] Of Char;

    l__CHAR__ProductID : Packed Array[ 1..1024 ] Of Char;

    l__CHAR__ProductRevisionLevel : Packed Array[ 1..1024 ] Of Char;

    l__ULONG__BufferSizeInUCHARs,
    l__ULONG__CurrentReadSpeed,
    l__ULONG__MaximumReadSpeed,
    l__ULONG__CurrentWriteSpeed,
    l__ULONG__MaximumWriteSpeed : DWORD;

    l__PVOID__CdvdBurnerGrabber : Pointer;

    l__EXCEPTION_NUMBER : EXCEPTION_NUMBER;

    l__CHAR__ExceptionText : Packed Array[ 1..1024 ] Of Char;

    l__CDB_FAILURE_INFORMATION : CDB_FAILURE_INFORMATION;

    l__DISC_INFORMATION : DISC_INFORMATION;

    l__DISC_TYPE  : DISC_TYPE;

    l__STRING     : String;

    l__BOOLEAN__IsSendOPCSuccessful,

    l__BOOLEAN__IsBUPSupported,

    l__BOOLEAN__IsBUPEnabled,

    l__BOOLEAN__IsTrackAtOnce,

    l__BOOLEAN__IsSessionAtOnce,

    l__BOOLEAN__IsDiscAtOncePQ,

    l__BOOLEAN__IsDiscAtOnceRawPW,

    l__BOOLEAN__IsTestWrite : Boolean;

    l__DISC_LAYOUT : DISC_LAYOUT;

    l__LONG__Index : Integer;

    l__TRACK_INFORMATION : TRACK_INFORMATION;

    l__HANDLE : THANDLE;

    l__ULONG__FileSizeLow : DWORD;

    l__ULONG__FileSizeHigh : DWORD;

    l__LARGE_INTEGER__FileSizeInUCHARs : LARGE_INTEGER;

    dwThreadId : DWORD;

Function CancelThread( P : Pointer):DWORD stdcall;
Begin
  OutputDebugString('CancelThread() : ENTERed!');
  Sleep(15*1000);
  OutputDebugString('CancelThread() : Canceling...!');
  StarBurn_CdvdBurnerGrabber_Cancel(l__PVOID__CdvdBurnerGrabber);
  OutputDebugString('CancelThread() : EXITing');
End;

Begin
{    Main application entry called by OS loader   }


    l__ULONG__Status := ERROR_GEN_FAILURE;
    l__ULONG__BufferSizeInUCHARs := 0;
    l__PVOID__CdvdBurnerGrabber := NIL;

    l__BOOLEAN__IsTrackAtOnce := FALSE;

    l__BOOLEAN__IsSessionAtOnce := FALSE;

    l__BOOLEAN__IsDiscAtOncePQ := FALSE;

    l__BOOLEAN__IsDiscAtOnceRawPW := FALSE;

    l__BOOLEAN__IsTestWrite := TRUE; // Assume test write by default

    WriteLn('SessionAtOnceFromFile: ENTERed for ',ParamCount,' argument(s)');

    //
    // Check are there enough input parameters
    //
    If ParamCount < 4 Then Begin

        WriteLn( 'SessionAtOnceFromFile: EXITing with failure!!!' );

        WriteLn( 'SessionAtOnceFromFile: SCSI address' );

        WriteLn( 'SessionAtOnceFromFile: Example: SessionAtOnceFromFile.exe 0 0 1 0' );
        //
        // Return invalid status
        //
        Halt(ERROR_INVALID_PARAMETER);
    End;


    ZeroMemory(
        @l__CHAR__ExceptionText[1],
        sizeof( l__CHAR__ExceptionText )
        );


    WriteLn(
      Format(
        'SessionAtOnceFromFile: %d MBs of cache will be used during burn process',
        [
        CACHE_SIZE_IN_MBS
        ])
      );

    WriteLn(Format(
        'SessionAtOnceFromFile: Probing SCSI address %d:%d:%d:%d for CD/DVD burner device... ',
        [
        SafeStrToInt(ParamStr( 1 )),
        SafeStrToInt(ParamStr( 2 )),
        SafeStrToInt(ParamStr( 3 )),
        SafeStrToInt(ParamStr( 4 ))
        ])
        );

    //
    // Start processing cleanup
    //
    Try
      //
      // Try to initialize StarBurn
      //
      l__EXCEPTION_NUMBER := StarBurn_UpStart();

        //
        // Check for success
        //
        if l__EXCEPTION_NUMBER <> EN_SUCCESS then
      begin
            WriteLn(
            Format(
                   'SessionAtOnceFromFile: StarBurn_UpStart() failed, exception %ld',
               [
                      Integer( l__EXCEPTION_NUMBER )
               ]
               )
                );

            //
            // Get out of here
            //
            Raise Exception.Create('Error');
        end;

        //
        // Try to construct CD/DVD burner, passing 0 as cache size will make the toolkit allocate default amount of
        // cache memory
        //
        l__EXCEPTION_NUMBER :=
            StarBurn_CdvdBurnerGrabber_Create(
                l__PVOID__CdvdBurnerGrabber,
                PCHAR( @l__CHAR__ExceptionText[1] ),
                sizeof( l__CHAR__ExceptionText ),
                l__ULONG__Status,
                @l__CDB_FAILURE_INFORMATION,
                @SamplesCallback,
                NIL,
                SafeStrToInt(ParamStr( 1 )),
                SafeStrToInt(ParamStr( 2 )),
                SafeStrToInt(ParamStr( 3 )),
                SafeStrToInt(ParamStr( 4 )),
                0 // = DEFAULT_CACHE_SIZE_IN_MBS
                );

        //
        // Check for success
        //
        If l__EXCEPTION_NUMBER <> EN_SUCCESS Then Begin

            WriteLn(
                Format(
                'SessionAtOnceFromFile: StarBurn_CdvdBurnerGrabber_Create() failed, exception %d, status %d, text "%s"',
                [
                Integer(l__EXCEPTION_NUMBER),
                l__ULONG__Status,
                PAnsiChar(@l__CHAR__ExceptionText[1])
                ]
                )
                );

            //
            // Get out of here
            //
            Raise Exception.Create('Error');
        End;

        //
        // Prepare data buffers
        //
        ZeroMemory(
            PAnsiChar(@l__CHAR__VendorID[1]),
            sizeof( l__CHAR__VendorID )
            );

        ZeroMemory(
            PAnsiChar(@l__CHAR__ProductID[1]),
            sizeof( l__CHAR__ProductID )
            );     

        ZeroMemory(
            PAnsiChar(@l__CHAR__ProductRevisionLevel[1]),
            sizeof( l__CHAR__ProductRevisionLevel )
            );     

        //
        // Try to get CD/DVD burner information
        //
        StarBurn_CdvdBurnerGrabber_GetDeviceInformation(
            l__PVOID__CdvdBurnerGrabber,
            PCHAR( @l__CHAR__VendorID[1] ),
            PCHAR( @l__CHAR__ProductID[1] ),
            PCHAR( @l__CHAR__ProductRevisionLevel[1] ),
            l__ULONG__BufferSizeInUCHARs
            );

        WriteLn('Ok!');

        WriteLn(
            Format(
            'SessionAtOnceFromFile: Found CD/DVD device "%s" - "%s" - "%s" with %d UCHARs of cache',
            [
            PCHAR( @l__CHAR__VendorID[1]),
            PCHAR( @l__CHAR__ProductID[1]),
            PCHAR( @l__CHAR__ProductRevisionLevel[1]),
            l__ULONG__BufferSizeInUCHARs
            ])
            );

        WriteLn( 'SessionAtOnceFromFile: Probing supported write modes... ' );

        //
        // Try to probe supported write modes
        //
        l__EXCEPTION_NUMBER :=
            StarBurn_CdvdBurnerGrabber_ProbeSupportedWriteModes(
                l__PVOID__CdvdBurnerGrabber,
                PCHAR ( @l__CHAR__ExceptionText[1] ),
                sizeof( l__CHAR__ExceptionText ),
                l__ULONG__Status,
                @l__CDB_FAILURE_INFORMATION,
                l__BOOLEAN__IsTrackAtOnce,
                l__BOOLEAN__IsSessionAtOnce,
                l__BOOLEAN__IsDiscAtOncePQ,
                l__BOOLEAN__IsDiscAtOnceRawPW
                );

        //
        // Check for success
        //
        If l__EXCEPTION_NUMBER <> EN_SUCCESS Then Begin

            WriteLn(Format(
                'SessionAtOnceFromFile: StarBurn_CdvdBurnerGrabber_ProbeSupportedWriteModes() failed, exception %d, status %d, text "%s"',
                [
                Integer(l__EXCEPTION_NUMBER),
                l__ULONG__Status,
                PAnsiChar(@l__CHAR__ExceptionText[1])
                ])
                );

            //
            // Get out of here
            //
            Raise Exception.Create('Error');
        End;

        WriteLn('OK!');

        WriteLn(
          Format(
            'SessionAtOnceFromFile: Track-At-Once: %s, Session-At-Once: %s, Disc-At-Once PQ: %s, Disc-At-Once raw P-W: %s',
            [
            YesNo(l__BOOLEAN__IsTrackAtOnce),
            YesNo(l__BOOLEAN__IsSessionAtOnce),
            YesNo(l__BOOLEAN__IsDiscAtOncePQ),
            YesNo(l__BOOLEAN__IsDiscAtOnceRawPW)
            ])
            );

        //
        // Check do we have Session-At-Once supported
        //
        If l__BOOLEAN__IsSessionAtOnce = FALSE
        Then Begin

            WriteLn( 'SessionAtOnceFromFile: Session-At-Once is unsupported!!!' );

            //
            // Get out of here
            //
            Raise Exception.Create('Error');
        End;


        WriteLn( 'SessionAtOnceFromFile: Testing unit ready... ' );

        //
        // Try to test unit ready
        //
        l__EXCEPTION_NUMBER :=
            StarBurn_CdvdBurnerGrabber_TestUnitReady(
                l__PVOID__CdvdBurnerGrabber,
                PCHAR ( @l__CHAR__ExceptionText[1] ),
                sizeof( l__CHAR__ExceptionText ),
                l__ULONG__Status,
                @l__CDB_FAILURE_INFORMATION
                );

        //
        // Check for success
        //
        If l__EXCEPTION_NUMBER <> EN_SUCCESS Then Begin

            WriteLn(
              Format(
                'SessionAtOnceFromFile: StarBurn_CdvdBurnerGrabber_TestUnitReady() failed, exception %d, status %d, text "%s"',
                [
                Integer(l__EXCEPTION_NUMBER),
                l__ULONG__Status,
                PAnsiChar(@l__CHAR__ExceptionText[1])
                ])
              );

            //
            // Get out of here
            //
            Raise Exception.Create('Error');
        End;

        WriteLn( 'Ok!' );

        WriteLn( 'SessionAtOnceFromFile: Getting BUP (Buffer Underrun Protection) support... ' );

        //
        // Try to get BUP here
        //
        l__EXCEPTION_NUMBER :=
            StarBurn_CdvdBurnerGrabber_GetBUP(
                l__PVOID__CdvdBurnerGrabber,
                PCHAR ( @l__CHAR__ExceptionText[1] ),
                sizeof( l__CHAR__ExceptionText ),
                l__ULONG__Status,
                @l__CDB_FAILURE_INFORMATION,
                l__BOOLEAN__IsBUPEnabled,
                l__BOOLEAN__IsBUPSupported
                );

        //
        // Check for success
        //
        If l__EXCEPTION_NUMBER <> EN_SUCCESS Then Begin

            WriteLn(
              Format(
                'SessionAtOnceFromFile: StarBurn_CdvdBurnerGrabber_GetBUP() failed, exception %d, status %d, text "%s"',
                [
                Integer(l__EXCEPTION_NUMBER),
                l__ULONG__Status,
                PAnsiChar(@l__CHAR__ExceptionText[1])
                ])
              );

            //
            // Get out of here
            //
            Raise Exception.Create('Error');
        End;

        WriteLn('Ok!');
        WriteLn(
          Format(
            'SessionAtOnceFromFile: BUP (Buffer Underrun Protection) Enabled: %s, Supported: %s',
            [
            YesNo(l__BOOLEAN__IsBUPEnabled),
            YesNo(l__BOOLEAN__IsBUPSupported)
            ])
            );

        //
        // Check if the BUP supported try to enable it
        //
        If l__BOOLEAN__IsBUPSupported = TRUE Then Begin

            WriteLn( 'SessionAtOnceFromFile: Enabling BUP (Buffer Underrun Protection)... ' );

            //
            // Try to set BUP status
            //
            l__EXCEPTION_NUMBER :=
                StarBurn_CdvdBurnerGrabber_SetBUP(
                    l__PVOID__CdvdBurnerGrabber,
                    PCHAR ( @l__CHAR__ExceptionText[1] ),
                    sizeof( l__CHAR__ExceptionText ),
                    l__ULONG__Status,
                    @l__CDB_FAILURE_INFORMATION,
                    TRUE
                    );

            //
            // Check for success
            //
            If l__EXCEPTION_NUMBER <> EN_SUCCESS Then Begin

                WriteLn(Format(
                    'SessionAtOnceFromFile: StarBurn_CdvdBurnerGrabber_SetBUP() failed, exception %d, status %d, text "%s"',
                    [
                    Integer(l__EXCEPTION_NUMBER),
                    l__ULONG__Status,
                    PAnsiChar(@l__CHAR__ExceptionText[1])
                    ])
                  );

                //
                // Get out of here
                //
                Raise Exception.Create('Error');

            End;

            WriteLn( 'OK!' );
        End;

        WriteLn( 'SessionAtOnceFromFile: Setting maximum supported CD/DVD speeds... ' );

        //
        // Try to set maximum supported CD/DVD speeds here
        //
        l__EXCEPTION_NUMBER :=
            StarBurn_CdvdBurnerGrabber_SetSpeeds(
                l__PVOID__CdvdBurnerGrabber,
                PCHAR ( @l__CHAR__ExceptionText[1] ),
                sizeof( l__CHAR__ExceptionText ),
                l__ULONG__Status,
                @l__CDB_FAILURE_INFORMATION,
                CDVD_SPEED_IS_KBPS_MAXIMUM,
                CDVD_SPEED_IS_KBPS_MAXIMUM
                );

        //
        // Check for success
        //
        If l__EXCEPTION_NUMBER <> EN_SUCCESS Then Begin

            WriteLn(
                Format(
                'SessionAtOnceFromFile: WARNING! StarBurn_CdvdBurnerGrabber_SetSpeeds() failed, exception %d, status %d, text "%s"',
                [
                Integer(l__EXCEPTION_NUMBER),
                l__ULONG__Status,
                PAnsiChar(@l__CHAR__ExceptionText[1])
                ])
                );

            //
            // Get out of here
            //
            //Raise Exception.Create('Error');
        End;

         WriteLn( 'Ok!');
        WriteLn( 'SessionAtOnceFromFile: Getting current CD/DVD speeds... ' );

        //
        // Try to get current read/write speeds to show what we'll have
        //
        l__EXCEPTION_NUMBER :=
            StarBurn_CdvdBurnerGrabber_GetSpeeds(
                l__PVOID__CdvdBurnerGrabber,
                PCHAR( @l__CHAR__ExceptionText[1] ),
                sizeof( l__CHAR__ExceptionText ),
                l__ULONG__Status,
                @l__CDB_FAILURE_INFORMATION,
                l__ULONG__CurrentReadSpeed,
                l__ULONG__MaximumReadSpeed,
                l__ULONG__CurrentWriteSpeed,
                l__ULONG__MaximumWriteSpeed
                );

        //
        // Check for success
        //
        If l__EXCEPTION_NUMBER <> EN_SUCCESS Then Begin

            WriteLn(
                Format(
                'SessionAtOnceFromFile: StarBurn_CdvdBurnerGrabber_GetSpeeds() failed, exception %d, status %d, text "%s"',
                [
                Integer(l__EXCEPTION_NUMBER),
                l__ULONG__Status,
                PChar(@l__CHAR__ExceptionText[1])
                ])
                );

            //
            // Get out of here
            //
            Raise Exception.Create('Error');
        End;
        WriteLn('Ok!');
        WriteLn(
            Format(
            'SessionAtOnceFromFile: Current read speed %d KBps (%d maximum)',
            [
            l__ULONG__CurrentReadSpeed,
            l__ULONG__MaximumReadSpeed
            ])
            );

        WriteLn(
            Format(
            'SessionAtOnceFromFile: Current write speed %d KBps (%d maximum)',
            [
            l__ULONG__CurrentWriteSpeed,
            l__ULONG__MaximumWriteSpeed
            ])
            );

        WriteLn( 'SessionAtOnceFromFile: Getting track information... ' );

        //
        // Try to read track information
        //
        l__EXCEPTION_NUMBER :=
            StarBurn_CdvdBurnerGrabber_GetTrackInformation(
                l__PVOID__CdvdBurnerGrabber,
                PCHAR( @l__CHAR__ExceptionText[1] ),
                sizeof( l__CHAR__ExceptionText ),
                l__ULONG__Status,
                @l__CDB_FAILURE_INFORMATION,
                TRACK_NUMBER_INVISIBLE,
                @l__TRACK_INFORMATION
                );

        //
        // Check for success
        //
        If l__EXCEPTION_NUMBER <> EN_SUCCESS Then Begin

            WriteLn(Format(
                'SessionAtOnceFromFile: StarBurn_CdvdBurnerGrabber_GetTrackInformation() failed, exception %d, status %d, text "%s"',
                [
                Integer(l__EXCEPTION_NUMBER),
                l__ULONG__Status,
                PChar(@l__CHAR__ExceptionText[1])
                ])
                );

            //
            // Get out of here
            //
            Raise Exception.Create('Error');
        End;
        WriteLn('Ok!');

        WriteLn(
          Format(
            'SessionAtOnceFromFile: Track Blank: %s, NWA valid: %s, free LBs %d, NWA %d, track number %d',
            [
            YesNo(l__TRACK_INFORMATION.m__BOOLEAN__IsBlank),
            YesNo(l__TRACK_INFORMATION.m__BOOLEAN__IsNextWritableAddressValid),
            l__TRACK_INFORMATION.m__LONG__FreeLBs,
            l__TRACK_INFORMATION.m__LONG__NextWritableAddress,
            l__TRACK_INFORMATION.m__UCHAR__TrackNumber
            ]
            )
          );

        WriteLn( 'SessionAtOnceFromFile: Getting disc information... ' );

        //
        // Try to read disc information
        //
        l__EXCEPTION_NUMBER :=
            StarBurn_CdvdBurnerGrabber_GetDiscInformation(
                l__PVOID__CdvdBurnerGrabber,
                PCHAR( @l__CHAR__ExceptionText[1] ),
                sizeof( l__CHAR__ExceptionText ),
                l__ULONG__Status,
                @l__CDB_FAILURE_INFORMATION,
                @l__DISC_INFORMATION
                );

        //
        // Check for success
        //
        If l__EXCEPTION_NUMBER <> EN_SUCCESS Then Begin

            WriteLn(
                Format(
                'SessionAtOnceFromFile: StarBurn_CdvdBurnerGrabber_GetDiscInformation() failed, exception %d, status %d, text "%s"',
                [
                Integer(l__EXCEPTION_NUMBER),
                l__ULONG__Status,
                PChar(@l__CHAR__ExceptionText[1])
                ])
                );

            //
            // Get out of here
            //
            Raise Exception.Create('Error');
        End;

        //
        // Try to get disc type
        //
        l__DISC_TYPE := StarBurn_CdvdBurnerGrabber_GetInsertedDiscType( l__PVOID__CdvdBurnerGrabber );

        If l__DISC_INFORMATION.m__BOOLEAN__IsErasable Then
          l__String := 'Yes'
        Else
          l__String := 'No';

        WriteLn('Ok!');
        WriteLn(
            Format(
            'SessionAtOnceFromFile: Disc erasable: %s, Disc status: 0x%02X, Last session status: 0x%02X, Disc type: %d',
            [
            l__String,
            l__DISC_INFORMATION.m__UCHAR__DiscStatus,
            l__DISC_INFORMATION.m__UCHAR__LastSessionStatus,
            DWORD( l__DISC_TYPE )
            ])
            );

        //
        // Check is this test burn, if yes we do not need to send OPC as some recorders do not like sending OPC in
        // simulation mode
        //
        If l__BOOLEAN__IsTestWrite = FALSE Then Begin

            WriteLn( 'SessionAtOnceFromFile: Sending OPC (Optimum Power Calibration)... ' );

            //
            // Set flag OPC was successful, it will be reset in case of exception
            //
            l__BOOLEAN__IsSendOPCSuccessful := TRUE;
                                                                                         
            //
            // Try to send OPC
            //
            l__EXCEPTION_NUMBER :=
                StarBurn_CdvdBurnerGrabber_SendOPC(
                    l__PVOID__CdvdBurnerGrabber,
                    PCHAR( @l__CHAR__ExceptionText[1] ),
                    sizeof( l__CHAR__ExceptionText ),
                    l__ULONG__Status,
                    @l__CDB_FAILURE_INFORMATION
                    );

            //
            // Check for success
            //
            If l__EXCEPTION_NUMBER <> EN_SUCCESS Then Begin

                WriteLn( 'Failed!' );

                //
                // Reset the flag OPC was successful
                //
                l__BOOLEAN__IsSendOPCSuccessful := FALSE;

                (*

                WriteLn(Format(
                    'SessionAtOnceFromFile: WARNING! StarBurn_CdvdBurnerGrabber_SendOPC() failed, exception %d, status %d, text "%s"',
                    [
                    Integer(l__EXCEPTION_NUMBER),
                    l__ULONG__Status,
                    PChar(@l__CHAR__ExceptionText[1])
                    ])
                    );

                *)

                //
                // Do not leave as failing to send OPC is not critical error
                //

                //
                // Get out of here
                //
                //__leave;
            End;

            //
            // Check was OPC successful
            //
            If l__BOOLEAN__IsSendOPCSuccessful = TRUE Then Begin

                WriteLn('OK!');

            End;

            WriteLn('SessionAtOnceFromFile: Writing the stuff to the CD/DVD disc >>>' );
        End
        Else Begin

            WriteLn( 'SessionAtOnceFromFile: Skipping send OPC (Optimum Power Calibration) in test mode... OK!' );

            WriteLn( 'SessionAtOnceFromFile: Writing the stuff (simulating) to the CD/DVD disc >>>' );
        End;

        CreateThread(NIL,0,@CancelThread,NIL,0,dwThreadId);

        //
        // Reset last written percent to zero
        //
        g__LARGE_INTEGER__LastWrittenPercent.QuadPart := 0;

        //
        // Prepare disc layout
        //
        ZeroMemory(
            @l__DISC_LAYOUT,
            sizeof( l__DISC_LAYOUT )
            );


        l__String := 'c:\audio\1.wav';
        //
        // Copy current command line entry
        //
        CopyMemory(
            @l__DISC_LAYOUT.m__DISC_LAYOUT_ENTRY[ 1 ].m__CHAR__TrackName[1],
            PChar(l__String),
            Length(l__String),
            );

        l__String := 'c:\audio\2.wav';
        //
        // Copy current command line entry
        //
        CopyMemory(
            @l__DISC_LAYOUT.m__DISC_LAYOUT_ENTRY[ 2 ].m__CHAR__TrackName[1],
            PChar(l__String),
            Length(l__String),
            );

        l__String := 'c:\audio\3.wav';
        //
        // Copy current command line entry
        //
        CopyMemory(
            @l__DISC_LAYOUT.m__DISC_LAYOUT_ENTRY[ 3 ].m__CHAR__TrackName[1],
            PChar(l__String),
            Length(l__String),
            );

        //
        // Update number of tracks
        //
        l__DISC_LAYOUT.m__LONG__NumberOfEntries := 3;

        //
        // Try to write the ISO/sound image to the disc as CDROM XA (MODE2 Form1) CDDA (CD digital audio)
        //
        l__EXCEPTION_NUMBER :=
            StarBurn_CdvdBurnerGrabber_SessionAtOnce(
                    l__PVOID__CdvdBurnerGrabber,
                    PCHAR( @l__CHAR__ExceptionText[1] ),
                    sizeof( l__CHAR__ExceptionText ),
                    l__ULONG__Status,
                    @l__CDB_FAILURE_INFORMATION,
                    @l__DISC_LAYOUT,
                    FALSE, // TRUE -- MODE2/Form1 vs FALSE -- MODE1, would be IGNORED for RAW images
                    l__BOOLEAN__IsTestWrite,
                    TRUE, // Next session allowed
                    WRITE_REPORT_DELAY_IN_SECONDS,
                    BUFFER_STATUS_REPORT_DELAY_IN_SECONDS
                    );
        //
        // Check for success
        //
        If l__EXCEPTION_NUMBER <> EN_SUCCESS Then Begin
       
            WriteLn(
                Format(
                'SessionAtOnceFromFile: StarBurn_CdvdBurnerGrabber_SessionAtOnce() failed, exception %d, status %d, text "%s"',
                [
                Integer(l__EXCEPTION_NUMBER),
                l__ULONG__Status,
                PChar(@l__CHAR__ExceptionText[1])
                ])
                );

            //
            // Get out of here
            //
            Raise Exception.Create('Error');
        End;

        WriteLn( 'SessionAtOnceFromFile: Ejecting the disc... ' );

        //
        // Try to eject the disc
        //
        l__EXCEPTION_NUMBER :=
            StarBurn_CdvdBurnerGrabber_Eject(
                l__PVOID__CdvdBurnerGrabber,
                PCHAR( @l__CHAR__ExceptionText[1] ),
                sizeof( l__CHAR__ExceptionText ),
                l__ULONG__Status,
                @l__CDB_FAILURE_INFORMATION
                );

        //
        // Check for success
        //
        If l__EXCEPTION_NUMBER <> EN_SUCCESS Then Begin

            WriteLn(
                Format(
                'SessionAtOnceFromFile: StarBurn_CdvdBurnerGrabber_Eject() failed, exception %d, status %d, text "%s"',
                [
                Integer(l__EXCEPTION_NUMBER),
                l__ULONG__Status,
                PChar(@l__CHAR__ExceptionText[1])
                ])
                );

            //
            // Get out of here
            //
            Raise Exception.Create('Error');
        End;

        //
        // Set status to good one
        //
        l__ULONG__Status := ERROR_SUCCESS;

        WriteLn( 'OK!' );

    Except

    End;
    //
    // Check was CdvdBurnerGrabber allocated
    //
    If l__PVOID__CdvdBurnerGrabber <> NIL Then
        //
        // Free allocated memory
        //
        StarBurn_Destroy( l__PVOID__CdvdBurnerGrabber );

   //
   // Uninitalize StarBurn, do not care about execution status
   //
   StarBurn_DownShut();

    If l__ULONG__Status = ERROR_SUCCESS Then
        WriteLn( 'SessionAtOnceFromFile: EXITing with success' )
    Else
        WriteLn( 'SessionAtOnceFromFile: EXITing with failure, Status = ', l__ULONG__Status);

    //
    // Return execution status
    //
    Halt(l__ULONG__Status);

End.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 18 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group