/*****************************************************************************
* file.c : audio output which writes the samples to a file
*****************************************************************************
- * Copyright (C) 2002 the VideoLAN team
+ * Copyright (C) 2002 VLC authors and VideoLAN
* $Id$
*
* Authors: Christophe Massiot <massiot@via.ecp.fr>
* Gildas Bazin <gbazin@netcourrier.com>
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
*
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
/*****************************************************************************
# include "config.h"
#endif
+#include <stdio.h>
+#include <errno.h>
+
#include <vlc_common.h>
#include <vlc_plugin.h>
#include <vlc_aout.h>
* Local prototypes.
*****************************************************************************/
static int Open ( vlc_object_t * );
-static void Play ( audio_output_t *, block_t *, mtime_t * );
+static void Play ( audio_output_t *, block_t * );
+static void Flush ( audio_output_t *, bool );
/*****************************************************************************
* Module descriptor
#define WAV_LONGTEXT N_("Instead of writing a raw file, you can add a WAV " \
"header to the file.")
-static const char *const format_list[] = { "u8", "s8", "u16", "s16", "u16_le",
- "s16_le", "u16_be", "s16_be",
- "float32", "spdif" };
-static const int format_int[] = { VLC_CODEC_U8,
- VLC_CODEC_S8,
- VLC_CODEC_U16N, VLC_CODEC_S16N,
- VLC_CODEC_U16L,
- VLC_CODEC_S16L,
- VLC_CODEC_U16B,
- VLC_CODEC_S16B,
- VLC_CODEC_F32L,
- VLC_CODEC_SPDIFL };
+static const char *const format_list[] = {
+ "u8", "s16",
+#ifndef WORDS_BIGENDIAN
+ "float32",
+#endif
+ "spdif",
+};
+static const int format_int[] = {
+ VLC_CODEC_U8, VLC_CODEC_S16N,
+#ifndef WORDS_BIGENDIAN
+ VLC_CODEC_FL32,
+#endif
+ VLC_CODEC_SPDIFL,
+};
#define FILE_TEXT N_("Output file")
#define FILE_LONGTEXT N_("File to which the audio samples will be written to. (\"-\" for stdout")
return VLC_EGENERIC;
}
+ p_aout->time_get = NULL;
p_aout->play = Play;
p_aout->pause = NULL;
- p_aout->flush = NULL;
+ p_aout->flush = Flush;
/* Audio format */
psz_format = var_InheritString( p_aout, "audiofile-format" );
switch( fmt->i_format )
{
- case VLC_CODEC_F32L:
+#ifndef WORDS_BIGENDIAN
+ case VLC_CODEC_FL32:
wh->Format = WAVE_FORMAT_IEEE_FLOAT;
wh->BitsPerSample = sizeof(float) * 8;
break;
+#endif
case VLC_CODEC_U8:
wh->Format = WAVE_FORMAT_PCM;
wh->BitsPerSample = 8;
break;
- case VLC_CODEC_S16L:
default:
wh->Format = WAVE_FORMAT_PCM;
wh->BitsPerSample = 16;
if( fwrite( wh, sizeof(WAVEHEADER), 1,
p_aout->sys->p_file ) != 1 )
{
- msg_Err( p_aout, "write error (%m)" );
+ msg_Err( p_aout, "write error: %s", vlc_strerror_c(errno) );
}
}
/* Write Wave Header */
if( fseek( p_aout->sys->p_file, 0, SEEK_SET ) )
{
- msg_Err( p_aout, "seek error (%m)" );
+ msg_Err( p_aout, "seek error: %s", vlc_strerror_c(errno) );
}
/* Header -> little endian format */
if( fwrite( &p_aout->sys->waveh, sizeof(WAVEHEADER), 1,
p_aout->sys->p_file ) != 1 )
{
- msg_Err( p_aout, "write error (%m)" );
+ msg_Err( p_aout, "write error: %s", vlc_strerror_c(errno) );
}
}
/*****************************************************************************
* Play: pretend to play a sound
*****************************************************************************/
-static void Play( audio_output_t * p_aout, block_t *p_buffer,
- mtime_t *restrict drift )
+static void Play( audio_output_t * p_aout, block_t *p_buffer )
{
if( fwrite( p_buffer->p_buffer, p_buffer->i_buffer, 1,
p_aout->sys->p_file ) != 1 )
{
- msg_Err( p_aout, "write error (%m)" );
+ msg_Err( p_aout, "write error: %s", vlc_strerror_c(errno) );
}
if( p_aout->sys->b_add_wav_header )
}
block_Release( p_buffer );
- (void) drift;
+}
+
+static void Flush( audio_output_t *aout, bool wait )
+{
+ if( fflush( aout->sys->p_file ) )
+ msg_Err( aout, "flush error: %s", vlc_strerror_c(errno) );
+ (void) wait;
}
static int Open(vlc_object_t *obj)