-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGapless.xs
72 lines (58 loc) · 1.5 KB
/
Gapless.xs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
#include "ppport.h"
#include "common.c"
#include "mp3cut.c"
MODULE = MP3::Cut::Gapless PACKAGE = MP3::Cut::Gapless
void
__init(HV *self)
PPCODE:
{
SV *pv = NEWSV(0, sizeof(mp3cut));
mp3cut *mp3c = (mp3cut *)SvPVX(pv);
SvPOK_only(pv);
Newz(0, mp3c->buf, sizeof(Buffer), Buffer);
Newz(0, mp3c->mllt_buf, sizeof(Buffer), Buffer);
Newz(0, mp3c->first_frame, sizeof(mp3frame), mp3frame);
Newz(0, mp3c->curr_frame, sizeof(mp3frame), mp3frame);
Newz(0, mp3c->xilt_frame, sizeof(xiltframe), xiltframe);
Newz(0, mp3c->xilt_frame->tag, sizeof(Buffer), Buffer);
buffer_init(mp3c->buf, MP3_BLOCK_SIZE);
buffer_init(mp3c->mllt_buf, MP3_BLOCK_SIZE);
_mp3cut_init(self, mp3c);
XPUSHs( sv_2mortal( sv_bless(
newRV_noinc(pv),
gv_stashpv("MP3::Cut::Gapless::XS", 1)
) ) );
}
int
read(HV *self, SV *buf, SV *buf_size)
CODE:
{
mp3cut *mp3c = (mp3cut *)SvPVX(SvRV(*(my_hv_fetch(self, "_mp3c"))));
RETVAL = _mp3cut_read(self, mp3c, buf, SvIV(buf_size));
}
OUTPUT:
RETVAL
void
__reset_read(HV *self)
CODE:
{
mp3cut *mp3c = (mp3cut *)SvPVX(SvRV(*(my_hv_fetch(self, "_mp3c"))));
mp3c->next_processed_frame = 0;
}
void
__cleanup(HV *self, mp3cut *mp3c)
CODE:
{
Safefree(mp3c->first_frame);
Safefree(mp3c->curr_frame);
buffer_free(mp3c->xilt_frame->tag);
Safefree(mp3c->xilt_frame->tag);
Safefree(mp3c->xilt_frame);
buffer_free(mp3c->buf);
Safefree(mp3c->buf);
buffer_free(mp3c->mllt_buf);
Safefree(mp3c->mllt_buf);
}