Skip track if returned LSNs are negative which indicates track errors or if track is not an audio track

This commit is contained in:
lazypingu 2024-02-26 10:35:50 +01:00
parent 9d853897cd
commit c00d217a53
1 changed files with 10 additions and 0 deletions

View File

@ -264,6 +264,16 @@ input_cdio_open(const char *uri,
lsn_to = cdio_cddap_disc_lastsector(drv);
}
/* LSNs < 0 indicate errors (e.g. -401: Invaid track, -402: no pregap) */
if(lsn_from < 0 || lsn_to < 0)
throw FmtRuntimeError("Error {} on track {}",
lsn_from < 0 ? lsn_from : lsn_to, parsed_uri.track);
/* Only check for audio track if not pregap or whole CD */
if (!cdio_cddap_track_audiop(drv, parsed_uri.track) && parsed_uri.track > 0)
throw FmtRuntimeError("No audio track: {}",
parsed_uri.track);
return std::make_unique<CdioParanoiaInputStream>(uri, mutex,
drv, cdio,
reverse_endian,