Add support for

- version 2 audio atoms in QuickTime containers, from mplayer cvs requested by
   David Hill (dhill at mindcry org)
- setting volumem via /dev/mixer, from Mike Belopuhov (mkb at crypt org ru)
This commit is contained in:
biorn 2006-01-22 06:28:25 +00:00
parent 01c5aa7fdb
commit a70bd55dd7
3 changed files with 207 additions and 2 deletions

View File

@ -1,4 +1,4 @@
# $OpenBSD: Makefile,v 1.95 2006/01/17 07:41:58 jakemsr Exp $
# $OpenBSD: Makefile,v 1.96 2006/01/22 06:28:25 biorn Exp $
# May not be hard to add more.
ONLY_FOR_ARCHS= amd64 i386 powerpc sparc64 arm
@ -7,7 +7,7 @@ COMMENT= "Movie player supporting MPEG, DivX, AVI, ASF, MOV & more"
DISTNAME= MPlayer-1.0pre7
DIST_SUBDIR= mplayer
PKGNAME= ${DISTNAME:L}p12
PKGNAME= ${DISTNAME:L}p13
CATEGORIES= x11
EXTRACT_SUFX= .tar.bz2

View File

@ -0,0 +1,144 @@
$OpenBSD: patch-libao2_ao_sun_c,v 1.1 2006/01/22 06:28:25 biorn Exp $
--- libao2/ao_sun.c.orig Thu Jan 6 23:56:54 2005
+++ libao2/ao_sun.c Thu Jan 19 18:00:16 2006
@@ -66,7 +66,57 @@ static enum {
extern int verbose;
+#if defined(__OpenBSD__) || defined(__NetBSD__)
+int sun_mixer_get_dev(int fd, int *dev, char *id)
+{
+ mixer_devinfo_t info;
+ for (info.index = 0; ioctl(fd, AUDIO_MIXER_DEVINFO, &info) >= 0;
+ info.index++) {
+ if (!strcmp(id, info.label.name)) {
+ *dev = info.index;
+ return 0;
+ }
+ }
+ return -1;
+}
+
+int sun_get_volume(int fd, int *l, int *r)
+{
+ mixer_ctrl_t mixer;
+
+ if (sun_mixer_get_dev(fd, &mixer.dev, "master") < 0)
+ return -1;
+
+ mixer.type = AUDIO_MIXER_VALUE;
+ mixer.un.value.num_channels = 2;
+ if (ioctl(fd, AUDIO_MIXER_READ, &mixer) < 0)
+ return -1;
+ *l = mixer.un.value.level[AUDIO_MIXER_LEVEL_LEFT];
+ *r = mixer.un.value.level[AUDIO_MIXER_LEVEL_RIGHT];
+
+ return 0;
+}
+
+int sun_set_volume(int fd, int l, int r)
+{
+ mixer_ctrl_t mixer;
+
+ if (sun_mixer_get_dev(fd, &mixer.dev, "master") < 0)
+ return -1;
+
+ mixer.type = AUDIO_MIXER_VALUE;
+ mixer.un.value.num_channels = 2;
+ mixer.un.value.level[AUDIO_MIXER_LEVEL_LEFT] = l;
+ mixer.un.value.level[AUDIO_MIXER_LEVEL_RIGHT] = r;
+
+ if (ioctl(fd, AUDIO_MIXER_WRITE, &mixer) < 0)
+ return -1;
+
+ return 0;
+}
+#endif
+
// convert an OSS audio format specification into a sun audio encoding
static int af2sunfmt(int format)
{
@@ -366,13 +416,21 @@ static void setup_device_paths()
audio_dev = "/dev/audio";
}
+#if defined(__OpenBSD__) || defined(__NetBSD__)
if (sun_mixer_device == NULL) {
+ if (mixer_device == NULL)
+ mixer_device = strdup("/dev/mixer");
+ sun_mixer_device = mixer_device;
+ }
+#else
+ if (sun_mixer_device == NULL) {
if ((sun_mixer_device = mixer_device) == NULL || !sun_mixer_device[0]) {
sun_mixer_device = malloc(strlen(audio_dev) + 4);
strcpy(sun_mixer_device, audio_dev);
strcat(sun_mixer_device, "ctl");
}
}
+#endif
if (ao_subdevice) audio_dev = ao_subdevice;
}
@@ -396,6 +454,14 @@ static int control(int cmd,void *arg){
if ( fd != -1 )
{
ao_control_vol_t *vol = (ao_control_vol_t *)arg;
+#if defined(__OpenBSD__) || defined(__NetBSD__)
+ int r, l;
+ if (sun_get_volume(fd, &r, &l) < 0) {
+ close(fd);
+ goto cgerr;
+ }
+ vol->right = vol->left = (float)(r * 100. / AUDIO_MAX_GAIN);
+#else
float volume;
struct audio_info info;
ioctl( fd,AUDIO_GETINFO,&info);
@@ -410,9 +476,11 @@ static int control(int cmd,void *arg){
/ AUDIO_MID_BALANCE;
vol->right = volume;
}
+#endif
close( fd );
return CONTROL_OK;
- }
+ }
+cgerr:
return CONTROL_ERROR;
}
case AOCONTROL_SET_VOLUME:
@@ -423,10 +491,18 @@ static int control(int cmd,void *arg){
if ( !sun_mixer_device ) /* control function is used before init? */
setup_device_paths();
- fd=open( sun_mixer_device,O_RDONLY );
+ fd=open( sun_mixer_device,O_RDWR );
if ( fd != -1 )
{
struct audio_info info;
+#if defined(__OpenBSD__) || defined(__NetBSD__)
+ int r;
+ r = (int)(vol->right * AUDIO_MAX_GAIN / 100);
+ if (sun_set_volume(fd, r, r) < 0) {
+ close(fd);
+ goto cserr;
+ }
+#else
float volume;
AUDIO_INITINFO(&info);
volume = vol->right > vol->left ? vol->right : vol->left;
@@ -441,9 +517,11 @@ static int control(int cmd,void *arg){
info.output_muted = (volume == 0);
#endif
ioctl( fd,AUDIO_SETINFO,&info );
+#endif
close( fd );
return CONTROL_OK;
- }
+ }
+cserr:
return CONTROL_ERROR;
}
}

