summaryrefslogtreecommitdiff
path: root/src/cache/handlers
diff options
context:
space:
mode:
authorAndrew Opalach <andrew@akon.city> 2025-11-30 14:32:51 -0500
committerAndrew Opalach <andrew@akon.city> 2025-11-30 14:32:51 -0500
commitc8412bbedae0fce38db96833732e8ce904721e4c (patch)
tree4611046186c714513d042966ce97825df0fecf9e /src/cache/handlers
parent0d6d13425015d78606232874498327cabcb0e4e2 (diff)
downloadcamu-c8412bbedae0fce38db96833732e8ce904721e4c.tar.gz
camu-c8412bbedae0fce38db96833732e8ce904721e4c.tar.bz2
camu-c8412bbedae0fce38db96833732e8ce904721e4c.zip
Build cleanup and fixes from sink testing
Signed-off-by: Andrew Opalach <andrew@akon.city>
Diffstat (limited to 'src/cache/handlers')
-rw-r--r--src/cache/handlers/cdio.c24
1 files changed, 11 insertions, 13 deletions
diff --git a/src/cache/handlers/cdio.c b/src/cache/handlers/cdio.c
index 29126c0..a9e3747 100644
--- a/src/cache/handlers/cdio.c
+++ b/src/cache/handlers/cdio.c
@@ -1,4 +1,5 @@
#define AL_LOG_SECTION "cache_cdio"
+//#define AL_LOG_ENABLE_TRACE
#include <al/log.h>
#include "../../codec/codec.h"
@@ -10,7 +11,7 @@
#include "cdio.h"
-// 1 sector at a time to minimize skips
+// 1 sector at a time to minimize skips.
#define SECTORS_PER_STEP 1
#define BYTES_PER_STEP (SECTORS_PER_STEP * CDIO_CD_FRAMESIZE_RAW)
@@ -18,13 +19,13 @@ static void cdio_log_messages(struct cch_handler_cdio *cdio)
{
char *error_messages = cdio_cddap_errors(cdio->drive);
if (error_messages) {
- log_error("\n%s", error_messages);
+ log_error("%s", error_messages);
cdio_cddap_free_messages(error_messages);
}
char *messages = cdio_cddap_messages(cdio->drive);
if (messages) {
- log_info("\n%s", messages);
+ log_info("%s", messages);
cdio_cddap_free_messages(messages);
}
}
@@ -42,26 +43,21 @@ static nn_thread_result NNWT_THREADCALL cd_read_thread(void *userdata)
for (;;) {
if (!al_atomic_load(s32)(&cdio->running, AL_ATOMIC_RELAXED)) {
- // We don't care about how complete the disc read was.
+ // We don't care about how complete the read was.
return 0;
}
- // cdio_read() here can block for a very long time so we buffer each read
- // before writing it to the backing.
+ // cdio_read() can block for a long time so we buffer each read before writing it to the backing.
long ret = cdio_cddap_read(cdio->drive, nn_buffer_get_ptr(&cdio->buffer, 0), cdio->sector, SECTORS_PER_STEP);
cdio_log_messages(cdio);
al_assert(ret <= SECTORS_PER_STEP);
off_t pointer = cdio->sector * CDIO_CD_FRAMESIZE_RAW;
size_t size;
u8 *ptr = cdio->backing->get_ptr(cdio->backing, pointer, &size);
- if (size < BYTES_PER_STEP) {
- log_error("Tried to write over expected size during normal operation.");
- cdio->backing->unlock(cdio->backing);
- break;
- }
+ al_assert(size >= BYTES_PER_STEP);
if (ret == SECTORS_PER_STEP) {
al_memcpy(ptr, nn_buffer_get_ptr(&cdio->buffer, 0), BYTES_PER_STEP);
} else if (ret == -10) {
- log_error("I/O error, skipping sector.");
+ log_error("Disc read error, skipping sector.");
al_memset(ptr, 0, BYTES_PER_STEP);
ret = SECTORS_PER_STEP;
} else if (ret < 0) {
@@ -170,7 +166,8 @@ static bool open_cd_drive(struct cch_handler_cdio *cdio)
lsn_t start = cdio_cddap_disc_firstsector(drive);
lsn_t end = cdio_cddap_disc_lastsector(drive);
- lsn_t offset = start;
+ lsn_t first_track_start = cdio_cddap_track_firstsector(drive, first_track);
+ lsn_t offset = first_track_start;
s32 track = CDIO_INVALID_TRACK;
while (offset < end) {
track = cdio_cddap_sector_gettrack(drive, offset);
@@ -178,6 +175,7 @@ static bool open_cd_drive(struct cch_handler_cdio *cdio)
lsn_t track_start = cdio_cddap_track_firstsector(drive, track);
lsn_t track_end = cdio_cddap_track_lastsector(drive, track);
al_array_push(cdio->handler.entry->chapters, ((struct cch_chapter){ track_start, track_end }));
+ log_trace("Track #%u: %zd-%zd.", track, track_start, track_end);
offset = track_end + 1;
}
// end is a valid index so add one framesize.