| 167 | } |
| 168 | |
| 169 | static void async_cb(s32 result, DVDFileInfo* fileInfo) |
| 170 | { |
| 171 | file_queue_entry* entry = &file_queue[(S32)fileInfo->cb.userData]; |
| 172 | s32 r7 = DVD_RESULT_FATAL_ERROR; |
| 173 | |
| 174 | switch (result) |
| 175 | { |
| 176 | case DVD_RESULT_FATAL_ERROR: |
| 177 | { |
| 178 | xTRCDisk(TRC_DiskFatal); |
| 179 | return; |
| 180 | } |
| 181 | case DVD_RESULT_GOOD: |
| 182 | case DVD_RESULT_IGNORED: |
| 183 | { |
| 184 | if (result >= DVD_RESULT_GOOD) |
| 185 | { |
| 186 | r7 = result; |
| 187 | } |
| 188 | |
| 189 | break; |
| 190 | } |
| 191 | } |
| 192 | |
| 193 | if (r7 < DVD_RESULT_GOOD) |
| 194 | { |
| 195 | entry->stat = IFILE_RDSTAT_FAIL; |
| 196 | |
| 197 | if (entry->callback) |
| 198 | { |
| 199 | entry->callback(entry->file); |
| 200 | } |
| 201 | } |
| 202 | else if (r7 + entry->offset >= entry->size || |
| 203 | r7 + entry->offset + entry->file->ps.offset >= entry->file->ps.fileInfo.length) |
| 204 | { |
| 205 | entry->stat = IFILE_RDSTAT_DONE; |
| 206 | entry->offset = entry->size; |
| 207 | |
| 208 | if (entry->callback) |
| 209 | { |
| 210 | entry->callback(entry->file); |
| 211 | } |
| 212 | |
| 213 | entry->file->ps.asynckey = -1; |
| 214 | } |
| 215 | else |
| 216 | { |
| 217 | entry->offset += r7; |
| 218 | entry->stat = IFILE_RDSTAT_INPROG; |
| 219 | |
| 220 | s32 length; |
| 221 | if ((entry->size - entry->offset < 0x8000)) |
| 222 | { |
| 223 | length = ALIGN(entry->size - entry->offset, 4); |
| 224 | } |
| 225 | else |
| 226 | { |