ref: 8a650e62ae71e60f93db0e493967dcb119df77b8
parent: 6bda4b061da31dce799b4b56a39b20f8942026e5
author: Erik de Castro Lopo <erikd@mingus>
date: Wed Jul 12 08:07:10 EDT 2006
audio_out.c : Be more explicit about setting the audio output format.
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2006-07-12 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+
+ * examples/audio_out.c
+ Be more explicit about setting the audio output format.
+
2006-06-06 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
* src/samplerate.c src/src_linear.c src/src_sinc.c
--- a/examples/audio_out.c
+++ b/examples/audio_out.c
@@ -63,7 +63,7 @@
static AUDIO_OUT *
linux_open (int channels, int samplerate)
{ LINUX_AUDIO_OUT *linux_out ;
- int stereo, temp, error ;
+ int stereo, fmt, error ;
if ((linux_out = malloc (sizeof (LINUX_AUDIO_OUT))) == NULL)
{ perror ("linux_open : malloc ") ;
@@ -90,11 +90,11 @@
exit (1) ;
} ;
- temp = 16 ;
- if ((error = ioctl (linux_out->fd, SOUND_PCM_WRITE_BITS, &temp)) != 0)
- { perror ("linux_open : bitwidth ") ;
- exit (1) ;
- } ;
+ fmt = CPU_IS_BIG_ENDIAN ? AFMT_S16_BE : AFMT_S16_LE ;
+ if (ioctl (fd, SOUND_PCM_SETFMT, &fmt) != 0)
+ { perror ("linux_open_dsp_device : set format ") ;
+ exit (1) ;
+ } ;
if ((error = ioctl (linux_out->fd, SOUND_PCM_WRITE_CHANNELS, &channels)) != 0)
{ perror ("linux_open : channels ") ;