DVDPrepareDisk
DVDPrepareDiskAsync

Syntax

#include <revolution/dvd.h>
typedef void (*DVDCBCallback)(s32 result, DVDCommandBlock* block);
s32 DVDPrepareDisk(DVDCommandBlock* block, DVDDiskID* id);
BOOL DVDPrepareDiskAsync(DVDCommandBlock* block, DVDDiskID* id,
                        DVDCBCallback callback);

Arguments

block Command block of this command.
id Pointer to disc ID.
callback Callback function that notifies of completion (DVDPrepareDiskAsync only).

Return Values

DVDPrepareDisk: Returns 0 if the command completes normally; returns a negative value otherwise.

DVDPrepareDiskAsync: Returns TRUE if the command terminates normally; returns FALSE otherwise.

Description

The DVDPrepareDiskAsync function waits for the game player to insert the game disc with the disc ID specified by id.

After the read finishes, the function specified by callback is called (unless NULL is specified). When the game disc is successfully changed, zero is returned as the result argument (the first argument) of the callback function. If a fatal error occurs, DVD_RESULT_FATAL_ERROR is returned. If the function is canceled, DVD_RESULT_CANCELED is returned. DVD_RESULT_FATAL_ERROR and DVD_RESULT_CANCELED are both negative values. The second argument, callback, is the DVDCommandBlock structure, which is the same structure given when the DVDCheckDiskAsync function has been called.

After calling the DVDPrepareDiskAsync function, there are two ways to determine whether the game disc exchange process has completed. One way is to check whether the callback function has been called. The other way is to poll with the DVDGetDriveStatus function and wait until the DVDGetDriveStatus function returns DVD_STATE_END.

The DVDPrepareDisk function is the synchronous version of the DVDPrepareDiskAsync function.

Caution: Be careful with the use of synchronous functions in a real game program. Use synchronous functions if the game program is multithreaded. In single-threaded games, synchronous functions cannot be used because there is no method for error checking.

See Also

DVDGenerateDiskID

Revision History

2007/04/20 Initial version.


CONFIDENTIAL