Skip to content

Commit 4c114af

Browse files
committed
correct type definitions in the C extension
The type names ending with _t are reserved, so use the names Sample, Frame and AccurateRip for my own types.
1 parent 853a3ac commit 4c114af

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

arver/audio/_audio.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@
2828
#include <sndfile.h>
2929
#include <zlib.h>
3030

31-
typedef uint16_t sample_t; // CDDA 16-bit sample (single channel)
32-
typedef uint32_t frame_t; // CDDA stereo frame (a pair of 16-bit samples)
31+
typedef uint16_t Sample; // CDDA 16-bit sample (single channel)
32+
typedef uint32_t Frame; // CDDA stereo frame (a pair of 16-bit samples)
3333

3434
// A pair of AccurateRip checksums
35-
typedef struct accuraterip_t {
35+
typedef struct AccurateRip {
3636
uint32_t v1;
3737
uint32_t v2;
38-
} accuraterip_t;
38+
} AccurateRip;
3939

4040
static int check_format(SF_INFO info)
4141
{
@@ -59,10 +59,10 @@ static int check_format(SF_INFO info)
5959
return 0;
6060
}
6161

62-
static sample_t *load_audio_data(SNDFILE *file, SF_INFO info, size_t *size)
62+
static Sample *load_audio_data(SNDFILE *file, SF_INFO info, size_t *size)
6363
{
6464
size_t nsamples = info.frames * info.channels;
65-
sample_t *data = calloc(nsamples, sizeof(sample_t));
65+
Sample *data = calloc(nsamples, sizeof(Sample));
6666

6767
if (data == NULL) {
6868
return NULL;
@@ -85,9 +85,9 @@ static sample_t *load_audio_data(SNDFILE *file, SF_INFO info, size_t *size)
8585
return data;
8686
}
8787

88-
static accuraterip_t accuraterip(const sample_t *data, size_t size, unsigned track, unsigned total_tracks)
88+
static AccurateRip accuraterip(const Sample *data, size_t size, unsigned track, unsigned total_tracks)
8989
{
90-
const frame_t *frames = (const frame_t*)data;
90+
const Frame *frames = (const Frame*)data;
9191
const size_t nframes = size / 2; // 2 samples per CDDA frame
9292
const size_t skip_frames = 5 * 588; // 5 CDDA sectors * 588 audio frames per sector
9393

@@ -117,7 +117,7 @@ static accuraterip_t accuraterip(const sample_t *data, size_t size, unsigned tra
117117
v1 = csum_lo;
118118
v2 = csum_lo + csum_hi;
119119

120-
return (accuraterip_t){.v1 = v1, .v2 = v2};
120+
return (AccurateRip){.v1 = v1, .v2 = v2};
121121
}
122122

123123
static PyObject *checksums(PyObject *self, PyObject *args)
@@ -158,7 +158,7 @@ static PyObject *checksums(PyObject *self, PyObject *args)
158158
}
159159

160160
size_t size = 0;
161-
sample_t *data = load_audio_data(file, info, &size);
161+
Sample *data = load_audio_data(file, info, &size);
162162
sf_close(file);
163163

164164
if (data == NULL) {
@@ -168,7 +168,7 @@ static PyObject *checksums(PyObject *self, PyObject *args)
168168

169169
uint32_t crc = crc32(0L, Z_NULL, 0);
170170
crc = crc32(crc, (uint8_t*)data, 2*size); // 2 bytes per CDDA sample
171-
accuraterip_t ar = accuraterip(data, size, track, total_tracks);
171+
AccurateRip ar = accuraterip(data, size, track, total_tracks);
172172
free(data);
173173

174174
return Py_BuildValue("III", ar.v1, ar.v2, crc);

0 commit comments

Comments
 (0)