[MPlayer-cvslog] CVS: main/libao2 ao_pcm.c,1.24,1.25

Reimar Döffinger CVS syncmail at mplayerhq.hu
Sun Jan 2 15:41:48 CET 2005


CVS change done by Reimar Döffinger CVS

Update of /cvsroot/mplayer/main/libao2
In directory mail:/var2/tmp/cvs-serv16757/libao2

Modified Files:
	ao_pcm.c 
Log Message:
Add -ao pcm suboptions and remove -aofile and -waveheader options.
Base on idea by Olivier Rolland (billl at users dot sf dot net)


Index: ao_pcm.c
===================================================================
RCS file: /cvsroot/mplayer/main/libao2/ao_pcm.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- ao_pcm.c	28 Dec 2004 19:11:14 -0000	1.24
+++ ao_pcm.c	2 Jan 2005 14:41:46 -0000	1.25
@@ -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)




More information about the MPlayer-cvslog mailing list