cdrom: set optimal read speed

This commit is contained in:
Brad Parker 2019-06-29 20:03:59 -04:00
parent e901f3d523
commit 9617605371
6 changed files with 30 additions and 0 deletions

View File

@ -438,6 +438,15 @@ static int cdrom_read_track_info(libretro_vfs_implementation_file *stream, unsig
return 0;
}
int cdrom_set_read_speed(libretro_vfs_implementation_file *stream, unsigned speed)
{
unsigned new_speed = swap_if_big32(speed);
/* MMC Command: SET CD SPEED */
unsigned char cmd[] = {0xBB, 0, (new_speed >> 24) & 0xFF, (new_speed >> 16) & 0xFF, (new_speed >> 8) & 0xFF, new_speed & 0xFF, 0, 0, 0, 0, 0, 0 };
return cdrom_send_command(stream, DIRECTION_NONE, NULL, 0, cmd, sizeof(cmd), 0);
}
int cdrom_write_cue(libretro_vfs_implementation_file *stream, char **out_buf, size_t *out_len, char cdrom_drive, unsigned char *num_tracks, cdrom_toc_t *toc)
{
unsigned char buf[2352] = {0};
@ -456,6 +465,8 @@ int cdrom_write_cue(libretro_vfs_implementation_file *stream, char **out_buf, si
return 1;
}
cdrom_set_read_speed(stream, 0xFFFFFFFF);
rv = cdrom_read_subq(stream, buf, sizeof(buf));
if (rv)

View File

@ -76,6 +76,8 @@ int cdrom_get_inquiry(libretro_vfs_implementation_file *stream, char *model, int
int cdrom_read(libretro_vfs_implementation_file *stream, unsigned char min, unsigned char sec, unsigned char frame, void *s, size_t len, size_t skip);
int cdrom_set_read_speed(libretro_vfs_implementation_file *stream, unsigned speed);
RETRO_END_DECLS
#endif

View File

@ -36,6 +36,7 @@
#include <boolean.h>
#include <stdarg.h>
#include <vfs/vfs_implementation.h>
#define FILESTREAM_REQUIRED_VFS_VERSION 2
@ -106,6 +107,8 @@ bool filestream_exists(const char *path);
char *filestream_getline(RFILE *stream);
const libretro_vfs_implementation_file* filestream_get_vfs_handle(RFILE *stream);
RETRO_END_DECLS
#endif

View File

@ -27,6 +27,8 @@
RETRO_BEGIN_DECLS
typedef struct RFILE RFILE;
typedef struct
{
char *cue_buf;
@ -62,6 +64,8 @@ int retro_vfs_file_error_cdrom(libretro_vfs_implementation_file *stream);
const cdrom_toc_t* retro_vfs_file_get_cdrom_toc(void);
const vfs_cdrom_t* retro_vfs_file_get_cdrom_position(const libretro_vfs_implementation_file *stream);
RETRO_END_DECLS
#endif

View File

@ -609,3 +609,8 @@ char *filestream_getline(RFILE *stream)
newline[idx] = '\0';
return newline;
}
const libretro_vfs_implementation_file* filestream_get_vfs_handle(RFILE *stream)
{
return (const libretro_vfs_implementation_file*)stream->hfile;
}

View File

@ -440,3 +440,8 @@ int retro_vfs_file_error_cdrom(libretro_vfs_implementation_file *stream)
{
return 0;
}
const vfs_cdrom_t* retro_vfs_file_get_cdrom_position(const libretro_vfs_implementation_file *stream)
{
return &stream->cdrom;
}