Commit 919c7c3e authored by Gerion Entrup's avatar Gerion Entrup
Browse files

cdda: add basic open and seek function

parent 1a626abf
......@@ -32,9 +32,11 @@
typedef struct {
const AVClass *class;
CDDA *cd;
cdrom_drive_t *cd;
cdrom_paranoid_t *cdp;
int playlist;
int paranoia_mode;
int track;
int angle;
int chapter;
/*int region;*/
......@@ -56,12 +58,67 @@ static const AVClass cdda_context_class = {
.version = LIBAVUTIL_VERSION_INT,
};
static int cdda_open(URLContext *h, const char *path, int flags)
{
CddaContext *cd = h->priv_data;
int mode = cd->paranoid_mode;
int num_tracks;
const char *diskname = path;
cd_info_t *cd_info;
av_strstart(path, CDDA_PROTO_PREFIX, &diskname);
/* identify device */
cd->cd = cdda_identify(diskname, 0, NULL);
if (!cd->cd) {
av_log(h, AV_LOG_ERROR, "Can't open CDDA device.\n");
return AVERROR(EIO);
}
/* be quiet */
cdio_cddap_verbose_set(cd->cd, CDDA_MESSAGE_FORGETIT, CDDA_MESSAGE_FORGETIT);
/* open cd */
if (cdda_open(cd->cd) != 0) {
av_log(h, AV_LOG_ERROR, "Can't open disc.\n");
cdda_close(cd->cd)
return AVERROR(EIO);
}
cd_info = cd_info_new();
/* load title list */
num_tracks = (int)cdda_tracks(cd->cd);
av_log(h, AV_LOG_INFO, "Found audio CD with %d tracks:\n", num_tracks);
if (num_tracks < 1) {
return AVERROR(EIO);
}
int i;
for (i = 1; i <= num_tracks; i++) {
long sec = cdda_track_firstsector(cd->cd, i);
long off = cdda_track_lastsector(cd->cd, i) - sec + 1;
av_log(h, AV_LOG_INFO, "Track %d, Length: %d sec, at posistion %d sec", i, sec, off);
}
/* if track was not given, select first track */
if (cd->track < 1) {
cd->track = 1;
}
/* select speed */
if (cd->speed > 0) {
cdda_speed_set(cd->cd, cd->speed);
}
return 0;
}
static int64_t bluray_seek(URLContext *h, int64_t pos, int whence)
{
CddaContext *cd = h->priv_data;
if (!bd || !bd->bd) {
if (!cd || !cd->cd) {
return AVERROR(EFAULT);
}
......@@ -69,7 +126,7 @@ static int64_t bluray_seek(URLContext *h, int64_t pos, int whence)
case SEEK_SET:
case SEEK_CUR:
case SEEK_END:
return bd_seek(bd->bd, pos);
return paranoia_seek(cd->cdp, pos);
case AVSEEK_SIZE:
return bd_get_title_size(bd->bd);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment