summaryrefslogtreecommitdiff
path: root/src/cache/handlers
diff options
context:
space:
mode:
Diffstat (limited to 'src/cache/handlers')
-rw-r--r--src/cache/handlers/cdio.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/cache/handlers/cdio.c b/src/cache/handlers/cdio.c
index b10bbf1..ffaaa62 100644
--- a/src/cache/handlers/cdio.c
+++ b/src/cache/handlers/cdio.c
@@ -14,11 +14,12 @@
static void cdio_log_messages(struct cch_handler_cdio *cdio)
{
char *error_messages = cdio_cddap_errors(cdio->drive);
- char *messages = cdio_cddap_messages(cdio->drive);
if (error_messages) {
al_log_error("cdio", "\n%s", error_messages);
cdio_cddap_free_messages(error_messages);
}
+
+ char *messages = cdio_cddap_messages(cdio->drive);
if (messages) {
al_log_info("cdio", "\n%s", messages);
cdio_cddap_free_messages(messages);
@@ -34,7 +35,8 @@ static bool handler_cdio_can_seek(struct cch_handler *handler)
static nn_thread_result NNWT_THREADCALL cd_read_thread(void *userdata)
{
struct cch_handler_cdio *cdio = (struct cch_handler_cdio *)userdata;
- while (1) {
+
+ for (;;) {
if (!al_atomic_load(s32)(&cdio->running, AL_ATOMIC_RELAXED)) {
// We don't care about how complete the disc read was.
return 0;
@@ -72,11 +74,13 @@ static nn_thread_result NNWT_THREADCALL cd_read_thread(void *userdata)
break;
}
}
+
if (cdio->sector <= cdio->end) {
al_log_warn("cdio", "Disc read cut short (sectors: %zd, end: %zd).", cdio->sector, cdio->end);
// We didn't read the full disc, disable waiters.
cch_threaded_waits_disable_all(&cdio->handler);
}
+
return 0;
}
@@ -148,9 +152,10 @@ static bool open_cd_drive(struct cch_handler_cdio *cdio)
al_log_warn("cdio", "Failed to set drive speed (%d).", ret);
}
- // Not sure what this is based on, but it can seemingly just be wrong.
track_t tracks = cdio_cddap_tracks(drive);
- al_log_info("cdio", "CD with %d tracks loaded.", tracks);
+ track_t first_track = cdio_get_first_track_num(drive->p_cdio);
+ track_t last_track = cdio_get_last_track_num(drive->p_cdio);
+ al_log_info("cdio", "CD with %d tracks loaded (%d-%d).", tracks, first_track, last_track);
al_array_reserve(cdio->handler.entry->chapters, tracks);
lsn_t start = cdio_cddap_disc_firstsector(drive);
@@ -196,7 +201,9 @@ struct cch_entry *cch_handler_cdio_create(void)
entry->handler->free = handler_cdio_free;
entry->handler->entry = entry;
al_str_from(&entry->handler->liana, "cdio");
- if (!open_cd_drive(cdio)) return NULL;
+ if (!open_cd_drive(cdio)) {
+ return NULL;
+ }
al_atomic_store(s32)(&cdio->running, 0, AL_ATOMIC_RELAXED);
nn_buffer_init(&cdio->buffer);
nn_buffer_ensure_space(&cdio->buffer, BYTES_PER_STEP);