"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "aplay/aplay.c" between
alsa-utils-1.2.5.tar.bz2 and alsa-utils-1.2.5.1.tar.bz2

About: ALSA (Advanced Linux Sound Architecture) - Utilities.

aplay.c  (alsa-utils-1.2.5.tar.bz2):aplay.c  (alsa-utils-1.2.5.1.tar.bz2)
skipping to change at line 35 skipping to change at line 35
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
* *
*/ */
#define _GNU_SOURCE #define _GNU_SOURCE
#include "aconfig.h" #include "aconfig.h"
#include <stdio.h> #include <stdio.h>
#include <malloc.h> #include <malloc.h>
#include <unistd.h> #include <unistd.h>
#include <stdlib.h> #include <stdlib.h>
#include <stdbool.h>
#include <string.h> #include <string.h>
#include <getopt.h> #include <getopt.h>
#include <fcntl.h> #include <fcntl.h>
#include <ctype.h> #include <ctype.h>
#include <errno.h> #include <errno.h>
#include <limits.h> #include <limits.h>
#include <time.h> #include <time.h>
#include <locale.h> #include <locale.h>
#include <alsa/asoundlib.h> #include <alsa/asoundlib.h>
#include <assert.h> #include <assert.h>
skipping to change at line 98 skipping to change at line 97
static snd_pcm_sframes_t (*writei_func)(snd_pcm_t *handle, const void *buffer, s nd_pcm_uframes_t size); static snd_pcm_sframes_t (*writei_func)(snd_pcm_t *handle, const void *buffer, s nd_pcm_uframes_t size);
static snd_pcm_sframes_t (*readn_func)(snd_pcm_t *handle, void **bufs, snd_pcm_u frames_t size); static snd_pcm_sframes_t (*readn_func)(snd_pcm_t *handle, void **bufs, snd_pcm_u frames_t size);
static snd_pcm_sframes_t (*writen_func)(snd_pcm_t *handle, void **bufs, snd_pcm_ uframes_t size); static snd_pcm_sframes_t (*writen_func)(snd_pcm_t *handle, void **bufs, snd_pcm_ uframes_t size);
enum { enum {
VUMETER_NONE, VUMETER_NONE,
VUMETER_MONO, VUMETER_MONO,
VUMETER_STEREO VUMETER_STEREO
}; };
static snd_pcm_format_t default_format = DEFAULT_FORMAT;
static char *command; static char *command;
static snd_pcm_t *handle; static snd_pcm_t *handle;
static struct { static struct {
snd_pcm_format_t format; snd_pcm_format_t format;
unsigned int channels; unsigned int channels;
unsigned int rate; unsigned int rate;
} hwparams, rhwparams; } hwparams, rhwparams;
static int timelimit = 0; static int timelimit = 0;
static int sampleslimit = 0; static int sampleslimit = 0;
static int quiet_mode = 0; static int quiet_mode = 0;
skipping to change at line 473 skipping to change at line 471
val = strtol(str, &endptr, 0); val = strtol(str, &endptr, 0);
if (errno != 0 || *endptr != '\0') if (errno != 0 || *endptr != '\0')
*err = -1; *err = -1;
else else
*err = 0; *err = 0;
return val; return val;
} }
static void try_to_adjust_default_format_16bit(void)
{
snd_pcm_hw_params_t *params;
int err;
snd_pcm_hw_params_alloca(&params);
err = snd_pcm_hw_params_any(handle, params);
if (err < 0) {
error(_("Broken configuration for this PCM: no configurations ava
ilable"));
prg_exit(EXIT_FAILURE);
}
if (file_type != FORMAT_AU && snd_pcm_hw_params_test_format(handle, param
s, SND_PCM_FORMAT_S16_LE) == 0)
rhwparams.format = default_format = SND_PCM_FORMAT_S16_LE;
else if (file_type == FORMAT_AU && snd_pcm_hw_params_test_format(handle,
params, SND_PCM_FORMAT_S16_BE) == 0)
rhwparams.format = default_format = SND_PCM_FORMAT_S16_BE;
}
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
int duration_or_sample = 0; int duration_or_sample = 0;
int option_index; int option_index;
static const char short_options[] = "hnlLD:qt:c:f:r:d:s:MNF:A:R:T:B:vV:IP Ci" static const char short_options[] = "hnlLD:qt:c:f:r:d:s:MNF:A:R:T:B:vV:IP Ci"
#ifdef CONFIG_SUPPORT_CHMAP #ifdef CONFIG_SUPPORT_CHMAP
"m:" "m:"
#endif #endif
; ;
static const struct option long_options[] = { static const struct option long_options[] = {
skipping to change at line 548 skipping to change at line 528
{"interactive", 0, 0, 'i'}, {"interactive", 0, 0, 'i'},
{"dump-hw-params", 0, 0, OPT_DUMP_HWPARAMS}, {"dump-hw-params", 0, 0, OPT_DUMP_HWPARAMS},
{"fatal-errors", 0, 0, OPT_FATAL_ERRORS}, {"fatal-errors", 0, 0, OPT_FATAL_ERRORS},
#ifdef CONFIG_SUPPORT_CHMAP #ifdef CONFIG_SUPPORT_CHMAP
{"chmap", 1, 0, 'm'}, {"chmap", 1, 0, 'm'},
#endif #endif
{0, 0, 0, 0} {0, 0, 0, 0}
}; };
char *pcm_name = "default"; char *pcm_name = "default";
int tmp, err, c; int tmp, err, c;
int do_device_list = 0, do_pcm_list = 0; int do_device_list = 0, do_pcm_list = 0, force_sample_format = 0;
snd_pcm_info_t *info; snd_pcm_info_t *info;
FILE *direction; FILE *direction;
bool user_set_fmt = false;
#ifdef ENABLE_NLS #ifdef ENABLE_NLS
setlocale(LC_ALL, ""); setlocale(LC_ALL, "");
textdomain(PACKAGE); textdomain(PACKAGE);
#endif #endif
snd_pcm_info_alloca(&info); snd_pcm_info_alloca(&info);
err = snd_output_stdio_attach(&log, stderr, 0); err = snd_output_stdio_attach(&log, stderr, 0);
assert(err >= 0); assert(err >= 0);
skipping to change at line 586 skipping to change at line 565
error(_("command should be named either arecord or aplay")); error(_("command should be named either arecord or aplay"));
return 1; return 1;
} }
if (isatty(fileno(direction)) && (argc == 1)) { if (isatty(fileno(direction)) && (argc == 1)) {
usage(command); usage(command);
return 1; return 1;
} }
chunk_size = -1; chunk_size = -1;
rhwparams.format = default_format; rhwparams.format = DEFAULT_FORMAT;
rhwparams.rate = DEFAULT_SPEED; rhwparams.rate = DEFAULT_SPEED;
rhwparams.channels = 1; rhwparams.channels = 1;
while ((c = getopt_long(argc, argv, short_options, long_options, &option_ index)) != -1) { while ((c = getopt_long(argc, argv, short_options, long_options, &option_ index)) != -1) {
switch (c) { switch (c) {
case 'h': case 'h':
usage(command); usage(command);
return 0; return 0;
case OPT_VERSION: case OPT_VERSION:
version(); version();
skipping to change at line 636 skipping to change at line 615
if (err < 0) { if (err < 0) {
error(_("invalid channels argument '%s'"), optarg ); error(_("invalid channels argument '%s'"), optarg );
return 1; return 1;
} }
if (rhwparams.channels < 1 || rhwparams.channels > 256) { if (rhwparams.channels < 1 || rhwparams.channels > 256) {
error(_("value %i for channels is invalid"), rhwp arams.channels); error(_("value %i for channels is invalid"), rhwp arams.channels);
return 1; return 1;
} }
break; break;
case 'f': case 'f':
user_set_fmt = true; force_sample_format = 1;
if (strcasecmp(optarg, "cd") == 0 || strcasecmp(optarg, " cdr") == 0) { if (strcasecmp(optarg, "cd") == 0 || strcasecmp(optarg, " cdr") == 0) {
if (strcasecmp(optarg, "cdr") == 0) if (strcasecmp(optarg, "cdr") == 0)
rhwparams.format = SND_PCM_FORMAT_S16_BE; rhwparams.format = SND_PCM_FORMAT_S16_BE;
else else
rhwparams.format = file_type == FORMAT_AU ? SND_PCM_FORMAT_S16_BE : SND_PCM_FORMAT_S16_LE; rhwparams.format = file_type == FORMAT_AU ? SND_PCM_FORMAT_S16_BE : SND_PCM_FORMAT_S16_LE;
rhwparams.rate = 44100; rhwparams.rate = 44100;
rhwparams.channels = 2; rhwparams.channels = 2;
} else if (strcasecmp(optarg, "dat") == 0) { } else if (strcasecmp(optarg, "dat") == 0) {
rhwparams.format = file_type == FORMAT_AU ? SND_P CM_FORMAT_S16_BE : SND_PCM_FORMAT_S16_LE; rhwparams.format = file_type == FORMAT_AU ? SND_P CM_FORMAT_S16_BE : SND_PCM_FORMAT_S16_LE;
rhwparams.rate = 48000; rhwparams.rate = 48000;
skipping to change at line 869 skipping to change at line 848
} }
if (nonblock) { if (nonblock) {
err = snd_pcm_nonblock(handle, 1); err = snd_pcm_nonblock(handle, 1);
if (err < 0) { if (err < 0) {
error(_("nonblock setting error: %s"), snd_strerror(err)) ; error(_("nonblock setting error: %s"), snd_strerror(err)) ;
return 1; return 1;
} }
} }
if (!user_set_fmt) if (!force_sample_format &&
try_to_adjust_default_format_16bit(); isatty(fileno(stdin)) &&
stream == SND_PCM_STREAM_CAPTURE &&
snd_pcm_format_width(rhwparams.format) <= 8)
fprintf(stderr, "Warning: Some sources (like microphones) may pro
duce inaudiable results\n"
" with 8-bit sampling. Use '-f' argument
to increase resolution\n"
" e.g. '-f S16_LE'.\n");
chunk_size = 1024; chunk_size = 1024;
hwparams = rhwparams; hwparams = rhwparams;
audiobuf = (u_char *)malloc(1024); audiobuf = (u_char *)malloc(1024);
if (audiobuf == NULL) { if (audiobuf == NULL) {
error(_("not enough memory")); error(_("not enough memory"));
return 1; return 1;
} }
skipping to change at line 1092 skipping to change at line 1076
prg_exit(EXIT_FAILURE); prg_exit(EXIT_FAILURE);
} }
channels = TO_CPU_SHORT(f->channels, big_endian); channels = TO_CPU_SHORT(f->channels, big_endian);
if (channels < 1) { if (channels < 1) {
error(_("can't play WAVE-files with %d tracks"), channels); error(_("can't play WAVE-files with %d tracks"), channels);
prg_exit(EXIT_FAILURE); prg_exit(EXIT_FAILURE);
} }
hwparams.channels = channels; hwparams.channels = channels;
switch (TO_CPU_SHORT(f->bit_p_spl, big_endian)) { switch (TO_CPU_SHORT(f->bit_p_spl, big_endian)) {
case 8: case 8:
if (hwparams.format != default_format && if (hwparams.format != DEFAULT_FORMAT &&
hwparams.format != SND_PCM_FORMAT_U8) hwparams.format != SND_PCM_FORMAT_U8)
fprintf(stderr, _("Warning: format is changed to U8\n")); fprintf(stderr, _("Warning: format is changed to U8\n"));
hwparams.format = SND_PCM_FORMAT_U8; hwparams.format = SND_PCM_FORMAT_U8;
break; break;
case 16: case 16:
if (big_endian) if (big_endian)
native_format = SND_PCM_FORMAT_S16_BE; native_format = SND_PCM_FORMAT_S16_BE;
else else
native_format = SND_PCM_FORMAT_S16_LE; native_format = SND_PCM_FORMAT_S16_LE;
if (hwparams.format != default_format && if (hwparams.format != DEFAULT_FORMAT &&
hwparams.format != native_format) hwparams.format != native_format)
fprintf(stderr, _("Warning: format is changed to %s\n"), fprintf(stderr, _("Warning: format is changed to %s\n"),
snd_pcm_format_name(native_format)); snd_pcm_format_name(native_format));
hwparams.format = native_format; hwparams.format = native_format;
break; break;
case 24: case 24:
switch (TO_CPU_SHORT(f->byte_p_spl, big_endian) / hwparams.channe ls) { switch (TO_CPU_SHORT(f->byte_p_spl, big_endian) / hwparams.channe ls) {
case 3: case 3:
if (big_endian) if (big_endian)
native_format = SND_PCM_FORMAT_S24_3BE; native_format = SND_PCM_FORMAT_S24_3BE;
else else
native_format = SND_PCM_FORMAT_S24_3LE; native_format = SND_PCM_FORMAT_S24_3LE;
if (hwparams.format != default_format && if (hwparams.format != DEFAULT_FORMAT &&
hwparams.format != native_format) hwparams.format != native_format)
fprintf(stderr, _("Warning: format is changed to %s\n"), fprintf(stderr, _("Warning: format is changed to %s\n"),
snd_pcm_format_name(native_format)); snd_pcm_format_name(native_format));
hwparams.format = native_format; hwparams.format = native_format;
break; break;
case 4: case 4:
if (big_endian) if (big_endian)
native_format = SND_PCM_FORMAT_S24_BE; native_format = SND_PCM_FORMAT_S24_BE;
else else
native_format = SND_PCM_FORMAT_S24_LE; native_format = SND_PCM_FORMAT_S24_LE;
if (hwparams.format != default_format && if (hwparams.format != DEFAULT_FORMAT &&
hwparams.format != native_format) hwparams.format != native_format)
fprintf(stderr, _("Warning: format is changed to %s\n"), fprintf(stderr, _("Warning: format is changed to %s\n"),
snd_pcm_format_name(native_format)); snd_pcm_format_name(native_format));
hwparams.format = native_format; hwparams.format = native_format;
break; break;
default: default:
error(_(" can't play WAVE-files with sample %d bits in %d bytes wide (%d channels)"), error(_(" can't play WAVE-files with sample %d bits in %d bytes wide (%d channels)"),
TO_CPU_SHORT(f->bit_p_spl, big_endian), TO_CPU_SHORT(f->bit_p_spl, big_endian),
TO_CPU_SHORT(f->byte_p_spl, big_endian), TO_CPU_SHORT(f->byte_p_spl, big_endian),
hwparams.channels); hwparams.channels);
skipping to change at line 1212 skipping to change at line 1196
{ {
AuHeader *ap = buffer; AuHeader *ap = buffer;
if (ap->magic != AU_MAGIC) if (ap->magic != AU_MAGIC)
return -1; return -1;
if (BE_INT(ap->hdr_size) > 128 || BE_INT(ap->hdr_size) < 24) if (BE_INT(ap->hdr_size) > 128 || BE_INT(ap->hdr_size) < 24)
return -1; return -1;
pbrec_count = BE_INT(ap->data_size); pbrec_count = BE_INT(ap->data_size);
switch (BE_INT(ap->encoding)) { switch (BE_INT(ap->encoding)) {
case AU_FMT_ULAW: case AU_FMT_ULAW:
if (hwparams.format != default_format && if (hwparams.format != DEFAULT_FORMAT &&
hwparams.format != SND_PCM_FORMAT_MU_LAW) hwparams.format != SND_PCM_FORMAT_MU_LAW)
fprintf(stderr, _("Warning: format is changed to MU_LAW\n ")); fprintf(stderr, _("Warning: format is changed to MU_LAW\n "));
hwparams.format = SND_PCM_FORMAT_MU_LAW; hwparams.format = SND_PCM_FORMAT_MU_LAW;
break; break;
case AU_FMT_LIN8: case AU_FMT_LIN8:
if (hwparams.format != default_format && if (hwparams.format != DEFAULT_FORMAT &&
hwparams.format != SND_PCM_FORMAT_U8) hwparams.format != SND_PCM_FORMAT_U8)
fprintf(stderr, _("Warning: format is changed to U8\n")); fprintf(stderr, _("Warning: format is changed to U8\n"));
hwparams.format = SND_PCM_FORMAT_U8; hwparams.format = SND_PCM_FORMAT_U8;
break; break;
case AU_FMT_LIN16: case AU_FMT_LIN16:
if (hwparams.format != default_format && if (hwparams.format != DEFAULT_FORMAT &&
hwparams.format != SND_PCM_FORMAT_S16_BE) hwparams.format != SND_PCM_FORMAT_S16_BE)
fprintf(stderr, _("Warning: format is changed to S16_BE\n ")); fprintf(stderr, _("Warning: format is changed to S16_BE\n "));
hwparams.format = SND_PCM_FORMAT_S16_BE; hwparams.format = SND_PCM_FORMAT_S16_BE;
break; break;
default: default:
return -1; return -1;
} }
hwparams.rate = BE_INT(ap->sample_rate); hwparams.rate = BE_INT(ap->sample_rate);
if (hwparams.rate < 2000 || hwparams.rate > 256000) if (hwparams.rate < 2000 || hwparams.rate > 256000)
return -1; return -1;
skipping to change at line 2393 skipping to change at line 2377
prg_exit(EXIT_FAILURE); prg_exit(EXIT_FAILURE);
} }
ofs -= chunk_bytes; ofs -= chunk_bytes;
} }
if (ofs) { if (ofs) {
if (safe_read(fd, buf, ofs) != ofs) { if (safe_read(fd, buf, ofs) != ofs) {
error(_("read error")); error(_("read error"));
prg_exit(EXIT_FAILURE); prg_exit(EXIT_FAILURE);
} }
} }
hwparams.format = default_format; hwparams.format = DEFAULT_FORMAT;
hwparams.channels = 1; hwparams.channels = 1;
hwparams.rate = DEFAULT_SPEED; hwparams.rate = DEFAULT_SPEED;
set_params(); set_params();
in_buffer = nextblock = 0; in_buffer = nextblock = 0;
while (!in_aborting) { while (!in_aborting) {
Fill_the_buffer: /* need this for repeat */ Fill_the_buffer: /* need this for repeat */
if (in_buffer < 32) { if (in_buffer < 32) {
/* move the rest of buffer to pos 0 and fill the buf up * / /* move the rest of buffer to pos 0 and fill the buf up * /
if (in_buffer) if (in_buffer)
 End of changes. 16 change blocks. 
37 lines changed or deleted 20 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)