[Alsaplayer-devel] ac3play (fwd)
Andy Lo A Foe
andy@alsa-project.org
Tue, 18 Jul 2000 19:52:24 +0200 (CEST)
This message is in MIME format. The first part should be readable text,
while the remaining parts are likely unreadable without MIME-aware tools.
Send mail to mime@docserver.cac.washington.edu for more info.
--------------AB037DB69C9A53638B1068EE
Content-Type: TEXT/PLAIN; CHARSET=US-ASCII
Content-ID: <Pine.LNX.4.21.0007181952132.16926@alsa.alsa-project.org>
--
AlsaPlayer, http://www.alsaplayer.org/
---------- Forwarded message ----------
Date: Sun, 16 Jul 2000 23:31:00 +0200
From: Abramo Bagnara <abramo@alsa-project.org>
To: andy@alsa-project.org
Subject: ac3play
I've ported ac3play-0.3.0 to current CVS.
Also:
- fixed a small bug for open fail.
- used frame mode (needed because you set a fragment size not available
on some cards)
- used AES0_PROFESSIONAL instead of AES0_CONSUMER (ice1712 seems to not
work with that)
Tested with Delta66 (ice1712) and Hammerfall Light (rme9652), egypt.ac3,
Sony STR-DB830 amplifier.
--
Abramo Bagnara mailto:abramo@alsa-project.org
Opera Unica
Via Emilia Interna, 140 Phone: +39.0546.656023
48014 Castel Bolognese (RA) - Italy Fax: +39.0546.656023
ALSA project is http://www.alsa-project.org
sponsored by SuSE Linux http://www.suse.com
It sounds good!
--------------AB037DB69C9A53638B1068EE
Content-Type: TEXT/PLAIN; CHARSET=us-ascii; NAME="ac3play.diff"
Content-ID: <Pine.LNX.4.21.0007181952133.16926@alsa.alsa-project.org>
Content-Description:
Content-Disposition: INLINE; FILENAME="ac3play.diff"
--- ac3play-0.3.0/ac3_pack.c.~1~ Tue Jun 6 09:59:22 2000
+++ ac3play-0.3.0/ac3_pack.c Sun Jul 16 23:22:18 2000
@@ -42,11 +42,11 @@
static syncinfo_t syncinfo;
static char *sbuffer = &buf[10];
-static int pcm_mode = SND_PCM_MODE_FRAGMENT;
+static int pcm_mode = SND_PCM_MODE_FRAME;
static FILE *bla2;
static snd_pcm_t *handle;
-static snd_pcm_stream_status_t status;
-static snd_pcm_stream_setup_t setup;
+static snd_pcm_status_t status;
+static snd_pcm_setup_t setup;
static stream = SND_PCM_STREAM_PLAYBACK;
uint_32
@@ -168,15 +168,15 @@
} while (status.bytes_free < BLOCK_SIZE);
#endif
- snd_pcm_write(handle, buf, BLOCK_SIZE);
+ snd_pcm_write(handle, buf, BLOCK_SIZE / 4);
memset(&status, 0, sizeof(status));
- snd_pcm_stream_status(handle, &status);
+ snd_pcm_status(handle, &status);
if (status.xruns) {
fprintf(stderr, "underrun, resetting stream\n");
- snd_pcm_stream_flush(handle, stream);
- snd_pcm_stream_prepare(handle, stream);
- snd_pcm_write(handle, buf, BLOCK_SIZE);
- snd_pcm_stream_status(handle, &status);
+ snd_pcm_flush(handle);
+ snd_pcm_prepare(handle);
+ snd_pcm_write(handle, buf, BLOCK_SIZE / 4);
+ snd_pcm_status(handle, &status);
if (status.xruns) {
fprintf(stderr, "still underrun, give up\n");
return;
@@ -188,18 +188,18 @@
uint_32
spdif_init(int acard, int adevice)
{
- snd_pcm_stream_info_t info;
- snd_pcm_digital_t digital;
- snd_pcm_stream_params_t params;
+ snd_pcm_info_t info;
+ snd_pcm_digital_t digital;
+ snd_pcm_params_t params;
int err, c;
- if ((err = snd_pcm_open(&handle, acard, adevice, SND_PCM_OPEN_PLAYBACK)) < 0)
+ if ((err = snd_pcm_plug_open(&handle, acard, adevice, SND_PCM_STREAM_PLAYBACK, 0)) < 0)
{
fprintf(stderr, "open: %s\n", snd_strerror(err));
return 1;
}
memset(&info, 0, sizeof(info));
- if ((err = snd_pcm_stream_info(handle, &info)) < 0) {
+ if ((err = snd_pcm_info(handle, &info)) < 0) {
fprintf(stderr, "info: %s\n", snd_strerror(err));
snd_pcm_close(handle);
return 1;
@@ -219,81 +219,71 @@
memset(&setup, 0, sizeof(setup));
memset(¶ms, 0, sizeof(params));
params.mode = pcm_mode;
- params.stream = stream;
params.start_mode = SND_PCM_START_FULL;
params.xrun_mode = SND_PCM_XRUN_FLUSH;
- params.frag_size = BLOCK_SIZE;
- params.buffer_size = BLOCK_SIZE * 6;
-#if 1
+ params.frag_size = BLOCK_SIZE / 4;
+ params.buffer_size = BLOCK_SIZE / 4 * 6;
params.digital.valid = 1;
params.digital.dig.aes.status[0] = SND_PCM_AES0_NONAUDIO;
+#if 1
+ params.digital.dig.aes.status[0] |= SND_PCM_AES0_PROFESSIONAL;
+ params.digital.dig.aes.status[0] |= SND_PCM_AES0_PRO_FS_48000;
+#else
params.digital.dig.aes.status[3] = SND_PCM_AES3_CON_FS_48000;
#endif
params.format.format = SND_PCM_SFMT_S16_LE;
params.format.rate = 48000;
params.format.interleave = 1;
params.format.channels = 2;
- snd_pcm_stream_flush(handle, stream);
+ snd_pcm_flush(handle);
- if ((err = snd_pcm_stream_params(handle, ¶ms)) < 0) {
+ if ((err = snd_pcm_params(handle, ¶ms)) < 0) {
fprintf(stderr, "params: %s\n", snd_strerror(err));
snd_pcm_close(handle);
return 3;
}
-#if 0
- setup.digital.valid = 1;
- setup.digital.dig.aes.status[0] = SND_PCM_DIG0_NONAUDIO;
- setup.digital.dig.aes.status[3] = SND_PCM_DIG3_CON_FS_48000;
-#endif
- setup.mode = pcm_mode;
- setup.stream = stream;
- if ((err = snd_pcm_stream_prepare(handle, stream)) < 0) {
+ if ((err = snd_pcm_prepare(handle)) < 0) {
fprintf(stderr, "prepare: %s\n", snd_strerror(err));
return 2;
}
- if ((err = snd_pcm_stream_setup(handle, &setup)) < 0) {
- fprintf(stderr, "setup: %s\n", snd_strerror(err));
- snd_pcm_close(handle);
- return 2;
- }
memset(buf, 0, sizeof(buf));
// Send some trailing zeros to avoid misdetecting the
// first frame as PCM (works for DTT2500 at least)
for (c=0; c < 0; c++) {
- if ((snd_pcm_write(handle, buf, BLOCK_SIZE)) < 0) {
+ if ((snd_pcm_write(handle, buf, BLOCK_SIZE / 4)) < 0) {
fprintf(stderr, "error in initial write\n");
exit(2);
}
- if ((err=snd_pcm_stream_status(handle, &status)) < 0) {
- fprintf(stderr, "cannot get stream status: %s\n", snd_strerror(err));
- }
- //snd_pcm_stream_prepare(handle, SND_PCM_CHANNEL_PLAYBACK);
-
- switch (status.status) {
- case SND_PCM_STATUS_NOTREADY:
- fprintf(stderr, "status: NOTREADY\n");
- break;
- case SND_PCM_STATUS_READY:
- fprintf(stderr, "status: READY\n");
- break;
- case SND_PCM_STATUS_PREPARED:
- snd_pcm_playback_go(handle);
- fprintf(stderr, "status: PREPARED\n");
- break;
- case SND_PCM_STATUS_RUNNING:
- fprintf(stderr, "status: RUNNING\n");
- break;
- case SND_PCM_STATUS_XRUN:
- fprintf(stderr, "status: XRUN\n");
- break;
- case SND_PCM_STATUS_PAUSED:
- fprintf(stderr, "status: PAUSED\n");
- break;
- }
- fprintf(stderr, "bytes available: %d\n",
- status.bytes_avail);
+ if ((err=snd_pcm_status(handle, &status)) < 0) {
+ fprintf(stderr, "cannot get stream status: %s\n", snd_strerror(err));
+ }
+ //snd_pcm_stream_prepare(handle, SND_PCM_CHANNEL_PLAYBACK);
+
+ switch (status.state) {
+ case SND_PCM_STATE_NOTREADY:
+ fprintf(stderr, "status: NOTREADY\n");
+ break;
+ case SND_PCM_STATE_READY:
+ fprintf(stderr, "status: READY\n");
+ break;
+ case SND_PCM_STATE_PREPARED:
+ snd_pcm_go(handle);
+ fprintf(stderr, "status: PREPARED\n");
+ break;
+ case SND_PCM_STATE_RUNNING:
+ fprintf(stderr, "status: RUNNING\n");
+ break;
+ case SND_PCM_STATE_XRUN:
+ fprintf(stderr, "status: XRUN\n");
+ break;
+ case SND_PCM_STATE_PAUSED:
+ fprintf(stderr, "status: PAUSED\n");
+ break;
+ }
+ fprintf(stderr, "frames available: %d\n",
+ status.frames_avail);
}
return 0;
}
--- ac3play-0.3.0/ac3play.c.~1~ Mon Jun 5 07:54:36 2000
+++ ac3play-0.3.0/ac3play.c Sun Jul 16 23:18:10 2000
@@ -72,8 +72,10 @@
return 1;
}
- if (spdif_init(acard, adevice) != 0)
+ if (spdif_init(acard, adevice) != 0) {
fprintf(stderr, "error openning digital output\n");
+ return 1;
+ }
// Read the whole file
--------------AB037DB69C9A53638B1068EE--