]> git.alsa-project.org Git - alsa-utils.git/commitdiff
- fix alsamixer bug which causes SEGFAULT when volume bar is changed.
authorTakashi Iwai <tiwai@suse.de>
Tue, 16 May 2000 10:46:11 +0000 (10:46 +0000)
committerTakashi Iwai <tiwai@suse.de>
Tue, 16 May 2000 10:46:11 +0000 (10:46 +0000)
- fix aplay for reading WAVE file properly even on big-endian machine.

alsamixer/alsamixer.c
aplay/aplay.c
aplay/formats.h

index 676019be2cea85e29bcb99b0730c6792d850312d..c2f05aec7800e399b9a274846a3c526156c6a937 100644 (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;
 }
 
index ba9df6e23b7a845c0caf132aacb6b46ce31bc835..3438d09be03271188a8d2eb23115530a5a590579 100644 (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);
index 7f41326f9f122267e0e958cc2cc78cc760d61b00..aa5b5afb789134a66f921c8c4ff10cc439c3f41a 100644 (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