diff options
Diffstat (limited to 'src/cache')
| -rw-r--r-- | src/cache/handlers/cdio.c | 24 | ||||
| -rw-r--r-- | src/cache/meson.build | 30 |
2 files changed, 25 insertions, 29 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. diff --git a/src/cache/meson.build b/src/cache/meson.build index 1a198eb..61be949 100644 --- a/src/cache/meson.build +++ b/src/cache/meson.build @@ -8,37 +8,35 @@ cache_src = [ cache_deps = [] cache_args = [] -if naunet_has_mmap - cache_src += ['backings/file_mapped.c'] -else - cache_src += ['backings/file.c'] +if 'file' in get_option('sources') + if naunet_has_mmap + cache_src += ['backings/file_mapped.c'] + else + cache_src += ['backings/file.c'] + endif endif -if naunet_has_curl +if 'http' in get_option('sources') and naunet_has_curl cache_src += ['handlers/http.c'] endif -cache_have_cdio = false -if is_linux - libcdio_paranoia = dependency('libcdio_paranoia', required: false, allow_fallback: true) - libcdio_cdda = dependency('libcdio_cdda', required: false, allow_fallback: true) +if 'cdio' in get_option('sources') + libcdio_paranoia = dependency('libcdio_paranoia', allow_fallback: true) + libcdio_cdda = dependency('libcdio_cdda', allow_fallback: true) if libcdio_paranoia.found() and libcdio_cdda.found() cache_src += ['handlers/cdio.c'] cache_deps += [libcdio_paranoia, libcdio_cdda] cache_args += ['-DCACHE_HAVE_CDIO'] - cache_have_cdio = true endif endif -cache_have_libdvd = false -if is_linux - libdvdcss = dependency('libdvdcss', required: false, allow_fallback: true) - libdvdread = dependency('dvdread', required: false, allow_fallback: true) - libdvdnav = dependency('dvdnav', required: false, allow_fallback: true) +if 'libdvd' in get_option('sources') + libdvdcss = dependency('libdvdcss', allow_fallback: true) + libdvdread = dependency('dvdread', allow_fallback: true) + libdvdnav = dependency('dvdnav', allow_fallback: true) if libdvdcss.found() and libdvdread.found() and libdvdnav.found() cache_deps += [libdvdcss, libdvdread, libdvdnav] cache_args += ['-DCACHE_HAVE_LIBDVD'] - cache_have_libdvd = true endif endif |