- fix alsamixer bug which causes SEGFAULT when volume bar is changed.

- fix aplay for reading WAVE file properly even on big-endian machine.
This commit is contained in:
Takashi Iwai 2000-05-16 10:46:11 +00:00
parent 8bc5325f98
commit 3b5c5b2268
3 changed files with 25 additions and 14 deletions

View file

@ -1389,7 +1389,7 @@ mixer_set_delta(int delta)
{
int grp;
for (grp = 0; grp <= SND_MIXER_CHN_WOOFER; grp++)
for (grp = 0; grp < 2; grp++)
mixer_volume_delta[grp] = delta;
}
@ -1398,7 +1398,7 @@ mixer_add_delta(int delta)
{
int grp;
for (grp = 0; grp <= SND_MIXER_CHN_WOOFER; grp++)
for (grp = 0; grp < 2; grp++)
mixer_volume_delta[grp] += delta;
}

View file

@ -546,17 +546,17 @@ static int test_wavefile(void *buffer)
if (wp->main_chunk == WAV_RIFF && wp->chunk_type == WAV_WAVE &&
wp->sub_chunk == WAV_FMT && wp->data_chunk == WAV_DATA) {
if (wp->format != WAV_PCM_CODE) {
if (LE_SHORT(wp->format) != WAV_PCM_CODE) {
fprintf(stderr, "%s: can't play not PCM-coded WAVE-files\n", command);
exit(EXIT_FAILURE);
}
if (wp->modus < 1 || wp->modus > 32) {
if (LE_SHORT(wp->modus) < 1 || LE_SHORT(wp->modus) > 32) {
fprintf(stderr, "%s: can't play WAVE-files with %d tracks\n",
command, wp->modus);
exit(EXIT_FAILURE);
}
format.voices = wp->modus;
switch (wp->bit_p_spl) {
format.voices = LE_SHORT(wp->modus);
switch (LE_SHORT(wp->bit_p_spl)) {
case 8:
format.format = SND_PCM_SFMT_U8;
break;
@ -567,8 +567,8 @@ static int test_wavefile(void *buffer)
fprintf(stderr, "%s: can't play WAVE-files with sample %d bits wide\n",
command, wp->bit_p_spl);
}
format.rate = wp->sample_fq;
count = wp->data_length;
format.rate = LE_INT(wp->sample_fq);
count = LE_INT(wp->data_length);
check_new_format(&format);
return 0;
}
@ -726,7 +726,7 @@ void playback_write_error(void)
exit(EXIT_FAILURE);
}
if (status.status == SND_PCM_STATUS_XRUN) {
fprintf(stderr, "underrun at position %u!!!\n", status.pos_io);
printf("underrun at position %u!!!\n", status.pos_io);
if (snd_pcm_channel_prepare(pcm_handle, SND_PCM_CHANNEL_PLAYBACK)<0) {
fprintf(stderr, "underrun: playback channel prepare error\n");
exit(EXIT_FAILURE);
@ -752,7 +752,7 @@ void capture_read_error(void)
if (status.status == SND_PCM_STATUS_RUNNING)
return; /* everything is ok, but the driver is waiting for data */
if (status.status == SND_PCM_STATUS_XRUN) {
fprintf(stderr, "overrun at position %u!!!\n", status.pos_io);
printf("overrun at position %u!!!\n", status.pos_io);
if (snd_pcm_channel_prepare(pcm_handle, SND_PCM_CHANNEL_CAPTURE)<0) {
fprintf(stderr, "overrun: capture channel prepare error\n");
exit(EXIT_FAILURE);

View file

@ -2,6 +2,7 @@
#define FORMATS_H 1
#include <sys/types.h>
#include <byteswap.h>
/* Definitions for .VOC files */
@ -43,10 +44,20 @@ typedef struct voc_ext_block {
/* Definitions for Microsoft WAVE format */
#define WAV_RIFF 0x46464952
#define WAV_WAVE 0x45564157
#define WAV_FMT 0x20746D66
#define WAV_DATA 0x61746164
#ifdef SND_LITTLE_ENDIAN
#define COMPOSE_ID(a,b,c,d) ((a) | ((b)<<8) | ((c)<<16) | ((d)<<24))
#define LE_SHORT(v) (v)
#define LE_INT(v) (v)
#else
#define COMPOSE_ID(a,b,c,d) ((d) | ((c)<<8) | ((b)<<16) | ((a)<<24))
#define LE_SHORT(v) bswap_16(v)
#define LE_INT(v) bswap_32(v)
#endif
#define WAV_RIFF COMPOSE_ID('R','I','F','F')
#define WAV_WAVE COMPOSE_ID('W','A','V','E')
#define WAV_FMT COMPOSE_ID('f','m','t',' ')
#define WAV_DATA COMPOSE_ID('d','a','t','a')
#define WAV_PCM_CODE 1
/* it's in chunks like .voc and AMIGA iff, but my source say there