| Miles Sound System SDK 7.2a |
The function RAD_IOPQueueAsyncReadAtTop queues an asynchronous read to be performed in the background at the highest priority.
S32 RAD_IOPQueueAsyncReadAtTop( RAD_IOP_ASYNC_READ_DATA *read_data ); |
Returns non-zero if the read was scheduled, or zero for failure.
This function schedules a read to be performed in the background. It will run at the highest priority (either immediately or directly after the current read finishes). You can read from a CD, DVD, the host, a hard drive, IOP memory, or SPU memory. You can read into EE, IOP or SPU destination memory addresses.
You set the file_handle, offset, bytes_to_read, dest, callback, and optionally the group fields in the read_data structure before calling this function. RAD_IOP will then instruct the IOP to perform the read in the background. When the read is complete, the status will be updated, and then the callback made (if you set one).
If you don't have a callback set, then you can spin on the status field and wait for it to go greater than or equal to RAD_IOP_STATUS_COMPLETE. You then query the status for RAD_IOP_STATUS_DONE to determine if the read succeeded.
If the callback is set, then it is called whether the read succeeded or failed, so check the status field in your callback. The callback is made at interrupt time, so be sure that your callback code is interrupt safe.
If the status returns as RAD_IOP_STATUS_ERROR, then you can call the RAD_IOPGetIOStatus function to query for the error code (which will be the result of sceCdRead for CD or DVD files, or the result of the C runtime read functions for other devices).
The read_data structure must remain valid until the read completes or you cancel the read with one of the CancelAsync functions.
You can do your own reads with this function while Bink or Miles is playing to load data in the background while a movie is playing. Load in nice big chunks so that the CD does the minimum amount of seeking back and forth. A good amount to read at one time is a value of one third of your data rate.
You can also do your own reading while we are streaming as long as you do a sceCdSync before each CD read to obtain access to the CD device.
You can also use this function to copy from IOP or SPU memory to IOP, SPU, or EE memory. Just create a file handle for the IOP or SPU memory address using RAD_IOPGetFileHandleToIOPMemory or RAD_IOPGetFileHandleToSPUMemory, and then use this function with the dest_type field set to the appropriate destination type. For example, to copy from IOP address 0x4500 to SPU address 0x17000, you could do:
RAD_IOP_ASYNC_READ_DATA read={0};
read.file_handle = RAD_IOPGetFileHandleToIOPMemory( 0x4500 );
read.offset = 0;
read.bytes_to_read = 32768;
read.dest = 0x17000;
read.dest_type = RAD_IOP_SPU_ADDRESS;
RAD_IOPQueueAsyncReadAtTop( &read ); // starts the copy
Group:
The RAD_IOP API for the Sony PS2
Related Sections:
Memory management under PlayStation 2
Related Functions:
RAD_IOPGetFileHandleToIOPMemory, RAD_IOPGetFileHandleToLSN, RAD_IOPGetFileHandleToSPUMemory, RAD_IOPGetIOStatus, RAD_IOPQueueAsyncOpenFile, RAD_IOPQueueAsyncReadAtBottom, RAD_IOP_READCALLBACK
Related Basic Types:
RAD_IOP_STATUS_VALUES, S32
Related Structures:
RAD_IOP_ASYNC_READ_DATA
Related FAQs:
On the Sony PS2, how can I use the IOP or SPU memory to hold my audio?
For technical support, e-mail Miles3@radgametools.com
© Copyright 1991-2007 RAD Game Tools, Inc. All Rights Reserved.