d11f853ac6
ok biorn@ (MAINTAINER), ajacoutot@, brad@
201 lines
5.0 KiB
Plaintext
201 lines
5.0 KiB
Plaintext
$OpenBSD: patch-stream_tvi_bsdbt848_c,v 1.1 2008/02/08 17:32:42 jakemsr Exp $
|
|
--- stream/tvi_bsdbt848.c.orig Sun Oct 7 12:49:26 2007
|
|
+++ stream/tvi_bsdbt848.c Mon Dec 17 14:49:10 2007
|
|
@@ -36,6 +36,7 @@
|
|
#include <sys/time.h>
|
|
#include <signal.h>
|
|
#include <string.h>
|
|
+#include <errno.h>
|
|
|
|
#include <sys/param.h>
|
|
#ifdef USE_SUN_AUDIO
|
|
@@ -50,6 +51,7 @@
|
|
#include IOCTL_BT848_H_NAME
|
|
#endif
|
|
|
|
+#ifndef __OpenBSD__
|
|
#ifdef HAVE_SYS_SOUNDCARD_H
|
|
#include <sys/soundcard.h>
|
|
#else
|
|
@@ -59,6 +61,7 @@
|
|
#include <machine/soundcard.h>
|
|
#endif
|
|
#endif
|
|
+#endif
|
|
|
|
#include "libaf/af_format.h"
|
|
#include "libmpcodecs/img_format.h"
|
|
@@ -141,9 +144,14 @@ typedef struct {
|
|
|
|
#include "tvi_def.h"
|
|
|
|
+static int sources[6] = { METEOR_INPUT_DEV1, METEOR_INPUT_DEV0, METEOR_INPUT_DEV2,
|
|
+ METEOR_INPUT_DEV3, METEOR_INPUT_DEV_RGB, METEOR_INPUT_DEV_SVIDEO };
|
|
+
|
|
+
|
|
static priv_t *G_private=NULL;
|
|
|
|
static int getinput(int innumber);
|
|
+static int getsource(int insrc);
|
|
|
|
static void processframe(int signal)
|
|
{
|
|
@@ -314,7 +322,14 @@ static int control(priv_t *priv, int cmd, void *arg)
|
|
{
|
|
int dspspeed = *(int *)arg;
|
|
|
|
+#if defined(__OpenBSD__)
|
|
+ audio_info_t audio_if;
|
|
+ AUDIO_INITINFO(&audio_if);
|
|
+ audio_if.record.sample_rate = dspspeed;
|
|
+ if (ioctl(priv->dspfd, AUDIO_SETINFO, &audio_if) == -1)
|
|
+#else
|
|
if(ioctl(priv->dspfd, SNDCTL_DSP_SPEED, &dspspeed) == -1)
|
|
+#endif
|
|
{
|
|
mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848InvalidAudioRate, strerror(errno));
|
|
return(TVI_CONTROL_FALSE);
|
|
@@ -525,7 +540,12 @@ static int init(priv_t *priv)
|
|
int marg;
|
|
int count;
|
|
u_short tmp_fps;
|
|
+int tuner_audio;
|
|
+#if defined(__OpenBSD__)
|
|
+audio_info_t audio_if;
|
|
+#endif
|
|
|
|
+
|
|
G_private = priv; /* Oooh, sick */
|
|
|
|
/* Video Configuration */
|
|
@@ -536,7 +556,7 @@ priv->iformat = METEOR_FMT_PAL;
|
|
priv->maxheight = PAL_HEIGHT;
|
|
priv->maxwidth = PAL_WIDTH;
|
|
priv->maxfps = PAL_FPS;
|
|
-priv->source = METEOR_INPUT_DEV0;
|
|
+priv->source = METEOR_INPUT_DEV1;
|
|
priv->fps = priv->maxfps;
|
|
|
|
priv->starttime=0;
|
|
@@ -622,13 +642,33 @@ if(priv->tunerfd < 0)
|
|
priv->tunerready = FALSE;
|
|
}
|
|
|
|
+if(ioctl(priv->tunerfd, BT848_GAUDIO, &tuner_audio) < 0)
|
|
+ {
|
|
+ perror("tuner get audio");
|
|
+ priv->tunerready = FALSE;
|
|
+ }
|
|
+if(tuner_audio & AUDIO_MUTE)
|
|
+ {
|
|
+ tuner_audio = AUDIO_UNMUTE;
|
|
+ if(ioctl(priv->tunerfd, BT848_SAUDIO, &tuner_audio) < 0)
|
|
+ {
|
|
+ perror("tuner unmute");
|
|
+ priv->tunerready = FALSE;
|
|
+ }
|
|
+ }
|
|
+
|
|
+
|
|
/* Audio Configuration */
|
|
|
|
priv->dspready = TRUE;
|
|
priv->dspsamplesize = 16;
|
|
priv->dspstereo = 1;
|
|
priv->dspspeed = 44100;
|
|
+#if defined (__OpenBSD__)
|
|
+priv->dspfmt = AUDIO_ENCODING_SLINEAR_LE;
|
|
+#else
|
|
priv->dspfmt = AFMT_S16_LE;
|
|
+#endif
|
|
priv->dspbytesread = 0;
|
|
priv->dsprate = priv->dspspeed * priv->dspsamplesize/8*(priv->dspstereo+1);
|
|
priv->dspframesize = priv->dspspeed*priv->dspsamplesize/8/priv->fps *
|
|
@@ -642,6 +682,26 @@ if((priv->dspfd = open (priv->dspdev, O_RDONLY, 0)) <
|
|
|
|
marg = (256 << 16) | 12;
|
|
|
|
+#if defined(__OpenBSD__)
|
|
+
|
|
+ AUDIO_INITINFO(&audio_if);
|
|
+
|
|
+ audio_if.record.precision = priv->dspsamplesize;
|
|
+ audio_if.record.channels = priv->dspstereo+1;
|
|
+ audio_if.record.sample_rate = priv->dspspeed;
|
|
+ audio_if.record.encoding = priv->dspfmt;
|
|
+
|
|
+ audio_if.mode = AUMODE_RECORD;
|
|
+
|
|
+ if (ioctl(priv->dspfd, AUDIO_SETINFO, &audio_if) < 0)
|
|
+ {
|
|
+ perror ("AUDIO_SETINFO:ioctl");
|
|
+ close(priv->dspfd);
|
|
+ priv->dspready = FALSE;
|
|
+ }
|
|
+
|
|
+#else
|
|
+
|
|
if (ioctl(priv->dspfd, SNDCTL_DSP_SETFRAGMENT, &marg ) < 0 )
|
|
{
|
|
mp_msg(MSGT_TV, MSGL_ERR, MSGTR_TV_Bt848IoctlFailed, "SNDCTL_DSP_SETFRAGMENT", strerror(errno));
|
|
@@ -659,6 +719,8 @@ if((priv->dspready == TRUE) &&
|
|
priv->dspready = FALSE;
|
|
}
|
|
|
|
+#endif
|
|
+
|
|
return(1);
|
|
}
|
|
|
|
@@ -703,6 +765,7 @@ return(1);
|
|
static int uninit(priv_t *priv)
|
|
{
|
|
int marg;
|
|
+int tuner_audio;
|
|
|
|
if(priv->videoready == FALSE) return(0);
|
|
|
|
@@ -725,6 +788,15 @@ if(ioctl(priv->btfd, METEORCAPTUR, &marg) < 0 )
|
|
close(priv->btfd);
|
|
close(priv->dspfd);
|
|
|
|
+tuner_audio = AUDIO_MUTE;
|
|
+if(ioctl(priv->tunerfd, BT848_SAUDIO, &tuner_audio) < 0)
|
|
+ {
|
|
+ perror("tuner mute");
|
|
+ priv->tunerready = FALSE;
|
|
+ }
|
|
+
|
|
+close(priv->tunerfd);
|
|
+
|
|
priv->dspfd = -1;
|
|
priv->btfd = -1;
|
|
|
|
@@ -869,22 +941,15 @@ if(ioctl(priv->dspfd, FIONREAD, &bytesavail) < 0)
|
|
/* When mencoder wants audio data, it wants data..
|
|
it won't go do anything else until it gets it :( */
|
|
|
|
-if(bytesavail == 0) return FRAGSIZE;
|
|
+// if(bytesavail == 0) return FRAGSIZE;
|
|
|
|
return(bytesavail);
|
|
}
|
|
|
|
static int getinput(int innumber)
|
|
{
|
|
-switch(innumber)
|
|
- {
|
|
- case 0: return METEOR_INPUT_DEV0; /* RCA */
|
|
- case 1: return METEOR_INPUT_DEV1; /* Tuner */
|
|
- case 2: return METEOR_INPUT_DEV2; /* In 1 */
|
|
- case 3: return METEOR_INPUT_DEV3; /* In 2 */
|
|
- case 4: return METEOR_INPUT_DEV_RGB; /* RGB */
|
|
- case 5: return METEOR_INPUT_DEV_SVIDEO; /* SVid */
|
|
- }
|
|
-
|
|
+if (sources[innumber])
|
|
+ return sources[innumber];
|
|
+
|
|
return 0;
|
|
}
|