[MPlayer-dev-eng] PATCHes again?
Christian Ohm
chr.ohm at gmx.net
Tue May 21 02:58:45 CEST 2002
hi.
since this wasn't rejected or applied, i send it again.
this patch adds a passthrough mode to the audio plugins, so mplayer doesn't
quit when playing a file with an audio format the plugin can't handle. and
it fixes a bug in the resample plugin which decreases the audio volume when
fin == fout.
bye
christian ohm
--
"There... I've run rings 'round you logically"
-- Monty Python's Flying Circus
-------------- next part --------------
Index: libao2/pl_extrastereo.c
===================================================================
RCS file: /cvsroot/mplayer/main/libao2/pl_extrastereo.c,v
retrieving revision 1.1
diff -u -r1.1 pl_extrastereo.c
--- libao2/pl_extrastereo.c 3 Mar 2002 14:17:53 -0000 1.1
+++ libao2/pl_extrastereo.c 21 May 2002 01:03:52 -0000
@@ -32,14 +32,16 @@
// local data
static struct {
+ int passthrough; // do nothing
float mul; // intensity
int inuse; // This plugin is in use TRUE, FALSE
int format; // sample format
-} pl_extrastereo = {2.5, 0, 0};
+} pl_extrastereo = {0, 2.5, 0, 0};
// to set/get/query special features/parameters
static int control(int cmd,int arg){
+ if(pl_extrastereo.passthrough) return CONTROL_OK;
switch(cmd){
case AOCONTROL_PLUGIN_SET_LEN:
return CONTROL_OK;
@@ -50,17 +52,19 @@
// open & setup audio device
// return: 1=success 0=fail
static int init(){
+ pl_extrastereo.inuse=1;
+
switch(ao_plugin_data.format){
case(AFMT_S16_LE):
break;
default:
- fprintf(stderr,"[pl_extrastereo] Audio format not yet suported \n");
- return 0;
+ fprintf(stderr,"[pl_extrastereo] Input audio format not yet supported, using passthrough mode.\n");
+ pl_extrastereo.passthrough=1;
+ return 1;
}
pl_extrastereo.mul=ao_plugin_cfg.pl_extrastereo_mul;
pl_extrastereo.format=ao_plugin_data.format;
- pl_extrastereo.inuse=1;
printf("[pl_extrastereo] Extra stereo plugin in use (multiplier=%2.2f).\n",
pl_extrastereo.mul);
@@ -79,7 +83,7 @@
// processes 'ao_plugin_data.len' bytes of 'data'
// called for every block of data
static int play(){
-
+ if(pl_extrastereo.passthrough) return 1;
switch(pl_extrastereo.format){
case(AFMT_S16_LE): {
Index: libao2/pl_format.c
===================================================================
RCS file: /cvsroot/mplayer/main/libao2/pl_format.c,v
retrieving revision 1.4
diff -u -r1.4 pl_format.c
--- libao2/pl_format.c 4 Dec 2001 12:28:26 -0000 1.4
+++ libao2/pl_format.c 21 May 2002 01:03:53 -0000
@@ -30,6 +30,7 @@
// local data
typedef struct pl_format_s
{
+ int passthrough;// do nothing
void* data; // local audio data block
int len; // local buffer length
int in; // input fomat
@@ -37,7 +38,7 @@
double sz_mult; // data size multiplier
} pl_format_t;
-static pl_format_t pl_format={NULL,0,0,0,1};
+static pl_format_t pl_format={0,NULL,0,0,0,1};
// Number of bits
#define B08 (0<<0)
@@ -57,6 +58,7 @@
// to set/get/query special features/parameters
static int control(int cmd,int arg){
+ if (pl_format.passthrough) return CONTROL_OK;
switch(cmd){
case AOCONTROL_PLUGIN_SET_LEN:
if(pl_format.data)
@@ -97,8 +99,9 @@
case(AFMT_A_LAW):
case(AFMT_MPEG):
case(AFMT_AC3):
- printf("[pl_format] Input audio format not yet suported \n");
- return 0;
+ printf("[pl_format] Input audio format not yet supported, using passthrough mode.\n");
+ pl_format.passthrough=1;
+ return 1;
default:
printf("[pl_format] Unrecognised input audio format\n"); //This can not happen ....
return 0;
@@ -161,6 +164,7 @@
// empty buffers
static void reset(){
+ if (pl_format.passthrough) return;
memset(pl_format.data, 0, pl_format.len);
}
@@ -174,6 +178,7 @@
int len=(ao_plugin_data.len)>>(pl_format.in&NBITS_MASK);
ao_plugin_data.len=(int)(((double)ao_plugin_data.len)*=pl_format.sz_mult);
+ if(pl_format.passthrough) return 1;;
// Change to little endian (Is this true for sun ?)
if((pl_format.in&END_MASK)!=LE){
switch(pl_format.in&NBITS_MASK){
Index: libao2/pl_resample.c
===================================================================
RCS file: /cvsroot/mplayer/main/libao2/pl_resample.c,v
retrieving revision 1.7
diff -u -r1.7 pl_resample.c
--- libao2/pl_resample.c 21 Feb 2002 16:05:09 -0000 1.7
+++ libao2/pl_resample.c 21 May 2002 01:03:57 -0000
@@ -81,6 +81,7 @@
// local data
typedef struct pl_resample_s
{
+ int passthrough; // do nothing
int16_t* data; // Data buffer
int16_t* w; // Current filter weights
uint16_t dn; // Down sampling factor
@@ -91,10 +92,11 @@
int16_t xs[CH][L*2]; // Circular buffers
} pl_resample_t;
-static pl_resample_t pl_resample = {NULL,NULL,1,1,1,0,W};
+static pl_resample_t pl_resample = {0,NULL,NULL,1,1,1,0,W};
// to set/get/query special features/parameters
static int control(int cmd,int arg){
+ if (pl_resample.passthrough) return CONTROL_OK;
switch(cmd){
case AOCONTROL_PLUGIN_SET_LEN:
if(pl_resample.data)
@@ -121,8 +123,9 @@
// Sheck input format
if(ao_plugin_data.format != AFMT_S16_LE){
- fprintf(stderr,"[pl_resample] Input audio format not yet suported. \n");
- return 0;
+ fprintf(stderr,"[pl_resample] Input audio format not yet supported, using passthrough mode.\n");
+ pl_resample.passthrough=1;
+ return 1;
}
// Sanity check and calculate down sampling factor
if((float)max(fin,fout)/(float)min(fin,fout) > 10){
@@ -130,6 +133,11 @@
return 0;
}
pl_resample.dn=(int)(0.5+((float)(fin*pl_resample.up))/((float)fout));
+ if(pl_resample.dn==pl_resample.up){
+ fprintf(stderr,"[pl_resample] fin == fout, using passthrough mode.\n");
+ pl_resample.passthrough=1;
+ return 1;
+ }
pl_resample.channels=ao_plugin_data.channels;
if(ao_plugin_data.channels>CH){
@@ -164,12 +172,8 @@
// called for every block of data
// FIXME: this routine needs to be optimized (it is probably possible to do a lot here)
static int play(){
- if(pl_resample.up==pl_resample.dn){
- register int16_t* in = ((int16_t*)ao_plugin_data.data);
- register int16_t* end = in+ao_plugin_data.len/2;
- while(in < end) *in=(*in++)>>1;
+ if(pl_resample.passthrough)
return 1;
- }
if(pl_resample.up>pl_resample.dn)
return upsample();
if(pl_resample.up<pl_resample.dn)
Index: libao2/pl_volnorm.c
===================================================================
RCS file: /cvsroot/mplayer/main/libao2/pl_volnorm.c,v
retrieving revision 1.4
diff -u -r1.4 pl_volnorm.c
--- libao2/pl_volnorm.c 10 Mar 2002 13:53:38 -0000 1.4
+++ libao2/pl_volnorm.c 21 May 2002 01:04:01 -0000
@@ -97,13 +97,15 @@
// Local data
static struct {
+ int passthrough; // do nothing
int inuse; // This plugin is in use TRUE, FALSE
int format; // sample fomat
-} pl_volnorm = {0, 0};
+} pl_volnorm = {0, 0, 0};
// minimal interface
static int control(int cmd,int arg){
+ if(pl_volnorm.passthrough) return CONTROL_OK;
switch(cmd){
case AOCONTROL_PLUGIN_SET_LEN:
return CONTROL_OK;
@@ -115,16 +117,18 @@
// open & setup audio device
// return: 1=success 0=fail
static int init(){
+ pl_volnorm.inuse = 1;
+
switch(ao_plugin_data.format){
case(AFMT_S16_LE):
break;
default:
- fprintf(stderr,"[pl_volnorm] Audio format not yet supported.\n");
- return 0;
+ fprintf(stderr,"[pl_volnorm] Input audio format not yet supported, using passthrough mode.\n");
+ pl_volnorm.passthrough=1;
+ return 1;
}
pl_volnorm.format = ao_plugin_data.format;
- pl_volnorm.inuse = 1;
reset();
@@ -140,6 +144,7 @@
// empty buffers
static void reset(){
int i;
+ if(pl_volnorm.passthrough) return;
mul = MUL_INIT;
switch(ao_plugin_data.format) {
case(AFMT_S16_LE):
@@ -154,7 +159,7 @@
#endif
break;
- default:
+ default: // shouldn't happen
fprintf(stderr,"[pl_volnorm] internal inconsistency - bugreport !\n");
*(char *) 0 = 0;
}
@@ -163,7 +168,7 @@
// processes 'ao_plugin_data.len' bytes of 'data'
// called for every block of data
static int play(){
-
+ if(pl_volnorm.passthrough) return 1;
switch(pl_volnorm.format){
case(AFMT_S16_LE): {
Index: libao2/pl_volume.c
===================================================================
RCS file: /cvsroot/mplayer/main/libao2/pl_volume.c,v
retrieving revision 1.2
diff -u -r1.2 pl_volume.c
--- libao2/pl_volume.c 13 Mar 2002 12:32:42 -0000 1.2
+++ libao2/pl_volume.c 21 May 2002 01:04:02 -0000
@@ -35,15 +35,17 @@
// local data
typedef struct pl_volume_s
{
+ int passthrough; // do nothing
uint16_t volume; // output volume level
int inuse; // This plugin is in use TRUE, FALSE
int format; // sample fomat
} pl_volume_t;
-static pl_volume_t pl_volume={0,0,0};
+static pl_volume_t pl_volume={0,0,0,0};
// to set/get/query special features/parameters
static int control(int cmd,int arg){
+ if(pl_volume.passthrough) return CONTROL_OK;
switch(cmd){
case AOCONTROL_PLUGIN_SET_LEN:
return CONTROL_OK;
@@ -78,22 +80,23 @@
// open & setup audio device
// return: 1=success 0=fail
static int init(){
+ /* The inuse flag is used in control to detremine if the return
+ value since that function always is called from ao_plugin regardless
+ of wether this plugin is in use or not. */
+ pl_volume.inuse=1;
// Sanity sheck this plugin supports AFMT_U8 and AFMT_S16_LE
switch(ao_plugin_data.format){
case(AFMT_U8):
case(AFMT_S16_LE):
break;
default:
- fprintf(stderr,"[pl_volume] Audio format not yet suported \n");
- return 0;
+ fprintf(stderr,"[pl_volume] Input audio format not yet supported, using passthrough mode.\n");
+ pl_volume.passthrough=1;
+ return 1;
}
// Initialize volume to this value
pl_volume.volume=ao_plugin_cfg.pl_volume_volume;
pl_volume.format=ao_plugin_data.format;
- /* The inuse flag is used in control to detremine if the return
- value since that function always is called from ao_plugin regardless
- of wether this plugin is in use or not. */
- pl_volume.inuse=1;
// Tell the world what we are up to
printf("[pl_volume] Software volume control in use%s.\n",ao_plugin_cfg.pl_volume_softclip?", soft clipping enabled":"");
return 1;
@@ -114,6 +117,7 @@
static int play(){
register int i=0;
register int vol=pl_volume.volume; // Logarithmic control sounds more natural
+ if(pl_volume.passthrough) return 1;
vol=(vol*vol*vol)>>12;
// Change the volume.
switch(pl_volume.format){
More information about the MPlayer-dev-eng
mailing list