Audio-Opusfile

 view release on metacpan or  search on metacpan

Opusfile.xs  view on Meta::CPAN

	int enabled;


void
op_read(of, bufsize = 1024 * 1024)
	Audio::Opusfile of;
	int bufsize;
PREINIT:
	opus_int16* buf;
	int li, ret, chans, i;
PPCODE:
	Newx(buf, bufsize, opus_int16);
	ret = op_read(of, buf, bufsize, &li);
	if(ret < 0)
		croak("op_read returned error %d\n", ret);
	chans = op_channel_count(of, li);
	EXTEND(SP, chans * ret + 1);
	PUSHs(sv_2mortal(newSViv(li)));
	for(i = 0 ; i < chans * ret ; i++)
		PUSHs(sv_2mortal(newSViv(buf[i])));

void
op_read_float(of, bufsize = 1024 * 1024)
	Audio::Opusfile of;
	int bufsize;
PREINIT:
	float* buf;
	int li, ret, chans, i;
PPCODE:
	Newx(buf, bufsize, float);
	ret = op_read_float(of, buf, bufsize, &li);
	if(ret < 0)
		croak("op_read_float returned error %d\n", ret);
	chans = op_channel_count(of, li);
	EXTEND(SP, chans * ret + 1);
	PUSHs(sv_2mortal(newSViv(li)));
	for(i = 0 ; i < chans * ret ; i++)
		PUSHs(sv_2mortal(newSVnv(buf[i])));

void
op_read_stereo(of, bufsize = 1024 * 1024)
	Audio::Opusfile of;
	int bufsize;
PREINIT:
	opus_int16* buf;
	int ret, i;
PPCODE:
	Newx(buf, bufsize, opus_int16);
	ret = op_read_stereo(of, buf, bufsize);
	if(ret < 0)
		croak("op_read_stereo returned error %d\n", ret);
	EXTEND(SP, 2 * ret);
	for(i = 0 ; i < 2 * ret ; i++)
		PUSHs(sv_2mortal(newSViv(buf[i])));

void
op_read_float_stereo(of, bufsize = 1024 * 1024)
	Audio::Opusfile of;
	int bufsize;
PREINIT:
	float* buf;
	int ret, i;
PPCODE:
	Newx(buf, bufsize, float);
	ret = op_read_float_stereo(of, buf, bufsize);
	if(ret < 0)
		croak("op_read_float_stereo returned error %d\n", ret);
	EXTEND(SP, 2 * ret);
	for(i = 0 ; i < 2 * ret ; i++)
		PUSHs(sv_2mortal(newSVnv(buf[i])));



fallback/const-xs.inc  view on Meta::CPAN

	dTARGET;
#endif
	STRLEN		len;
        int		type;
	IV		iv;
	/* NV		nv;	Uncomment this if you need to return NVs */
	/* const char	*pv;	Uncomment this if you need to return PVs */
    INPUT:
	SV *		sv;
        const char *	s = SvPV(sv, len);
    PPCODE:
        /* Change this to constant(aTHX_ s, len, &iv, &nv);
           if you need to return both NVs and IVs */
	type = constant(aTHX_ s, len, &iv);
      /* Return 1 or 2 items. First is error message, or undef if no error.
           Second, if present, is found value */
        switch (type) {
        case PERL_constant_NOTFOUND:
          sv =
	    sv_2mortal(newSVpvf("%s is not a valid Audio::Opusfile macro", s));
          PUSHs(sv);



( run in 1.781 second using v1.01-cache-2.11-cpan-71847e10f99 )