static snd_output_t *log;
static int fd = -1;
-static size_t count, fdcount;
+static size_t pbrec_count = (size_t)-1, fdcount;
static int vocmajor, vocminor;
/* needed prototypes */
snd_pcm_info_get_name(pcminfo));
count = snd_pcm_info_get_subdevices_count(pcminfo);
fprintf(stderr, " Subdevices: %i/%i\n", snd_pcm_info_get_subdevices_avail(pcminfo), count);
- for (idx = 0; idx < count; idx++) {
+ for (idx = 0; idx < (int)count; idx++) {
snd_pcm_info_set_subdevice(pcminfo, idx);
if ((err = snd_ctl_pcm_info(handle, pcminfo)) < 0) {
error("control digital audio playback info (%i): %s", card, snd_strerror(err));
{
if (*size >= reqsize)
return *size;
- if (safe_read(fd, buffer + *size, reqsize - *size) != reqsize - *size) {
+ if ((size_t)safe_read(fd, buffer + *size, reqsize - *size) != reqsize - *size) {
error("read error (called from line %i)", line);
exit(EXIT_FAILURE);
}
memmove(buffer, buffer + sizeof(WaveChunkHeader), size - sizeof(WaveChunkHeader));
size -= sizeof(WaveChunkHeader);
if (type == WAV_DATA) {
- if (len < count)
- count = len;
+ if (len < pbrec_count)
+ pbrec_count = len;
if (size > 0)
memcpy(_buffer, buffer, size);
free(buffer);
return -1;
if (BE_INT(ap->hdr_size) > 128 || BE_INT(ap->hdr_size) < 24)
return -1;
- count = BE_INT(ap->data_size);
+ pbrec_count = BE_INT(ap->data_size);
switch (BE_INT(ap->encoding)) {
case AU_FMT_ULAW:
hwparams.format = SND_PCM_FORMAT_MU_LAW;
hwparams.channels = BE_INT(ap->channels);
if (hwparams.channels < 1 || hwparams.channels > 128)
return -1;
- if (safe_read(fd, buffer + sizeof(AuHeader), BE_INT(ap->hdr_size) - sizeof(AuHeader)) != BE_INT(ap->hdr_size) - sizeof(AuHeader)) {
+ if ((size_t)safe_read(fd, buffer + sizeof(AuHeader), BE_INT(ap->hdr_size) - sizeof(AuHeader)) != BE_INT(ap->hdr_size) - sizeof(AuHeader)) {
error("read error");
exit(EXIT_FAILURE);
}
}
while (count > 0) {
r = writei_func(handle, data, count);
- if (r == -EAGAIN || (r >= 0 && r < count)) {
+ if (r == -EAGAIN || (r >= 0 && (size_t)r < count)) {
snd_pcm_wait(handle, 1000);
} else if (r == -EPIPE) {
xrun();
for (channel = 0; channel < channels; channel++)
bufs[channel] = data[channel] + offset * bits_per_sample / 8;
r = writen_func(handle, bufs, count);
- if (r == -EAGAIN || (r >= 0 && r < count)) {
+ if (r == -EAGAIN || (r >= 0 && (size_t)r < count)) {
snd_pcm_wait(handle, 1000);
} else if (r == -EPIPE) {
xrun();
while (count > 0) {
r = readi_func(handle, data, count);
- if (r == -EAGAIN || (r >= 0 && r < count)) {
+ if (r == -EAGAIN || (r >= 0 && (size_t)r < count)) {
snd_pcm_wait(handle, 1000);
} else if (r == -EPIPE) {
xrun();
for (channel = 0; channel < channels; channel++)
bufs[channel] = data[channel] + offset * bits_per_sample / 8;
r = readn_func(handle, bufs, count);
- if (r == -EAGAIN || (r >= 0 && r < count)) {
+ if (r == -EAGAIN || (r >= 0 && (size_t)r < count)) {
snd_pcm_wait(handle, 1000);
} else if (r == -EPIPE) {
xrun();
data += size;
count -= size;
buffer_pos += size;
- if (buffer_pos == chunk_bytes) {
- if ((r = pcm_write(audiobuf, chunk_size)) != chunk_size)
+ if ((size_t)buffer_pos == chunk_bytes) {
+ if ((size_t)(r = pcm_write(audiobuf, chunk_size)) != chunk_size)
return r;
buffer_pos = 0;
}
l = x;
if (l > chunk_size)
l = chunk_size;
- if (voc_pcm_write(buf, l) != l) {
+ if (voc_pcm_write(buf, l) != (ssize_t)l) {
error("write error");
exit(EXIT_FAILURE);
}
} else {
b = buffer_pos * 8 / bits_per_frame;
}
- if (pcm_write(audiobuf, b) != b)
+ if (pcm_write(audiobuf, b) != (ssize_t)b)
error("voc_pcm_flush error");
}
snd_pcm_drain(handle);
fprintf(stderr, "Playing Creative Labs Channel file '%s'...\n", name);
}
/* first we waste the rest of header, ugly but we don't need seek */
- while (ofs > chunk_bytes) {
- if (safe_read(fd, buf, chunk_bytes) != chunk_bytes) {
+ while (ofs > (ssize_t)chunk_bytes) {
+ if ((size_t)safe_read(fd, buf, chunk_bytes) != chunk_bytes) {
error("read error");
exit(EXIT_FAILURE);
}
} /* while (! nextblock) */
/* put nextblock data bytes to dsp */
l = in_buffer;
- if (nextblock < l)
+ if (nextblock < (size_t)l)
l = nextblock;
if (l) {
if (output && !quiet_mode) {
size_t count;
if (!timelimit) {
- count = -1;
+ count = (size_t)-1;
} else {
count = snd_pcm_format_size(hwparams.format,
timelimit * hwparams.rate *
hwparams.channels);
}
- return count;
+ return count < pbrec_count ? count : pbrec_count;
}
/* write a .VOC-header */
if (r == 0)
break;
l += r;
- } while (sleep_min == 0 && l < chunk_bytes);
+ } while (sleep_min == 0 && (size_t)l < chunk_bytes);
l = l * 8 / bits_per_frame;
r = pcm_write(audiobuf, l);
if (r != l)
if (c > chunk_bytes)
c = chunk_bytes;
c = c * 8 / bits_per_frame;
- if ((r = pcm_read(audiobuf, c)) != c)
+ if ((size_t)(r = pcm_read(audiobuf, c)) != c)
break;
r = r * bits_per_frame / 8;
if ((err = write(fd, audiobuf, r)) != r) {
}
/* read the file header */
dta = sizeof(AuHeader);
- if (safe_read(fd, audiobuf, dta) != dta) {
+ if ((size_t)safe_read(fd, audiobuf, dta) != dta) {
error("read error");
exit(EXIT_FAILURE);
}
if (test_au(fd, audiobuf) >= 0) {
rhwparams.format = SND_PCM_FORMAT_MU_LAW;
- count = calc_count();
- playback_go(fd, 0, count, FORMAT_AU, name);
+ pbrec_count = calc_count();
+ playback_go(fd, 0, pbrec_count, FORMAT_AU, name);
goto __end;
}
dta = sizeof(VocHeader);
- if (safe_read(fd, audiobuf + sizeof(AuHeader),
+ if ((size_t)safe_read(fd, audiobuf + sizeof(AuHeader),
dta - sizeof(AuHeader)) != dta - sizeof(AuHeader)) {
error("read error");
exit(EXIT_FAILURE);
}
if ((ofs = test_vocfile(audiobuf)) >= 0) {
- count = calc_count();
+ pbrec_count = calc_count();
voc_play(fd, ofs, name);
goto __end;
}
/* read bytes for WAVE-header */
if ((dtawave = test_wavefile(fd, audiobuf, dta)) >= 0) {
- count = calc_count();
- playback_go(fd, dtawave, count, FORMAT_WAVE, name);
+ pbrec_count = calc_count();
+ playback_go(fd, dtawave, pbrec_count, FORMAT_WAVE, name);
} else {
/* should be raw data */
init_raw_data();
- count = calc_count();
- playback_go(fd, dta, count, FORMAT_RAW, name);
+ pbrec_count = calc_count();
+ playback_go(fd, dta, pbrec_count, FORMAT_RAW, name);
}
__end:
if (fd != 0)
}
}
fdcount = 0;
- count = calc_count();
- count += count % 2;
- if (count == 0)
- count -= 2;
+ pbrec_count = calc_count();
/* WAVE-file should be even (I'm not sure), but wasting one byte
isn't a problem (this can only be in 8 bit mono) */
+ pbrec_count += pbrec_count % 2;
+ if (pbrec_count == 0)
+ pbrec_count -= 2;
if (fmt_rec_table[file_type].start)
- fmt_rec_table[file_type].start(fd, count);
- capture_go(fd, count, file_type, name);
+ fmt_rec_table[file_type].start(fd, pbrec_count);
+ capture_go(fd, pbrec_count, file_type, name);
fmt_rec_table[file_type].end(fd);
}
} while (sleep_min == 0 && c < expected);
c = c * 8 / bits_per_sample;
r = pcm_writev(bufs, channels, c);
- if (r != c)
+ if ((size_t)r != c)
break;
r = r * bits_per_frame / 8;
count -= r;
if (c > chunk_bytes)
c = chunk_bytes;
c = c * 8 / bits_per_frame;
- if ((r = pcm_readv(bufs, channels, c)) != c)
+ if ((size_t)(r = pcm_readv(bufs, channels, c)) != c)
break;
rv = r * bits_per_sample / 8;
for (channel = 0; channel < channels; ++channel) {
- if (write(fds[channel], bufs[channel], rv) != rv) {
+ if ((size_t)write(fds[channel], bufs[channel], rv) != rv) {
perror(names[channel]);
exit(EXIT_FAILURE);
}
}
/* should be raw data */
init_raw_data();
- count = calc_count();
- playbackv_go(fds, channels, 0, count, FORMAT_RAW, names);
+ pbrec_count = calc_count();
+ playbackv_go(fds, channels, 0, pbrec_count, FORMAT_RAW, names);
__end:
for (channel = 0; channel < channels; ++channel) {
}
/* should be raw data */
init_raw_data();
- count = calc_count();
- capturev_go(fds, channels, count, FORMAT_RAW, names);
+ pbrec_count = calc_count();
+ capturev_go(fds, channels, pbrec_count, FORMAT_RAW, names);
__end:
for (channel = 0; channel < channels; ++channel) {