mirror of
https://github.com/libretro/libretro-common.git
synced 2024-11-24 00:29:50 +00:00
Updates
This commit is contained in:
parent
242759eb92
commit
fa7f0906c7
@ -20,7 +20,10 @@
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <audio/audio_mix.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <memalign.h>
|
||||
|
||||
#if defined(__SSE2__)
|
||||
#include <emmintrin.h>
|
||||
@ -28,10 +31,6 @@
|
||||
#include <altivec.h>
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <memalign.h>
|
||||
#include <retro_miscellaneous.h>
|
||||
#include <audio/audio_mix.h>
|
||||
#include <streams/file_stream.h>
|
||||
|
@ -58,6 +58,30 @@ static void cdfs_determine_sector_size(cdfs_track_t* track)
|
||||
track->stream_sector_size = 2352;
|
||||
track->stream_sector_header_size = 16;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* attempt to determine stream_sector_size from file size */
|
||||
size_t size = intfstream_get_size(track->stream);
|
||||
|
||||
if ((size % 2352) == 0)
|
||||
{
|
||||
/* raw tracks use all 2352 bytes and have a 24 byte header */
|
||||
track->stream_sector_size = 2352;
|
||||
track->stream_sector_header_size = 24;
|
||||
}
|
||||
else if ((size % 2048) == 0)
|
||||
{
|
||||
/* cooked tracks eliminate all header/footer data */
|
||||
track->stream_sector_size = 2048;
|
||||
track->stream_sector_header_size = 0;
|
||||
}
|
||||
else if ((size % 2336) == 0)
|
||||
{
|
||||
/* MODE 2 format without 16-byte sync data */
|
||||
track->stream_sector_size = 2336;
|
||||
track->stream_sector_header_size = 8;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -418,7 +442,7 @@ static cdfs_track_t* cdfs_open_cue_track(
|
||||
const char *track = line + 5;
|
||||
cdfs_skip_spaces(&track);
|
||||
|
||||
sscanf(track, "%d", &track_number);
|
||||
sscanf(track, "%d", (int*)&track_number);
|
||||
while (*track && *track != ' ' && *track != '\n')
|
||||
++track;
|
||||
|
||||
@ -540,6 +564,10 @@ struct cdfs_track_t* cdfs_open_track(const char* path,
|
||||
return cdfs_open_chd_track(path, track_index);
|
||||
#endif
|
||||
|
||||
/* if opening track 1, try opening as a raw track */
|
||||
if (track_index == 1)
|
||||
return cdfs_open_raw_track(path);
|
||||
|
||||
/* unsupported file type */
|
||||
return NULL;
|
||||
}
|
||||
@ -563,22 +591,39 @@ struct cdfs_track_t* cdfs_open_data_track(const char* path)
|
||||
cdfs_track_t* cdfs_open_raw_track(const char* path)
|
||||
{
|
||||
const char* ext = path_get_extension(path);
|
||||
cdfs_track_t* track = NULL;
|
||||
|
||||
if ( string_is_equal_noncase(ext, "bin") ||
|
||||
string_is_equal_noncase(ext, "iso"))
|
||||
return cdfs_wrap_stream(intfstream_open_file(path,
|
||||
RETRO_VFS_FILE_ACCESS_READ,
|
||||
RETRO_VFS_FILE_ACCESS_HINT_NONE), 0);
|
||||
{
|
||||
intfstream_t* file = intfstream_open_file(path,
|
||||
RETRO_VFS_FILE_ACCESS_READ, RETRO_VFS_FILE_ACCESS_HINT_NONE);
|
||||
|
||||
/* unsupported file type */
|
||||
return NULL;
|
||||
track = cdfs_wrap_stream(file, 0);
|
||||
if (track != NULL && track->stream_sector_size == 0)
|
||||
{
|
||||
cdfs_close_track(track);
|
||||
track = NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* unsupported file type */
|
||||
}
|
||||
|
||||
return track;
|
||||
}
|
||||
|
||||
void cdfs_close_track(cdfs_track_t* track)
|
||||
{
|
||||
if (track)
|
||||
{
|
||||
intfstream_close(track->stream);
|
||||
if (track->stream)
|
||||
{
|
||||
intfstream_close(track->stream);
|
||||
free(track->stream);
|
||||
}
|
||||
|
||||
free(track);
|
||||
}
|
||||
}
|
||||
|
@ -85,8 +85,10 @@ bool media_detect_cd_info_cue(const char *path, media_detect_cd_info_t *info)
|
||||
|
||||
if (!file)
|
||||
{
|
||||
#ifdef MEDIA_CUE_PARSE_DEBUG
|
||||
printf("[MEDIA] Could not open cue path for reading: %s\n", path);
|
||||
fflush(stdout);
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -148,7 +150,7 @@ bool media_detect_cd_info_cue(const char *path, media_detect_cd_info_t *info)
|
||||
if (!string_is_empty(track))
|
||||
{
|
||||
unsigned track_number = 0;
|
||||
sscanf(track, "%d", &track_number);
|
||||
sscanf(track, "%d", (int*)&track_number);
|
||||
#ifdef MEDIA_CUE_PARSE_DEBUG
|
||||
printf("Found track: %d\n", track_number);
|
||||
fflush(stdout);
|
||||
@ -184,7 +186,7 @@ bool media_detect_cd_info_cue(const char *path, media_detect_cd_info_t *info)
|
||||
if (!string_is_empty(index))
|
||||
{
|
||||
unsigned index_number = 0;
|
||||
sscanf(index, "%d", &index_number);
|
||||
sscanf(index, "%d", (int*)&index_number);
|
||||
|
||||
if (index_number == 1)
|
||||
{
|
||||
@ -206,7 +208,7 @@ bool media_detect_cd_info_cue(const char *path, media_detect_cd_info_t *info)
|
||||
|
||||
if (strlen(track_mode) == 10)
|
||||
{
|
||||
sscanf(track_mode, "MODE%d/%d", &track_mode_number, &track_sector_size);
|
||||
sscanf(track_mode, "MODE%d/%d", (int*)&track_mode_number, (int*)&track_sector_size);
|
||||
#ifdef MEDIA_CUE_PARSE_DEBUG
|
||||
printf("Found track mode %d with sector size %d\n", track_mode_number, track_sector_size);
|
||||
fflush(stdout);
|
||||
@ -216,7 +218,7 @@ bool media_detect_cd_info_cue(const char *path, media_detect_cd_info_t *info)
|
||||
unsigned min = 0;
|
||||
unsigned sec = 0;
|
||||
unsigned frame = 0;
|
||||
sscanf(pregap, "%02d:%02d:%02d", &min, &sec, &frame);
|
||||
sscanf(pregap, "%02d:%02d:%02d", (int*)&min, (int*)&sec, (int*)&frame);
|
||||
|
||||
if (min || sec || frame || strstr(pregap, "00:00:00"))
|
||||
{
|
||||
@ -244,18 +246,20 @@ bool media_detect_cd_info_cue(const char *path, media_detect_cd_info_t *info)
|
||||
{
|
||||
if (strstr(track_path, "/") || strstr(track_path, "\\"))
|
||||
{
|
||||
#ifdef MEDIA_CUE_PARSE_DEBUG
|
||||
printf("using path %s\n", track_path);
|
||||
fflush(stdout);
|
||||
#endif
|
||||
return media_detect_cd_info(track_path, data_track_pregap_bytes, info);
|
||||
}
|
||||
else
|
||||
{
|
||||
fill_pathname_basedir(track_abs_path, path, sizeof(track_abs_path));
|
||||
strlcat(track_abs_path, track_path, sizeof(track_abs_path));
|
||||
printf("using abs path %s\n", track_abs_path);
|
||||
fflush(stdout);
|
||||
return media_detect_cd_info(track_abs_path, data_track_pregap_bytes, info);
|
||||
}
|
||||
|
||||
fill_pathname_basedir(track_abs_path, path, sizeof(track_abs_path));
|
||||
strlcat(track_abs_path, track_path, sizeof(track_abs_path));
|
||||
#ifdef MEDIA_CUE_PARSE_DEBUG
|
||||
printf("using abs path %s\n", track_abs_path);
|
||||
fflush(stdout);
|
||||
#endif
|
||||
return media_detect_cd_info(track_abs_path, data_track_pregap_bytes, info);
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -273,8 +277,10 @@ bool media_detect_cd_info(const char *path, uint64_t pregap_bytes, media_detect_
|
||||
|
||||
if (!file)
|
||||
{
|
||||
#ifdef MEDIA_CUE_PARSE_DEBUG
|
||||
printf("[MEDIA] Could not open path for reading: %s\n", path);
|
||||
fflush(stdout);
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -295,8 +301,10 @@ bool media_detect_cd_info(const char *path, uint64_t pregap_bytes, media_detect_
|
||||
|
||||
if (read_bytes != buf_size)
|
||||
{
|
||||
#ifdef MEDIA_CUE_PARSE_DEBUG
|
||||
printf("[MEDIA] Could not read from media: got %" PRId64 " bytes instead of %d.\n", read_bytes, buf_size);
|
||||
fflush(stdout);
|
||||
#endif
|
||||
filestream_close(file);
|
||||
free(buf);
|
||||
return false;
|
||||
|
Loading…
Reference in New Issue
Block a user