Audio-MPC
view release on metacpan or search on metacpan
mcustomreader = Nullsv;
if ((ec = mpc_streaminfo_read(&msi, &mr->reader)) != ERROR_CODE_OK) {
Safefree(mr);
throw MPC_exception (ec, fname);
}
if (mpc_decoder_initialize(&md, &msi) == FALSE) {
Safefree(mr);
throw MPC_exception (ERROR_CODE_DECODER);
}
}
MPC (pTHX_ MPC_data *mpcdata, SV *obj) throw (MPC_exception) {
int ec;
New(0, mr, 1, mpc_reader_file);
mr->reader.read = read_impl; /* SCRESTO */
mr->reader.seek = seek_impl;
mr->reader.tell = tell_impl;
mr->reader.get_size = get_size_impl;
mr->reader.canseek = canseek_impl;
mr->reader.data = mpcdata;
mpc_streaminfo_init(&msi);
mpc_decoder_setup(&md, &mr->reader);
/* delayed initialization of 'self' field */
mcustomreader = mpcdata->self = obj;
if ((ec = mpc_streaminfo_read(&msi, &mr->reader)) != ERROR_CODE_OK) {
throw MPC_exception (ec);
}
if (mpc_decoder_initialize(&md, &msi) == FALSE) {
throw MPC_exception (ERROR_CODE_DECODER);
}
SvREFCNT_inc(mcustomreader);
}
void shutdown (pTHX) {
OUTPUT:
RETVAL
MPC *
MPC::new (...)
CODE:
{
FILE *file;
PerlIO *perlio = NULL;
char *fname = NULL;
MPC_data *mpcdata = NULL;
bool isperlio = false;
if (items == 1 || !SvOK(ST(1))) {
perlio = PerlIO_stdin();
file = PerlIO_exportFILE(PerlIO_stdin(), NULL);
isperlio = true;
}
else {
if (sv_isobject(ST(1)) and sv_derived_from(ST(1), "Audio::MPC::Reader")) {
mpcdata = (MPC_data*)SvIV(SvRV(ST(1)));
}
else if (!SvROK(ST(1))) {
file = fopen(fname = SvPV_nolen(ST(1)), "r");
if (!file) {
MPC_exception e(ERROR_CODE_FILE, fname);
errstr = e.to_string();
XSRETURN_UNDEF;
}
}
else if (glob_ref(ST(1))) {
perlio = IoIFP(sv_2io(ST(1)));
isperlio = true;
}
}
try {
if (mpcdata) RETVAL = new MPC (aTHX_ mpcdata, ST(1));
else if (isperlio) RETVAL = new MPC (aTHX_ perlio, fname);
else RETVAL = new MPC (aTHX_ file, fname);
} catch (MPC_exception e) {
errstr = e.to_string();
XSRETURN_UNDEF;
}
}
OUTPUT:
RETVAL
( run in 0.273 second using v1.01-cache-2.11-cpan-ec4f86ec37b )