[linux-dvb] AC3 support for szap with firmware 0x2622
Dr. Werner Fink
werner at suse.de
Mon Dec 12 18:07:12 CET 2005
On Sat, Dec 10, 2005 at 07:56:20PM +0100, Johannes Stezenbach wrote:
> On Wed, Dec 07, 2005, Dr. Werner Fink wrote:
> > just a few changes to the current szap found in the CVS of
> > linuxtv.org to support TV channels with AC3 audio channels.
>
> > + if ((audiofd = open(auddev, O_RDWR)) < 0) {
> > perror("opening audio demux failed");
> > - close(videofd);
> > + close(dmxfd);
> > close(fefd);
> > return FALSE;
> > }
>
> It seems you open the audio device unconditionally which makes
> this patch incompatible with budget cards.
>
> Can you fix that up?
Hopefully it is OK to test for dvr == 0 and use audiofd == -1 to detect
failed opening of the audio device. I've also added a patch for some
cleanings to test_audio.c, test_front.c , test_switch.c, and
test_video.c in a second patch.
-------------------------------* snip *---------------------------------
--- util/szap/szap.c
+++ util/szap/szap.c 2005-12-12 12:51:40.000000000 +0100
@@ -46,6 +46,7 @@
#include <linux/dvb/frontend.h>
#include <linux/dvb/dmx.h>
+#include <linux/dvb/audio.h>
#include "lnb.h"
#ifndef TRUE
@@ -65,6 +66,7 @@
#define FRONTENDDEVICE "/dev/dvb/adapter%d/frontend%d"
#define DEMUXDEVICE "/dev/dvb/adapter%d/demux%d"
+#define AUDIODEVICE "/dev/dvb/adapter%d/audio%d"
static struct lnb_types_st lnb_type;
@@ -80,6 +82,7 @@
" -f number : use given frontend (default 0)\n"
" -d number : use given demux (default 0)\n"
" -c file : read channels list from 'file'\n"
+ " -b : enable Audio Bypass (default no)\n"
" -x : exit after tuning\n"
" -r : set up /dev/dvb/adapterX/dvr0 for TS recording\n"
" -l lnb-type (DVB-S Only) (use -l help to print types) or \n"
@@ -292,10 +295,10 @@
int zap_to(unsigned int adapter, unsigned int frontend, unsigned int demux,
unsigned int sat_no, unsigned int freq, unsigned int pol,
unsigned int sr, unsigned int vpid, unsigned int apid, int sid,
- int dvr, int rec_psi)
+ int dvr, int rec_psi, int bypass)
{
- char fedev[128], dmxdev[128];
- static int fefd, videofd, audiofd, patfd, pmtfd;
+ char fedev[128], dmxdev[128], auddev[128];
+ static int fefd, dmxfd, audiofd = -1, patfd, pmtfd;
int pmtpid;
uint32_t ifreq;
int hiband, result;
@@ -304,6 +307,7 @@
if (!fefd) {
snprintf(fedev, sizeof(fedev), FRONTENDDEVICE, adapter, frontend);
snprintf(dmxdev, sizeof(dmxdev), DEMUXDEVICE, adapter, demux);
+ snprintf(auddev, sizeof(auddev), AUDIODEVICE, adapter, demux);
printf("using '%s' and '%s'\n", fedev, dmxdev);
if ((fefd = open(fedev, O_RDWR | O_NONBLOCK)) < 0) {
@@ -325,24 +329,20 @@
return FALSE;
}
- if ((videofd = open(dmxdev, O_RDWR)) < 0) {
+ if ((dmxfd = open(dmxdev, O_RDWR)) < 0) {
perror("opening video demux failed");
close(fefd);
return FALSE;
}
- if ((audiofd = open(dmxdev, O_RDWR)) < 0) {
- perror("opening audio demux failed");
- close(videofd);
- close(fefd);
- return FALSE;
- }
+ if (dvr == 0) /* DMX_OUT_DECODER */
+ audiofd = open(auddev, O_RDWR);
if (rec_psi){
if ((patfd = open(dmxdev, O_RDWR)) < 0) {
perror("opening audio demux failed");
close(audiofd);
- close(videofd);
+ close(dmxfd);
close(fefd);
return FALSE;
}
@@ -351,7 +351,7 @@
perror("opening audio demux failed");
close(patfd);
close(audiofd);
- close(videofd);
+ close(dmxfd);
close(fefd);
return FALSE;
}
@@ -375,8 +375,10 @@
if (diseqc(fefd, sat_no, pol, hiband))
if (do_tune(fefd, ifreq, sr))
- if (set_demux(videofd, vpid, DMX_PES_VIDEO, dvr))
- if (set_demux(audiofd, apid, DMX_PES_AUDIO, dvr)) {
+ if (set_demux(dmxfd, vpid, DMX_PES_VIDEO, dvr))
+ if (audiofd >= 0)
+ (void)ioctl(audiofd, AUDIO_SET_BYPASS_MODE, bypass);
+ if (set_demux(dmxfd, apid, DMX_PES_AUDIO, dvr)) {
if (rec_psi) {
pmtpid = get_pmt_pid(dmxdev, sid);
if (pmtpid < 0) {
@@ -399,8 +401,9 @@
if (!interactive) {
close(patfd);
close(pmtfd);
- close(audiofd);
- close(videofd);
+ if (audiofd >= 0)
+ close(audiofd);
+ close(dmxfd);
close(fefd);
}
@@ -411,7 +414,8 @@
static int read_channels(const char *filename, int list_channels,
uint32_t chan_no, const char *chan_name,
unsigned int adapter, unsigned int frontend,
- unsigned int demux, int dvr, int rec_psi)
+ unsigned int demux, int dvr, int rec_psi,
+ int bypass)
{
FILE *cfp;
char buf[4096];
@@ -504,6 +508,18 @@
if (!(field = strsep(&tmp, ":")))
goto syntax_err;
+ p = strchr(field, ';');
+
+ if (p) {
+ *p = '\0';
+ p++;
+ if (bypass) {
+ if (!p || !*p)
+ goto syntax_err;
+ field = p;
+ }
+ }
+
apid = strtoul(field, NULL, 0);
if (!apid)
apid = 0x1fff;
@@ -519,8 +535,8 @@
fclose(cfp);
- ret = zap_to(adapter, frontend, demux,
- sat_no, freq * 1000, pol, sr, vpid, apid, sid, dvr, rec_psi);
+ ret = zap_to(adapter, frontend, demux, sat_no, freq * 1000,
+ pol, sr, vpid, apid, sid, dvr, rec_psi, bypass);
if (interactive)
goto again;
@@ -584,16 +600,20 @@
unsigned int chan_no = 0;
const char *chan_name = NULL;
unsigned int adapter = 0, frontend = 0, demux = 0, dvr = 0, rec_psi = 0;
+ int bypass = 0;
int opt, copt = 0;
lnb_type = *lnb_enum(0);
- while ((opt = getopt(argc, argv, "hqrpn:a:f:d:c:l:xi")) != -1) {
+ while ((opt = getopt(argc, argv, "hqrpn:a:f:d:c:l:xib")) != -1) {
switch (opt)
{
case '?':
case 'h':
default:
bad_usage(argv[0], 0);
+ case 'b':
+ bypass = 1;
+ break;
case 'q':
list_channels = 1;
break;
@@ -669,7 +689,7 @@
dvr=1;
if (!read_channels(chanfile, list_channels, chan_no, chan_name,
- adapter, frontend, demux, dvr, rec_psi))
+ adapter, frontend, demux, dvr, rec_psi, bypass))
return TRUE;
return FALSE;
-------------------------------* snap *---------------------------------
-------------------------------* snip *---------------------------------
--- test/test_audio.c
+++ test/test_audio.c 2005-12-12 18:02:22.000000000 +0100
@@ -40,7 +40,7 @@
{
int ans;
- if ( (ans = ioctl(fd,AUDIO_STOP,0) < 0)){
+ if ((ans = ioctl(fd,AUDIO_STOP,0)) < 0) {
perror("AUDIO STOP: ");
return -1;
}
@@ -52,7 +52,7 @@
{
int ans;
- if ( (ans = ioctl(fd,AUDIO_PLAY) < 0)){
+ if ((ans = ioctl(fd,AUDIO_PLAY)) < 0) {
perror("AUDIO PLAY: ");
return -1;
}
@@ -65,7 +65,7 @@
{
int ans;
- if ( (ans = ioctl(fd,AUDIO_PAUSE) < 0)){
+ if ((ans = ioctl(fd,AUDIO_PAUSE)) < 0) {
perror("AUDIO PAUSE: ");
return -1;
}
@@ -78,7 +78,7 @@
{
int ans;
- if ( (ans = ioctl(fd,AUDIO_CONTINUE) < 0)){
+ if ((ans = ioctl(fd,AUDIO_CONTINUE)) < 0) {
perror("AUDIO CONTINUE: ");
return -1;
}
@@ -90,7 +90,7 @@
{
int ans;
- if ( (ans = ioctl(fd,AUDIO_SELECT_SOURCE, source) < 0)){
+ if ((ans = ioctl(fd,AUDIO_SELECT_SOURCE, source)) < 0) {
perror("AUDIO SELECT SOURCE: ");
return -1;
}
@@ -104,7 +104,7 @@
{
int ans;
- if ( (ans = ioctl(fd,AUDIO_SET_MUTE, state) < 0)){
+ if ((ans = ioctl(fd,AUDIO_SET_MUTE, state)) < 0) {
perror("AUDIO SET MUTE: ");
return -1;
}
@@ -116,7 +116,7 @@
{
int ans;
- if ( (ans = ioctl(fd,AUDIO_SET_AV_SYNC, state) < 0)){
+ if ((ans = ioctl(fd,AUDIO_SET_AV_SYNC, state)) < 0) {
perror("AUDIO SET AV SYNC: ");
return -1;
}
@@ -128,8 +128,8 @@
{
int ans;
- if ( (ans = ioctl(fd,AUDIO_SET_BYPASS_MODE, mode) < 0)){
- perror("AUDIO SET BYPASS MODE: ");
+ if ((ans = ioctl(fd,AUDIO_SET_BYPASS_MODE, mode)) < 0) {
+ printf("AUDIO SET BYPASS MODE not implemented?\n");
return -1;
}
@@ -141,7 +141,7 @@
{
int ans;
- if ( (ans = ioctl(fd,AUDIO_CHANNEL_SELECT, select) < 0)){
+ if ((ans = ioctl(fd,AUDIO_CHANNEL_SELECT, select)) < 0) {
perror("AUDIO CHANNEL SELECT: ");
return -1;
}
@@ -154,7 +154,7 @@
struct audio_status stat;
int ans;
- if ( (ans = ioctl(fd,AUDIO_GET_STATUS, &stat) < 0)){
+ if ((ans = ioctl(fd,AUDIO_GET_STATUS, &stat)) < 0) {
perror("AUDIO GET STATUS: ");
return -1;
}
@@ -321,7 +321,7 @@
audioSetMute(fd,mute);
- // audioSetBypassMode(fd,false); // not implemented
+ audioSetBypassMode(fd,false);
//audioContinue(fd);
audioSelectSource(fd,AUDIO_SOURCE_MEMORY);
audioPlay(fd);
--- test/test_front.c
+++ test/test_front.c 2005-12-12 12:43:00.000000000 +0100
@@ -40,7 +40,7 @@
{
int ans;
- if ( (ans = ioctl(fd,OST_SELFTEST,0) < 0)){
+ if ((ans = ioctl(fd,OST_SELFTEST,0)) < 0) {
perror("OST SELF TEST: ");
return -1;
}
@@ -52,7 +52,7 @@
{
int ans;
- if ( (ans = ioctl(fd,OST_SET_POWER_STATE,state) < 0)){
+ if ((ans = ioctl(fd,OST_SET_POWER_STATE,state)) < 0) {
perror("OST SET POWER STATE: ");
return -1;
}
@@ -64,7 +64,7 @@
{
int ans;
- if ( (ans = ioctl(fd,OST_GET_POWER_STATE,state) < 0)){
+ if ((ans = ioctl(fd,OST_GET_POWER_STATE,state)) < 0) {
perror("OST GET POWER STATE: ");
return -1;
}
@@ -95,7 +95,7 @@
int ans;
feStatus stat;
- if ( (ans = ioctl(fd,FE_READ_STATUS,&stat) < 0)){
+ if ((ans = ioctl(fd,FE_READ_STATUS,&stat)) < 0) {
perror("FE READ STATUS: ");
return -1;
}
@@ -116,7 +116,7 @@
{
int ans;
- if ( (ans = ioctl(fd,FE_READ_BER, ber) < 0)){
+ if ((ans = ioctl(fd,FE_READ_BER, ber)) < 0) {
perror("FE READ_BER: ");
return -1;
}
@@ -129,7 +129,7 @@
{
int ans;
- if ( (ans = ioctl(fd,FE_READ_SIGNAL_STRENGTH, strength) < 0)){
+ if ((ans = ioctl(fd,FE_READ_SIGNAL_STRENGTH, strength)) < 0) {
perror("FE READ SIGNAL STRENGTH: ");
return -1;
}
@@ -142,7 +142,7 @@
{
int ans;
- if ( (ans = ioctl(fd,FE_READ_SNR, snr) < 0)){
+ if ((ans = ioctl(fd,FE_READ_SNR, snr)) < 0) {
perror("FE READ_SNR: ");
return -1;
}
@@ -156,7 +156,7 @@
{
int ans;
- if ( (ans = ioctl(fd,FE_READ_UNCORRECTED_BLOCKS, ucb) < 0)){
+ if ((ans = ioctl(fd,FE_READ_UNCORRECTED_BLOCKS, ucb)) < 0) {
perror("FE READ UNCORRECTED BLOCKS: ");
return -1;
}
@@ -169,7 +169,7 @@
{
int ans;
- if ( (ans = ioctl(fd,FE_GET_NEXT_FREQUENCY, nfr) < 0)){
+ if ((ans = ioctl(fd,FE_GET_NEXT_FREQUENCY, nfr)) < 0) {
perror("FE GET NEXT FREQUENCY: ");
return -1;
}
@@ -182,7 +182,7 @@
{
int ans;
- if ( (ans = ioctl(fd,FE_GET_NEXT_SYMBOL_RATE, nsr) < 0)){
+ if ((ans = ioctl(fd,FE_GET_NEXT_SYMBOL_RATE, nsr)) < 0) {
perror("FE GET NEXT SYMBOL RATE: ");
return -1;
}
@@ -195,7 +195,7 @@
{
int ans;
- if ( (ans = ioctl(fd,QPSK_TUNE, param) < 0)){
+ if ((ans = ioctl(fd,QPSK_TUNE, param)) < 0) {
perror("QPSK TUNE: ");
return -1;
}
@@ -207,7 +207,7 @@
{
int ans;
- if ( (ans = ioctl(fd,QPSK_GET_EVENT, event) < 0)){
+ if ((ans = ioctl(fd,QPSK_GET_EVENT, event)) < 0) {
perror("QPSK GET EVENT: ");
return -1;
}
@@ -219,7 +219,7 @@
{
int ans;
- if ( (ans = ioctl(fd,QPSK_FE_INFO, info) < 0)){
+ if ((ans = ioctl(fd,QPSK_FE_INFO, info)) < 0) {
perror("QPSK FE INFO: ");
return -1;
}
@@ -238,7 +238,7 @@
{
int ans;
- if ( (ans = ioctl(fd,SEC_GET_STATUS, state) < 0)){
+ if ((ans = ioctl(fd,SEC_GET_STATUS, state)) < 0) {
perror("QPSK GET EVENT: ");
return -1;
}
--- test/test_switch.c
+++ test/test_switch.c 2005-12-12 12:43:19.000000000 +0100
@@ -248,7 +248,7 @@
{
int ans;
- if ( (ans = ioctl(fd,FE_READ_STATUS,stat) < 0)){
+ if ((ans = ioctl(fd,FE_READ_STATUS,stat)) < 0) {
perror("FE READ STATUS: ");
return -1;
}
--- test/test_video.c
+++ test/test_video.c 2005-12-12 12:43:34.000000000 +0100
@@ -40,7 +40,7 @@
{
int ans;
- if ( (ans = ioctl(fd,VIDEO_STOP,0) < 0)){
+ if ((ans = ioctl(fd,VIDEO_STOP,0)) < 0) {
perror("VIDEO STOP: ");
return -1;
}
@@ -52,7 +52,7 @@
{
int ans;
- if ( (ans = ioctl(fd,VIDEO_PLAY) < 0)){
+ if ((ans = ioctl(fd,VIDEO_PLAY)) < 0) {
perror("VIDEO PLAY: ");
return -1;
}
@@ -65,7 +65,7 @@
{
int ans;
- if ( (ans = ioctl(fd,VIDEO_FREEZE) < 0)){
+ if ((ans = ioctl(fd,VIDEO_FREEZE)) < 0) {
perror("VIDEO FREEZE: ");
return -1;
}
@@ -78,7 +78,7 @@
{
int ans;
- if ( (ans = ioctl(fd,VIDEO_CONTINUE) < 0)){
+ if ((ans = ioctl(fd,VIDEO_CONTINUE)) < 0) {
perror("VIDEO CONTINUE: ");
return -1;
}
@@ -90,7 +90,7 @@
{
int ans;
- if ( (ans = ioctl(fd,VIDEO_SELECT_SOURCE, source) < 0)){
+ if ((ans = ioctl(fd,VIDEO_SELECT_SOURCE, source)) < 0) {
perror("VIDEO SELECT SOURCE: ");
return -1;
}
@@ -104,7 +104,7 @@
{
int ans;
- if ( (ans = ioctl(fd,VIDEO_SET_BLANK, state) < 0)){
+ if ((ans = ioctl(fd,VIDEO_SET_BLANK, state)) < 0) {
perror("VIDEO SET BLANK: ");
return -1;
}
@@ -116,7 +116,7 @@
{
int ans;
- if ( (ans = ioctl(fd,VIDEO_FAST_FORWARD, nframes) < 0)){
+ if ((ans = ioctl(fd,VIDEO_FAST_FORWARD, nframes)) < 0) {
perror("VIDEO FAST FORWARD: ");
return -1;
}
@@ -128,7 +128,7 @@
{
int ans;
- if ( (ans = ioctl(fd,VIDEO_SLOWMOTION, nframes) < 0)){
+ if ((ans = ioctl(fd,VIDEO_SLOWMOTION, nframes)) < 0) {
perror("VIDEO SLOWMOTION: ");
return -1;
}
@@ -141,7 +141,7 @@
struct video_status stat;
int ans;
- if ( (ans = ioctl(fd,VIDEO_GET_STATUS, &stat) < 0)){
+ if ((ans = ioctl(fd,VIDEO_GET_STATUS, &stat)) < 0) {
perror("VIDEO GET STATUS: ");
return -1;
}
@@ -213,7 +213,7 @@
{
int ans;
- if ( (ans = ioctl(fd,VIDEO_STILLPICTURE, sp) < 0)){
+ if ((ans = ioctl(fd,VIDEO_STILLPICTURE, sp)) < 0) {
perror("VIDEO STILLPICTURE: ");
return -1;
}
-------------------------------* snap *---------------------------------
Werner
--
AC3 loop through sound card http://bitstreamout.sourceforge.net/
Howto http://www.vdr-portal.de/board/thread.php?threadid=1958
------------------------------------------------------------------
"Having a smoking section in a restaurant is like having
a peeing section in a swimming pool." -- Edward Burr
More information about the linux-dvb
mailing list