On Tue, 7 Jan 2003, Troy Benjegerdes wrote:
> On Tue, Jan 07, 2003 at 05:02:53PM +0100, Takashi Iwai wrote:
> > At Thu, 2 Jan 2003 22:22:34 -0600,
> > Troy Benjegerdes wrote:
> > >
> > > I have a mac G4 (running debian testing), a ymfpci card (MaxiSound
> > > Fortissimo) with optical TOSlink out, and a yamaha HTR-5540 receiver with
> > > digital optical TOSlink input.
> > >
> > > I'm trying to get xine or some other DVD player to output AC/3 sound to
> > > the receiver for watching dvd's, and I have a couple of problems.
> > >
> > > 1) xmms (and xine 2-channel sound) works with OSS emulation, but is static
> > > with native ALSA drivers. This seems like some endian problem
> >
> > then most likely it's a bug of alsa output plugin.
>
> It seems the latest xmms source uses 'S16_NE' (which is S16_BE on
> big-endian platforms) as the pcm format, which works correctly.
>
> alsa-tools/acdec/output.c also has a problem.. it uses S16_LE on
> big-endian platforms.
>
> I am able to successfully open the SPDIF output and output *something*
> with a commandline like:
>
> ac3dec -D hw:0,0 -C THX.ac3
>
> However, the hardware decoder (yamaha receiver) is getting garbled data
> and plays what sounds like stacatto static.
>
> ac3dec -C THX.ac3 gives the following:
>
> Using PCM device 'iec958:AES0=0x2,AES1=0x82,AES2=0x0,AES3=0x2'
> ALSA lib pcm_hw.c:292:(snd_pcm_hw_hw_params) SNDRV_PCM_IOCTL_HW_PARAMS
> failed: No such device or address
> PCM hw_params failed: No such device or address
> Output open failed
>
> Another interesting bit...
> If I change S16_LE to S16_BE in output.c, now it works with regular 2
> channel audio, but anything with the '-C' option gives:
>
> Using PCM device 'hw:0,0'
> Sample format non availableOutput open failed
>
> Using PCM device 'iec958:AES0=0x2,AES1=0x82,AES2=0x0,AES3=0x2'
> Sample format non availableOutput open failed
>
>
> Should the alsa drive be able to byteswap SPDIF data??
There were a few bad assumtions in the spdif code. Could you try the
latest CVS code of ac3dec (or attached patch)?
Jaroslav
-----
Jaroslav Kysela <[EMAIL PROTECTED]>
Linux Kernel Sound Maintainer
ALSA Project, SuSE Labs
? out.txt
Index: ac3spdif.c
===================================================================
RCS file: /cvsroot/alsa/alsa-tools/ac3dec/ac3spdif.c,v
retrieving revision 1.3
diff -u -r1.3 ac3spdif.c
--- ac3spdif.c 6 Aug 2001 16:08:01 -0000 1.3
+++ ac3spdif.c 8 Jan 2003 11:28:48 -0000
@@ -154,7 +154,7 @@
done_banner = 1;
}
-#ifndef WORDS_BIGENDIAN
+#ifndef _a_b_c_d_e_f /* WORDS_BIGENDIAN */
// extract_ac3 seems to write swabbed data
swab(&buf[10], &buf[10], syncinfo.frame_size * 2 - 2);
#endif
Index: output.c
===================================================================
RCS file: /cvsroot/alsa/alsa-tools/ac3dec/output.c,v
retrieving revision 1.17
diff -u -r1.17 output.c
--- output.c 22 Oct 2002 18:01:16 -0000 1.17
+++ output.c 8 Jan 2003 11:28:48 -0000
@@ -41,6 +41,7 @@
char devstr[128];
snd_pcm_hw_params_t *params;
unsigned int rate, buffer_time, period_time, tmp;
+ snd_pcm_format_t format = output->bits == 16 ? SND_PCM_FORMAT_S16 :
+SND_PCM_FORMAT_U8;
int err, step;
snd_pcm_hw_params_alloca(¶ms);
@@ -76,6 +77,7 @@
sprintf(devstr,
"iec958:AES0=0x%x,AES1=0x%x,AES2=0x%x,AES3=0x%x", s[0], s[1], s[2], s[3]);
if (out_config.card)
sprintf(devstr + strlen(devstr), ",CARD=%s",
out_config.card);
+ format = SND_PCM_FORMAT_S16_LE;
} else {
if (out_config.card)
sprintf(devstr, "plughw:%s", out_config.card);
@@ -114,29 +116,29 @@
err = snd_pcm_hw_params_set_access(pcm, params,
SND_PCM_ACCESS_RW_INTERLEAVED);
if (err < 0) {
- fprintf(stderr, "Access type not available");
+ fprintf(stderr, "Access type not available\n");
goto __close;
}
- err = snd_pcm_hw_params_set_format(pcm, params, output->bits == 16 ?
SND_PCM_FORMAT_S16_LE : SND_PCM_FORMAT_U8);
+ err = snd_pcm_hw_params_set_format(pcm, params, format);
if (err < 0) {
- fprintf(stderr, "Sample format non available");
+ fprintf(stderr, "Sample format non available\n");
goto __close;
}
err = snd_pcm_hw_params_set_channels(pcm, params, output->channels);
if (err < 0) {
- fprintf(stderr, "Channels count non available");
+ fprintf(stderr, "Channels count non available\n");
goto __close;
}
rate = output->rate;
err = snd_pcm_hw_params_set_rate_near(pcm, params, &rate, 0);
if (err < 0) {
- fprintf(stderr, "Rate not available");
+ fprintf(stderr, "Rate not available\n");
goto __close;
}
buffer_time = 500000;
err = snd_pcm_hw_params_set_buffer_time_near(pcm, params, &buffer_time, 0);
if (err < 0) {
- fprintf(stderr, "Buffer time not available");
+ fprintf(stderr, "Buffer time not available\n");
goto __close;
}
step = 2;
@@ -146,7 +148,7 @@
tmp = period_time;
err = snd_pcm_hw_params_set_period_time_near(pcm, params, &tmp, 0);
if (err < 0) {
- fprintf(stderr, "Period time not available");
+ fprintf(stderr, "Period time not available\n");
goto __close;
}
if (tmp == period_time) {