コード例 #1
0
static int
CDDAReader_init_image(cdio_CDDAReader *self, const char *device)
{
    self->_.image.image = NULL;
    self->_.image.current_sector = 0;
    self->_.image.final_sector = 0;
    self->first_track_num  = CDDAReader_first_track_num_image;
    self->last_track_num = CDDAReader_last_track_num_image;
    self->track_lsn = CDDAReader_track_lsn_image;
    self->track_last_lsn = CDDAReader_track_last_lsn_image;
    self->first_sector = CDDAReader_first_sector_image;
    self->last_sector = CDDAReader_last_sector_image;
    self->read = CDDAReader_read_image;
    self->seek = CDDAReader_seek_image;
    self->set_speed = CDDAReader_set_speed_image;
    self->dealloc = CDDAReader_dealloc_image;

    /*open CD image based on what type it is*/
    if (cdio_is_cuefile(device)) {
        self->_.image.image = cdio_open_cue(device);
    } else if (cdio_is_tocfile(device)) {
        self->_.image.image = cdio_open_bincue(device);
    } else if (cdio_is_tocfile(device)) {
        self->_.image.image = cdio_open_cdrdao(device);
    } else if (cdio_is_nrg(device)) {
        self->_.image.image = cdio_open_nrg(device);
    }
    if (self->_.image.image == NULL) {
        PyErr_SetString(PyExc_IOError, "unable to open CD image");
        return -1;
    }
    self->_.image.final_sector = (lsn_t)self->last_sector(self);
    return 0;
}
コード例 #2
0
ファイル: cdiomodule.c プロジェクト: Excito/audiotools
static int
CDImage_init(cdio_CDImage *self, PyObject *args, PyObject *kwds) {
    const char *image = NULL;
    int image_type;
    self->pcm_module = NULL;
    self->image = NULL;

    if (!PyArg_ParseTuple(args, "si", &image, &image_type))
        return -1;

    if ((self->pcm_module = PyImport_ImportModule("audiotools.pcm")) == NULL)
        return -1;

    switch (image_type & 0x7) {
    case CUE_FILE:
        self->image = cdio_open_cue(image);
        break;
    case BIN_FILE:
        self->image = cdio_open_bincue(image);
        break;
    case TOC_FILE:
        self->image = cdio_open_cdrdao(image);
        break;
    case NRG_FILE:
        self->image = cdio_open_nrg(image);
        break;
    default:
        self->image = NULL;
        break;
    }

    if (self->image == NULL) {
        PyErr_SetString(PyExc_ValueError, "Unable to open image file");
        return -1;
    }

    return 0;
}