mirror of
https://github.com/alsa-project/alsa-utils
synced 2024-11-10 00:45:41 +01:00
aplay,axfer: Replace off64_t with off_t
Also replace lseek64 with lseek. _FILE_OFFSET_BITS=64 is passed to needed platforms since configure uses AC_SYS_LARGEFILE macro. Therefore off_t is already 64-bit and lseek is same as lseek64. Additionally this fixes buils with latest musl where these lfs64 functions are moved out from _GNU_SOURCE and under _LARGEFILE64_SOURCE macro alone. This makes the builds fail on 32-bit platforms even though default off_t on musl is 64-bit always. Fixes: https://github.com/alsa-project/alsa-utils/pull/183 Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp> Signed-off-by: Khem Raj <raj.khem@gmail.com> Signed-off-by: Jaroslav Kysela <perex@perex.cz>
This commit is contained in:
parent
deaa1635cc
commit
4e3843d0ed
6 changed files with 30 additions and 30 deletions
|
@ -141,7 +141,7 @@ static long term_c_lflag = -1;
|
||||||
static int dump_hw_params = 0;
|
static int dump_hw_params = 0;
|
||||||
|
|
||||||
static int fd = -1;
|
static int fd = -1;
|
||||||
static off64_t pbrec_count = LLONG_MAX, fdcount;
|
static off_t pbrec_count = LLONG_MAX, fdcount;
|
||||||
static int vocmajor, vocminor;
|
static int vocmajor, vocminor;
|
||||||
|
|
||||||
static char *pidfile_name = NULL;
|
static char *pidfile_name = NULL;
|
||||||
|
@ -2372,7 +2372,7 @@ static void voc_play(int fd, int ofs, char *name)
|
||||||
u_char *data, *buf;
|
u_char *data, *buf;
|
||||||
char was_extended = 0, output = 0;
|
char was_extended = 0, output = 0;
|
||||||
u_short *sp, repeat = 0;
|
u_short *sp, repeat = 0;
|
||||||
off64_t filepos = 0;
|
off_t filepos = 0;
|
||||||
|
|
||||||
#define COUNT(x) nextblock -= x; in_buffer -= x; data += x
|
#define COUNT(x) nextblock -= x; in_buffer -= x; data += x
|
||||||
#define COUNT1(x) in_buffer -= x; data += x
|
#define COUNT1(x) in_buffer -= x; data += x
|
||||||
|
@ -2506,7 +2506,7 @@ static void voc_play(int fd, int ofs, char *name)
|
||||||
d_printf("Repeat loop %d times\n", repeat);
|
d_printf("Repeat loop %d times\n", repeat);
|
||||||
#endif
|
#endif
|
||||||
if (filepos >= 0) { /* if < 0, one seek fails, why test another */
|
if (filepos >= 0) { /* if < 0, one seek fails, why test another */
|
||||||
if ((filepos = lseek64(fd, 0, 1)) < 0) {
|
if ((filepos = lseek(fd, 0, 1)) < 0) {
|
||||||
error(_("can't play loops; %s isn't seekable\n"), name);
|
error(_("can't play loops; %s isn't seekable\n"), name);
|
||||||
repeat = 0;
|
repeat = 0;
|
||||||
} else {
|
} else {
|
||||||
|
@ -2528,7 +2528,7 @@ static void voc_play(int fd, int ofs, char *name)
|
||||||
else
|
else
|
||||||
d_printf("Neverending loop\n");
|
d_printf("Neverending loop\n");
|
||||||
#endif
|
#endif
|
||||||
lseek64(fd, filepos, 0);
|
lseek(fd, filepos, 0);
|
||||||
in_buffer = 0; /* clear the buffer */
|
in_buffer = 0; /* clear the buffer */
|
||||||
goto Fill_the_buffer;
|
goto Fill_the_buffer;
|
||||||
}
|
}
|
||||||
|
@ -2594,9 +2594,9 @@ static void init_raw_data(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* calculate the data count to read from/to dsp */
|
/* calculate the data count to read from/to dsp */
|
||||||
static off64_t calc_count(void)
|
static off_t calc_count(void)
|
||||||
{
|
{
|
||||||
off64_t count;
|
off_t count;
|
||||||
|
|
||||||
if (timelimit == 0)
|
if (timelimit == 0)
|
||||||
if (sampleslimit == 0)
|
if (sampleslimit == 0)
|
||||||
|
@ -2605,7 +2605,7 @@ static off64_t calc_count(void)
|
||||||
count = snd_pcm_format_size(hwparams.format, sampleslimit * hwparams.channels);
|
count = snd_pcm_format_size(hwparams.format, sampleslimit * hwparams.channels);
|
||||||
else {
|
else {
|
||||||
count = snd_pcm_format_size(hwparams.format, hwparams.rate * hwparams.channels);
|
count = snd_pcm_format_size(hwparams.format, hwparams.rate * hwparams.channels);
|
||||||
count *= (off64_t)timelimit;
|
count *= (off_t)timelimit;
|
||||||
}
|
}
|
||||||
return count < pbrec_count ? count : pbrec_count;
|
return count < pbrec_count ? count : pbrec_count;
|
||||||
}
|
}
|
||||||
|
@ -2766,7 +2766,7 @@ static void begin_au(int fd, size_t cnt)
|
||||||
/* closing .VOC */
|
/* closing .VOC */
|
||||||
static void end_voc(int fd)
|
static void end_voc(int fd)
|
||||||
{
|
{
|
||||||
off64_t length_seek;
|
off_t length_seek;
|
||||||
VocBlockType bt;
|
VocBlockType bt;
|
||||||
size_t cnt;
|
size_t cnt;
|
||||||
char dummy = 0; /* Write a Terminator */
|
char dummy = 0; /* Write a Terminator */
|
||||||
|
@ -2786,15 +2786,15 @@ static void end_voc(int fd)
|
||||||
bt.datalen = (u_char) (cnt & 0xFF);
|
bt.datalen = (u_char) (cnt & 0xFF);
|
||||||
bt.datalen_m = (u_char) ((cnt & 0xFF00) >> 8);
|
bt.datalen_m = (u_char) ((cnt & 0xFF00) >> 8);
|
||||||
bt.datalen_h = (u_char) ((cnt & 0xFF0000) >> 16);
|
bt.datalen_h = (u_char) ((cnt & 0xFF0000) >> 16);
|
||||||
if (lseek64(fd, length_seek, SEEK_SET) == length_seek)
|
if (lseek(fd, length_seek, SEEK_SET) == length_seek)
|
||||||
xwrite(fd, &bt, sizeof(VocBlockType));
|
xwrite(fd, &bt, sizeof(VocBlockType));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void end_wave(int fd)
|
static void end_wave(int fd)
|
||||||
{ /* only close output */
|
{ /* only close output */
|
||||||
WaveChunkHeader cd;
|
WaveChunkHeader cd;
|
||||||
off64_t length_seek;
|
off_t length_seek;
|
||||||
off64_t filelen;
|
off_t filelen;
|
||||||
u_int rifflen;
|
u_int rifflen;
|
||||||
|
|
||||||
length_seek = sizeof(WaveHeader) +
|
length_seek = sizeof(WaveHeader) +
|
||||||
|
@ -2804,20 +2804,20 @@ static void end_wave(int fd)
|
||||||
cd.length = fdcount > 0x7fffffff ? LE_INT(0x7fffffff) : LE_INT(fdcount);
|
cd.length = fdcount > 0x7fffffff ? LE_INT(0x7fffffff) : LE_INT(fdcount);
|
||||||
filelen = fdcount + 2*sizeof(WaveChunkHeader) + sizeof(WaveFmtBody) + 4;
|
filelen = fdcount + 2*sizeof(WaveChunkHeader) + sizeof(WaveFmtBody) + 4;
|
||||||
rifflen = filelen > 0x7fffffff ? LE_INT(0x7fffffff) : LE_INT(filelen);
|
rifflen = filelen > 0x7fffffff ? LE_INT(0x7fffffff) : LE_INT(filelen);
|
||||||
if (lseek64(fd, 4, SEEK_SET) == 4)
|
if (lseek(fd, 4, SEEK_SET) == 4)
|
||||||
xwrite(fd, &rifflen, 4);
|
xwrite(fd, &rifflen, 4);
|
||||||
if (lseek64(fd, length_seek, SEEK_SET) == length_seek)
|
if (lseek(fd, length_seek, SEEK_SET) == length_seek)
|
||||||
xwrite(fd, &cd, sizeof(WaveChunkHeader));
|
xwrite(fd, &cd, sizeof(WaveChunkHeader));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void end_au(int fd)
|
static void end_au(int fd)
|
||||||
{ /* only close output */
|
{ /* only close output */
|
||||||
AuHeader ah;
|
AuHeader ah;
|
||||||
off64_t length_seek;
|
off_t length_seek;
|
||||||
|
|
||||||
length_seek = (char *)&ah.data_size - (char *)&ah;
|
length_seek = (char *)&ah.data_size - (char *)&ah;
|
||||||
ah.data_size = fdcount > 0xffffffff ? 0xffffffff : BE_INT(fdcount);
|
ah.data_size = fdcount > 0xffffffff ? 0xffffffff : BE_INT(fdcount);
|
||||||
if (lseek64(fd, length_seek, SEEK_SET) == length_seek)
|
if (lseek(fd, length_seek, SEEK_SET) == length_seek)
|
||||||
xwrite(fd, &ah.data_size, sizeof(ah.data_size));
|
xwrite(fd, &ah.data_size, sizeof(ah.data_size));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2844,11 +2844,11 @@ static void header(int rtype, char *name)
|
||||||
|
|
||||||
/* playing raw data */
|
/* playing raw data */
|
||||||
|
|
||||||
static void playback_go(int fd, size_t loaded, off64_t count, int rtype, char *name)
|
static void playback_go(int fd, size_t loaded, off_t count, int rtype, char *name)
|
||||||
{
|
{
|
||||||
int l, r;
|
int l, r;
|
||||||
off64_t written = 0;
|
off_t written = 0;
|
||||||
off64_t c;
|
off_t c;
|
||||||
|
|
||||||
header(rtype, name);
|
header(rtype, name);
|
||||||
set_params();
|
set_params();
|
||||||
|
@ -3218,7 +3218,7 @@ static void capture(char *orig_name)
|
||||||
int filecount=0; /* number of files written */
|
int filecount=0; /* number of files written */
|
||||||
char *name = orig_name; /* current filename */
|
char *name = orig_name; /* current filename */
|
||||||
char namebuf[PATH_MAX+2];
|
char namebuf[PATH_MAX+2];
|
||||||
off64_t count, rest; /* number of bytes to capture */
|
off_t count, rest; /* number of bytes to capture */
|
||||||
struct stat statbuf;
|
struct stat statbuf;
|
||||||
|
|
||||||
/* get number of bytes to capture */
|
/* get number of bytes to capture */
|
||||||
|
@ -3289,7 +3289,7 @@ static void capture(char *orig_name)
|
||||||
/* capture */
|
/* capture */
|
||||||
fdcount = 0;
|
fdcount = 0;
|
||||||
while (rest > 0 && recycle_capture_file == 0 && !in_aborting) {
|
while (rest > 0 && recycle_capture_file == 0 && !in_aborting) {
|
||||||
size_t c = (rest <= (off64_t)chunk_bytes) ?
|
size_t c = (rest <= (off_t)chunk_bytes) ?
|
||||||
(size_t)rest : chunk_bytes;
|
(size_t)rest : chunk_bytes;
|
||||||
size_t f = c * 8 / bits_per_frame;
|
size_t f = c * 8 / bits_per_frame;
|
||||||
size_t read = pcm_read(audiobuf, f);
|
size_t read = pcm_read(audiobuf, f);
|
||||||
|
@ -3330,7 +3330,7 @@ static void capture(char *orig_name)
|
||||||
} while ((file_type == FORMAT_RAW && !timelimit && !sampleslimit) || count > 0);
|
} while ((file_type == FORMAT_RAW && !timelimit && !sampleslimit) || count > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void playbackv_go(int* fds, unsigned int channels, size_t loaded, off64_t count, int rtype, char **names)
|
static void playbackv_go(int* fds, unsigned int channels, size_t loaded, off_t count, int rtype, char **names)
|
||||||
{
|
{
|
||||||
int r;
|
int r;
|
||||||
size_t vsize;
|
size_t vsize;
|
||||||
|
@ -3384,7 +3384,7 @@ static void playbackv_go(int* fds, unsigned int channels, size_t loaded, off64_t
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void capturev_go(int* fds, unsigned int channels, off64_t count, int rtype, char **names)
|
static void capturev_go(int* fds, unsigned int channels, off_t count, int rtype, char **names)
|
||||||
{
|
{
|
||||||
size_t c;
|
size_t c;
|
||||||
ssize_t r;
|
ssize_t r;
|
||||||
|
|
|
@ -775,7 +775,7 @@ static int write_block_terminator(struct container_context *cntr)
|
||||||
static int write_data_size(struct container_context *cntr, uint64_t byte_count)
|
static int write_data_size(struct container_context *cntr, uint64_t byte_count)
|
||||||
{
|
{
|
||||||
struct builder_state *state = cntr->private_data;
|
struct builder_state *state = cntr->private_data;
|
||||||
off64_t offset;
|
off_t offset;
|
||||||
uint8_t size_field[3];
|
uint8_t size_field[3];
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
|
|
|
@ -113,11 +113,11 @@ enum container_format container_format_from_path(const char *path)
|
||||||
return CONTAINER_FORMAT_RAW;
|
return CONTAINER_FORMAT_RAW;
|
||||||
}
|
}
|
||||||
|
|
||||||
int container_seek_offset(struct container_context *cntr, off64_t offset)
|
int container_seek_offset(struct container_context *cntr, off_t offset)
|
||||||
{
|
{
|
||||||
off64_t pos;
|
off_t pos;
|
||||||
|
|
||||||
pos = lseek64(cntr->fd, offset, SEEK_SET);
|
pos = lseek(cntr->fd, offset, SEEK_SET);
|
||||||
if (pos < 0)
|
if (pos < 0)
|
||||||
return -errno;
|
return -errno;
|
||||||
if (pos != offset)
|
if (pos != offset)
|
||||||
|
|
|
@ -107,7 +107,7 @@ int container_recursive_read(struct container_context *cntr, void *buf,
|
||||||
unsigned int byte_count);
|
unsigned int byte_count);
|
||||||
int container_recursive_write(struct container_context *cntr, void *buf,
|
int container_recursive_write(struct container_context *cntr, void *buf,
|
||||||
unsigned int byte_count);
|
unsigned int byte_count);
|
||||||
int container_seek_offset(struct container_context *cntr, off64_t offset);
|
int container_seek_offset(struct container_context *cntr, off_t offset);
|
||||||
|
|
||||||
extern const struct container_parser container_parser_riff_wave;
|
extern const struct container_parser container_parser_riff_wave;
|
||||||
extern const struct container_builder container_builder_riff_wave;
|
extern const struct container_builder container_builder_riff_wave;
|
||||||
|
|
|
@ -153,7 +153,7 @@ static int callback(struct test_generator *gen, snd_pcm_access_t access,
|
||||||
|
|
||||||
for (i = 0; i < ARRAY_SIZE(entries); ++i) {
|
for (i = 0; i < ARRAY_SIZE(entries); ++i) {
|
||||||
int fd;
|
int fd;
|
||||||
off64_t pos;
|
off_t pos;
|
||||||
|
|
||||||
frames_per_second = entries[i];
|
frames_per_second = entries[i];
|
||||||
|
|
||||||
|
@ -172,7 +172,7 @@ static int callback(struct test_generator *gen, snd_pcm_access_t access,
|
||||||
frames_per_second, frame_buffer, frame_count,
|
frames_per_second, frame_buffer, frame_count,
|
||||||
trial->verbose);
|
trial->verbose);
|
||||||
|
|
||||||
pos = lseek64(fd, 0, SEEK_SET);
|
pos = lseek(fd, 0, SEEK_SET);
|
||||||
if (pos < 0) {
|
if (pos < 0) {
|
||||||
err = -errno;
|
err = -errno;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -257,7 +257,7 @@ static int test_mapper(struct mapper_trial *trial, snd_pcm_access_t access,
|
||||||
goto end;
|
goto end;
|
||||||
|
|
||||||
for (i = 0; i < cntr_count; ++i) {
|
for (i = 0; i < cntr_count; ++i) {
|
||||||
off64_t pos = lseek64(cntr_fds[i], 0, SEEK_SET);
|
off_t pos = lseek(cntr_fds[i], 0, SEEK_SET);
|
||||||
if (pos != 0) {
|
if (pos != 0) {
|
||||||
err = -EIO;
|
err = -EIO;
|
||||||
goto end;
|
goto end;
|
||||||
|
|
Loading…
Reference in a new issue