don't spam log when loading discs for ui purposes

This commit is contained in:
Anthony Pesch 2017-11-22 09:11:28 -05:00
parent 5ca08dbb4d
commit eb9cb266e5
10 changed files with 46 additions and 34 deletions

View File

@ -154,7 +154,7 @@ static int dc_load_bin(struct dreamcast *dc, const char *path) {
}
static int dc_load_disc(struct dreamcast *dc, const char *path) {
struct disc *disc = disc_create(path);
struct disc *disc = disc_create(path, 1);
if (!disc) {
return 0;

View File

@ -98,7 +98,7 @@ static void cdi_destroy(struct disc *disc) {
}
static int cdi_parse_track(struct disc *disc, uint32_t version,
int *track_offset, int *leadout_fad) {
int *track_offset, int *leadout_fad, int verbose) {
struct cdi *cdi = (struct cdi *)disc;
FILE *fp = cdi->fp;
@ -187,9 +187,11 @@ static int cdi_parse_track(struct disc *disc, uint32_t version,
track->ctrl = sector_mode == 0 ? 0 : 4;
track->file_offset = data_offset - track->fad * track->sector_size;
LOG_INFO("cdi_parse_track track=%d fad=%d off=%d mode=%s/%d", track->num,
track->fad, data_offset, cdi_sector_modes[sector_mode],
track->sector_size);
if (verbose) {
LOG_INFO("cdi_parse_track track=%d fad=%d off=%d mode=%s/%d", track->num,
track->fad, data_offset, cdi_sector_modes[sector_mode],
track->sector_size);
}
*track_offset += total_len * sector_size;
*leadout_fad = track->fad + track_len;
@ -198,7 +200,7 @@ static int cdi_parse_track(struct disc *disc, uint32_t version,
}
static int cdi_parse_session(struct disc *disc, uint32_t version,
int *track_offset) {
int *track_offset, int verbose) {
struct cdi *cdi = (struct cdi *)disc;
FILE *fp = cdi->fp;
@ -217,7 +219,7 @@ static int cdi_parse_session(struct disc *disc, uint32_t version,
int leadout_fad = 0;
while (num_tracks--) {
if (!cdi_parse_track(disc, version, track_offset, &leadout_fad)) {
if (!cdi_parse_track(disc, version, track_offset, &leadout_fad, verbose)) {
return 0;
}
@ -252,7 +254,7 @@ static int cdi_parse_session(struct disc *disc, uint32_t version,
return 1;
}
static int cdi_parse(struct disc *disc, const char *filename) {
static int cdi_parse(struct disc *disc, const char *filename, int verbose) {
struct cdi *cdi = (struct cdi *)disc;
FILE *fp = fopen(filename, "rb");
@ -281,7 +283,9 @@ static int cdi_parse(struct disc *disc, const char *filename) {
int found = 0;
for (int i = 0; i < ARRAY_SIZE(cdi_versions); i++) {
if (version == cdi_versions[i]) {
LOG_INFO("cdi_parse version %s detected", cdi_version_names[i]);
if (verbose) {
LOG_INFO("cdi_parse version %s detected", cdi_version_names[i]);
}
found = 1;
break;
}
@ -308,13 +312,15 @@ static int cdi_parse(struct disc *disc, const char *filename) {
return 0;
}
LOG_INFO("cdi_parse found %d sessions", num_sessions);
if (verbose) {
LOG_INFO("cdi_parse found %d sessions", num_sessions);
}
/* tracks the current track's data offset from the file start */
int track_offset = 0;
while (num_sessions--) {
if (!cdi_parse_session(disc, version, &track_offset)) {
if (!cdi_parse_session(disc, version, &track_offset, verbose)) {
return 0;
}
@ -329,7 +335,7 @@ static int cdi_parse(struct disc *disc, const char *filename) {
return 1;
}
struct disc *cdi_create(const char *filename) {
struct disc *cdi_create(const char *filename, int verbose) {
struct cdi *cdi = calloc(1, sizeof(struct cdi));
cdi->destroy = &cdi_destroy;
@ -343,7 +349,7 @@ struct disc *cdi_create(const char *filename) {
struct disc *disc = (struct disc *)cdi;
if (!cdi_parse(disc, filename)) {
if (!cdi_parse(disc, filename, verbose)) {
cdi_destroy(disc);
return NULL;
}

View File

@ -3,6 +3,6 @@
struct disc;
struct disc *cdi_create(const char *filename);
struct disc *cdi_create(const char *filename, int verbose);
#endif

View File

@ -84,7 +84,7 @@ static void chd_destroy(struct disc *disc) {
chd_close(chd->chd);
}
static int chd_parse(struct disc *disc, const char *filename) {
static int chd_parse(struct disc *disc, const char *filename, int verbose) {
struct chd *chd = (struct chd *)disc;
chd_error err = chd_open(filename, CHD_OPEN_READ, 0, &chd->chd);
@ -182,8 +182,10 @@ static int chd_parse(struct disc *disc, const char *filename) {
track->ctrl = strcmp(type, "AUDIO") == 0 ? 0 : 4;
track->file_offset = fad - cad;
LOG_INFO("chd_parse '%s' track=%d fad=%d secsz=%d", tmp, track->num,
track->fad, track->sector_size);
if (verbose) {
LOG_INFO("chd_parse '%s' track=%d fad=%d secsz=%d", tmp, track->num,
track->fad, track->sector_size);
}
/* chd block addresses are padded to a 4-frame boundary */
cad += ALIGN_UP(frames, 4);
@ -213,7 +215,7 @@ static int chd_parse(struct disc *disc, const char *filename) {
return 1;
}
struct disc *chd_create(const char *filename) {
struct disc *chd_create(const char *filename, int verbose) {
struct chd *chd = calloc(1, sizeof(struct chd));
chd->destroy = &chd_destroy;
@ -227,7 +229,7 @@ struct disc *chd_create(const char *filename) {
struct disc *disc = (struct disc *)chd;
if (!chd_parse(disc, filename)) {
if (!chd_parse(disc, filename, verbose)) {
chd_destroy(disc);
return NULL;
}

View File

@ -3,6 +3,6 @@
struct disc;
struct disc *chd_create(const char *filename);
struct disc *chd_create(const char *filename, int verbose);
#endif

View File

@ -280,15 +280,15 @@ void disc_destroy(struct disc *disc) {
disc->destroy(disc);
}
struct disc *disc_create(const char *filename) {
struct disc *disc_create(const char *filename, int verbose) {
struct disc *disc = NULL;
if (strstr(filename, ".cdi")) {
disc = cdi_create(filename);
disc = cdi_create(filename, verbose);
} else if (strstr(filename, ".chd")) {
disc = chd_create(filename);
disc = chd_create(filename, verbose);
} else if (strstr(filename, ".gdi")) {
disc = gdi_create(filename);
disc = gdi_create(filename, verbose);
}
if (!disc) {
@ -316,7 +316,9 @@ struct disc *disc_create(const char *filename) {
snprintf(disc->uid, sizeof(disc->uid), "%s %s %s %s", disc->prodnme,
disc->prodnum, disc->prodver, disc->discnum);
LOG_INFO("disc_create id=%s", disc->uid);
if (verbose) {
LOG_INFO("disc_create id=%s", disc->uid);
}
return disc;
}

View File

@ -85,7 +85,7 @@ struct disc {
void (*read_sector)(struct disc *, struct track *, int, void *);
};
struct disc *disc_create(const char *filename);
struct disc *disc_create(const char *filename, int verbose);
void disc_destroy(struct disc *disc);
int disc_get_format(struct disc *disc);

View File

@ -93,7 +93,7 @@ static void gdi_destroy(struct disc *disc) {
}
}
static int gdi_parse(struct disc *disc, const char *filename) {
static int gdi_parse(struct disc *disc, const char *filename, int verbose) {
struct gdi *gdi = (struct gdi *)disc;
FILE *fp = fopen(filename, "rb");
@ -162,8 +162,10 @@ static int gdi_parse(struct disc *disc, const char *filename) {
snprintf(track->filename, sizeof(track->filename), "%s" PATH_SEPARATOR "%s",
dirname, filename);
LOG_INFO("gdi_parse track=%d filename='%s' fad=%d secsz=%d", track->num,
track->filename, track->fad, track->sector_size);
if (verbose) {
LOG_INFO("gdi_parse track=%d filename='%s' fad=%d secsz=%d", track->num,
track->filename, track->fad, track->sector_size);
}
}
/* gdroms contains two sessions, one for the single density area (tracks 0-1)
@ -191,7 +193,7 @@ static int gdi_parse(struct disc *disc, const char *filename) {
return 1;
}
struct disc *gdi_create(const char *filename) {
struct disc *gdi_create(const char *filename, int verbose) {
struct gdi *gdi = calloc(1, sizeof(struct gdi));
gdi->destroy = &gdi_destroy;
@ -205,7 +207,7 @@ struct disc *gdi_create(const char *filename) {
struct disc *disc = (struct disc *)gdi;
if (!gdi_parse(disc, filename)) {
if (!gdi_parse(disc, filename, verbose)) {
gdi_destroy(disc);
return NULL;
}

View File

@ -3,6 +3,6 @@
struct disc;
struct disc *gdi_create(const char *filename);
struct disc *gdi_create(const char *filename, int verbose);
#endif

View File

@ -518,7 +518,7 @@ static void ui_scan_games_f(struct ui *ui, const char *filename) {
snprintf(ui->scan_status, sizeof(ui->scan_status), "scanning %s", filename);
if (ui_has_game_ext(filename, game_exts, ARRAY_SIZE(game_exts))) {
struct disc *disc = disc_create(filename);
struct disc *disc = disc_create(filename, 0);
if (disc) {
struct game game = {0};
@ -1099,7 +1099,7 @@ enum {
};
static texture_handle_t ui_load_disc_texture(struct ui *ui, struct game *game) {
struct disc *disc = disc_create(game->filename);
struct disc *disc = disc_create(game->filename, 0);
if (!disc) {
return ui->disc_tex;
}