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;
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;
}
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);
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);
#define FORMATS_H 1
#include <sys/types.h>
+#include <byteswap.h>
/* Definitions for .VOC files */
/* 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