[MPlayer-dev-eng] [PATCH] No trailing noise with -ao pcm under win32

Zhou Zongyi zhouzongyi at pset.suntec.net
Mon Apr 27 08:17:01 CEST 2009


Hi all,

GUI makers can use Windows named pipe to transfer pcm data from mplayer to audio encoders,
without the need of temporal files. But currently mplayer always tries to rewrite wave
header at the end of stream(you cannot seek backwards in pipes), resulting in trailing noise.
The following patch adds file type check under win32:

Index: libao2/ao_pcm.c
===================================================================
--- libao2/ao_pcm.c	(revision 29238)
+++ libao2/ao_pcm.c	(working copy)
@@ -34,6 +34,9 @@
 #include "mp_msg.h"
 #include "help_mp.h"
 
+#ifdef _WIN32
+#include <windows.h>
+#endif
 
 static const ao_info_t info = 
 {
@@ -175,7 +178,11 @@
 static void uninit(int immed){
     
     if(ao_pcm_waveheader){ /* Rewrite wave header */
+#ifdef _WIN32
+        if (GetFileType((HANDLE)_get_osfhandle(_fileno(fp))) != FILE_TYPE_DISK || fseek(fp, 0, SEEK_SET) != 0)
+#else
         if (fseek(fp, 0, SEEK_SET) != 0)
+#endif
             mp_msg(MSGT_AO, MSGL_ERR, "Could not seek to start, WAV size headers not updated!\n");
         else if (data_length > 0x7ffff000)
             mp_msg(MSGT_AO, MSGL_ERR, "File larger than allowed for WAV files, may play truncated!\n");


Attached is a small tool to test named pipe under windows, here is an example

In the first cmd window, type something like(there should be at least 2 spaces between exe name and parameters):
NamedPipe.exe \\.\pipe\1.wav neroAacEnc.exe  -if - -of audio.mp4 -q 0.5 -ignorelength

In the second cmd window, type somthing like:
mplayer xxx.yyy -vc NULL -vo NULL -ao pcm:fast:file=\\.\pipe\1.wav -benchmark

This will create a pipe named "\\.\pipe\1.wav" and redirect neroAacEnc's stdin to the server end of the pipe.

Regards,

Z
-------------- next part --------------
A non-text attachment was scrubbed...
Name: NamedPipe.7z
Type: application/octet-stream
Size: 696 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20090427/d6550861/attachment.obj>


More information about the MPlayer-dev-eng mailing list