[MPlayer-dev-eng] [PATCH] -ao pcm suboptions
Reimar Döffinger
Reimar.Doeffinger at stud.uni-karlsruhe.de
Sat Jan 1 20:21:56 CET 2005
Hi,
> > this patch adds suboptions to -ao pcm:
> >
> > - file=<filename>
> > to write the sound to the given file instead of the default
> > audiodump.wav.
> >
> > - waveheader
> > to include the wave header (default)
> >
> > - nowaveheader
> > to not include the wave header
> >
> > The global options -aofile, -waveheader and -nowaveheader are still
> > recognized but print a message saying they are no more supported.
>
> I guess this should be reimplemented using the new suboption parser
> helper once it is in CVS. But large parts of this can be reused.
I did that. See the attached patch. I want to apply tomorrow, any
objections?
Greetings,
Reimar Döffinger
-------------- next part --------------
Index: libao2/ao_pcm.c
===================================================================
RCS file: /cvsroot/mplayer/main/libao2/ao_pcm.c,v
retrieving revision 1.24
diff -u -r1.24 ao_pcm.c
--- libao2/ao_pcm.c 28 Dec 2004 19:11:14 -0000 1.24
+++ libao2/ao_pcm.c 1 Jan 2005 11:36:26 -0000
@@ -5,6 +5,7 @@
#include <string.h>
#include "bswap.h"
+#include "subopt-helper.h"
#include "libaf/af_format.h"
#include "audio_out.h"
#include "audio_out_internal.h"
@@ -24,8 +25,8 @@
extern int vo_pts;
-char *ao_outputfilename = NULL;
-int ao_pcm_waveheader = 1;
+static char *ao_outputfilename = NULL;
+static int ao_pcm_waveheader = 1;
#define WAV_ID_RIFF 0x46464952 /* "RIFF" */
#define WAV_ID_WAVE 0x45564157 /* "WAVE" */
@@ -79,9 +80,20 @@
// return: 1=success 0=fail
static int init(int rate,int channels,int format,int flags){
int bits;
- if(!ao_outputfilename) {
- ao_outputfilename = strdup(ao_pcm_waveheader ? "audiodump.wav" : "audiodump.pcm");
+ strarg_t file;
+ opt_t subopts[] = {
+ {"waveheader", OPT_ARG_BOOL, &ao_pcm_waveheader, NULL},
+ {"file", OPT_ARG_STR, &file, NULL},
+ {NULL}
}
+ // set defaults
+ ao_pcm_waveheader = 1;
+ file.str = "audiodump.wav";
+ file.len = 13;
+ if (subopt_parse(ao_subdevice, subopts) != 0) {
+ return 0;
+ }
+ ao_outputfilename = strndup(file.str, file.len);
/* bits is only equal to format if (format == 8) or (format == 16);
this means that the following "if" is a kludge and should
@@ -142,6 +154,9 @@
fwrite(&wavhdr,sizeof(wavhdr),1,fp);
}
fclose(fp);
+ if (ao_outputfilename)
+ free(ao_outputfilename);
+ ao_outputfilename = NULL;
}
// stop playing and empty buffers (for seeking/pause)
Index: cfg-mplayer.h
===================================================================
RCS file: /cvsroot/mplayer/main/cfg-mplayer.h,v
retrieving revision 1.236
diff -u -r1.236 cfg-mplayer.h
--- cfg-mplayer.h 27 Dec 2004 19:34:42 -0000 1.236
+++ cfg-mplayer.h 1 Jan 2005 11:36:27 -0000
@@ -167,9 +167,9 @@
{"abs", &ao_data.buffersize, CONF_TYPE_INT, CONF_MIN, 0, 0, NULL},
// -ao pcm options:
- {"aofile", &ao_outputfilename, CONF_TYPE_STRING, 0, 0, 0, NULL},
- {"waveheader", &ao_pcm_waveheader, CONF_TYPE_FLAG, 0, 0, 1, NULL},
- {"nowaveheader", &ao_pcm_waveheader, CONF_TYPE_FLAG, 0, 1, 0, NULL},
+ {"aofile", "-aofile is deprecated. Use -ao pcm:file=<filename> instead.\n", CONF_TYPE_PRINT, 0, 0, 0, NULL},
+ {"waveheader", "-waveheader is deprecated. Use -ao pcm:waveheader instead.\n", CONF_TYPE_PRINT, 0, 0, 1, NULL},
+ {"nowaveheader", "-nowaveheader is deprecated. Use -ao pcm:waveheader instead.\n", CONF_TYPE_PRINT, 0, 1, 0, NULL},
{"alsa", "-alsa has been removed. Remove it from your config file.\n",
CONF_TYPE_PRINT, 0, 0, 0, NULL},
Index: DOCS/man/en/mplayer.1
===================================================================
RCS file: /cvsroot/mplayer/main/DOCS/man/en/mplayer.1,v
retrieving revision 1.833
diff -u -r1.833 mplayer.1
--- DOCS/man/en/mplayer.1 28 Dec 2004 01:53:17 -0000 1.833
+++ DOCS/man/en/mplayer.1 1 Jan 2005 11:36:49 -0000
@@ -1669,10 +1669,6 @@
Override audio driver/\:card buffer size detection.
.
.TP
-.B \-aofile <filename>
-Override the default filename employed by \-ao pcm.
-.
-.TP
.B \-aop <list=plugin1,plugin2...:option1=value1:opt2=val2...>
Specify audio plugin(s) and their options
(also see the audio plugins section of the documentation).
@@ -1770,11 +1766,6 @@
the maximum, which e.g.\& the OSD cannot display correctly.
.
.TP
-.B \-nowaveheader (\-ao pcm only)
-Don't include wave header.
-Used for raw PCM.
-.
-.TP
.B \-volstep <0\-100>
Set the step size of mixer volume changes in percent of the whole range
(default: 3).
@@ -1908,9 +1899,24 @@
Use \-nosound for benchmarking.
.
.TP
-.B pcm (also see \-aofile)
+.B pcm
Raw PCM/\:wave file writer audio output.
-Writes the sound to ./audiodump.wav.
+.PD 0
+.RSs
+.IPs (no)waveheader
+Include or not the wave header (default: included).
+When not included, raw PCM will be generated.
+.IPs file=<filename>
+Write the sound to the given file instead of the default
+audiodump.wav.
+.REss
+.PD 1
+.RS
+.sp 1
+.I NOTE:
+If you don't specify any option the output is progressive
+(i.e.\& not interlaced).
+.RE
.
.TP
.B plugin\ \
Index: etc/dvb-menu.conf
===================================================================
RCS file: /cvsroot/mplayer/main/etc/dvb-menu.conf,v
retrieving revision 1.2
diff -u -r1.2 dvb-menu.conf
--- etc/dvb-menu.conf 28 Jul 2004 00:29:32 -0000 1.2
+++ etc/dvb-menu.conf 1 Jan 2005 11:36:49 -0000
@@ -58,10 +58,8 @@
<e name="abs"/>
<e name="af"/>
<e name="ao"/>
- <e name="aofile"/>
<e name="delay"/>
<e name="mixer"/>
- <e name="nowaveheader"/>
</pref>
<pref name="video_pref" title="Video">
Index: etc/menu.conf
===================================================================
RCS file: /cvsroot/mplayer/main/etc/menu.conf,v
retrieving revision 1.4
diff -u -r1.4 menu.conf
--- etc/menu.conf 28 Jul 2004 00:29:32 -0000 1.4
+++ etc/menu.conf 1 Jan 2005 11:36:49 -0000
@@ -55,10 +55,8 @@
<e name="abs"/>
<e name="af"/>
<e name="ao"/>
- <e name="aofile"/>
<e name="delay"/>
<e name="mixer"/>
- <e name="nowaveheader"/>
</pref>
<pref name="video_pref" title="Video">
More information about the MPlayer-dev-eng
mailing list