View File

@ -0,0 +1,61 @@
$OpenBSD: patch-libmpdemux_demux_mov_c,v 1.1 2006/01/22 06:28:25 biorn Exp $
--- libmpdemux/demux_mov.c.orig Thu Mar 31 00:10:07 2005
+++ libmpdemux/demux_mov.c Wed Jan 18 22:05:11 2006
@@ -865,6 +865,7 @@ static void lschunks(demuxer_t* demuxer,
// ([int32_t size,int32_t type,some data ],repeat)
} my_stdata;
#endif
+ int version, adjust;
sh_audio_t* sh=new_sh_audio(demuxer,priv->track_db);
sh->format=trak->fourcc;
@@ -911,8 +912,27 @@ static void lschunks(demuxer_t* demuxer,
// 32 char[4] atom type (fourc charater code -> esds)
// 36 char[] atom data (len=size-8)
+ version=char2short(trak->stdata,8);
+ if (version > 1)
+ mp_msg(MSGT_DEMUX, MSGL_WARN, "MOV: version %d sound atom may not parse correctly!\n", version);
trak->samplebytes=sh->samplesize=char2short(trak->stdata,18)/8;
- trak->nchannels=sh->channels=char2short(trak->stdata,16);
+
+ /* I can't find documentation, but so far this is the case. -Corey */
+ switch (char2short(trak->stdata,16)) {
+ case 1:
+ trak->nchannels = 1; break;
+ case 2:
+ trak->nchannels = 2; break;
+ case 3:
+ trak->nchannels = 6; break;
+ default:
+ mp_msg(MSGT_DEMUX, MSGL_WARN,
+ "MOV: unable to determine audio channels, assuming 2 (got %d)\n",
+ char2short(trak->stdata,16));
+ trak->nchannels = 2;
+ }
+ sh->channels = trak->nchannels;
+
/*printf("MOV: timescale: %d samplerate: %d durmap: %d (%d) -> %d (%d)\n",
trak->timescale, char2short(trak->stdata,24), trak->durmap[0].dur,
trak->durmap[0].num, trak->timescale/trak->durmap[0].dur,
@@ -966,8 +986,18 @@ static void lschunks(demuxer_t* demuxer,
}
}
- if((trak->stdata[9]==0 || trak->stdata[9]==1) && trak->stdata_len >= 36) { // version 0 with extra atoms
- int adjust = (trak->stdata[9]==1)?48:0;
+ switch (version) {
+ case 0:
+ adjust = 0; break;
+ case 1:
+ adjust = 48; break;
+ case 2:
+ adjust = 68; break;
+ default:
+ mp_msg(MSGT_DEMUX, MSGL_WARN, "MOV: unknown sound atom version (%d); may not work!\n", version);
+ adjust = 68;
+ }
+ if (trak->stdata_len >= 36 + adjust) {
int atom_len = char2int(trak->stdata,28+adjust);
switch(char2int(trak->stdata,32+adjust)) { // atom type
case MOV_FOURCC('e','s','d','s'): {