changeset 6501:827f08ddf044

Allow writing to pipe.
author albeu
date Sat, 22 Jun 2002 12:10:02 +0000
parents cb078d0579f3
children 01ada897cc89
files libao2/ao_pcm.c
diffstat 1 files changed, 2 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/libao2/ao_pcm.c	Sat Jun 22 10:22:49 2002 +0000
+++ b/libao2/ao_pcm.c	Sat Jun 22 12:10:02 2002 +0000
@@ -109,7 +109,7 @@
 
 	if(fp) {
 		if(ao_pcm_waveheader) /* Reserve space for wave header */
-			fseek(fp, sizeof(wavhdr), SEEK_SET);
+			fwrite(&wavhdr,sizeof(wavhdr),1,fp);
 		return 1;
 	}
 	printf("PCM: Failed to open %s for writing!\n", ao_outputfilename);
@@ -119,10 +119,9 @@
 // close audio device
 static void uninit(){
 	
-	if(ao_pcm_waveheader){ /* Write wave header */
+	if(ao_pcm_waveheader && fseek(fp, 0, SEEK_SET) == 0){ /* Write wave header */
 		wavhdr.file_length = wavhdr.data_length + sizeof(wavhdr) - 8;
 		wavhdr.file_length = le2me_32(wavhdr.file_length);
-		fseek(fp, 0, SEEK_SET);
 		fwrite(&wavhdr,sizeof(wavhdr),1,fp);
 	}
 	fclose(fp);