From 6e33f2b9addb9d89614ddaeff5f3cecaa5c7d11d Mon Sep 17 00:00:00 2001 From: ben Date: Fri, 28 Jul 2006 21:36:03 +0000 Subject: added audio output for ivtv cards git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@19229 b3059339-0415-0410-9bf9-f77b7e298cf2 --- configure | 3 + libao2/ao_ivtv.c | 162 +++++++++++++++++++++++++++++++++++++++++++++++++++++ libao2/audio_out.c | 8 ++- 3 files changed, 172 insertions(+), 1 deletion(-) create mode 100644 libao2/ao_ivtv.c diff --git a/configure b/configure index 798ee47ef8..703c2bdfdf 100755 --- a/configure +++ b/configure @@ -4701,9 +4701,12 @@ if test "$_ivtv" = yes ; then _def_ivtv='#define HAVE_IVTV 1' _vosrc="$_vosrc vo_ivtv.c" _vomodules="ivtv $_vomodules" + _aosrc="$_aosrc ao_ivtv.c" + _aomodules="ivtv $_aomodules" else _def_ivtv='#undef HAVE_IVTV' _novomodules="ivtv $_novomodules" + _noaomodules="ivtv $_noaomodules" fi echores "$_ivtv" diff --git a/libao2/ao_ivtv.c b/libao2/ao_ivtv.c new file mode 100644 index 0000000000..ea57bcf9c4 --- /dev/null +++ b/libao2/ao_ivtv.c @@ -0,0 +1,162 @@ +/* + * Copyright (C) 2006 Benjamin Zores + * Audio output for WinTV PVR-150/250/350 (a.k.a IVTV) cards. + * through Connexant hardware MPEG decoder. + * See http://ivtvdriver.org/index.php/Main_Page for more details on the + * cards supported by the ivtv driver. + * + * 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 + * (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. + * + * 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 + * + * WARNING: you need to force -ac hwmpa for audio output to work. + */ + +#include + +#include "config.h" + +#include "mp_msg.h" +#include "help_mp.h" + +#include "audio_out.h" +#include "audio_out_internal.h" +#include "libaf/af_format.h" +#include "libmpdemux/mpeg_packetizer.h" + +#define MPEG_AUDIO_ID 0x1C0 + +static int freq = 0; + +static ao_info_t info = +{ + "IVTV MPEG Audio Decoder output", + "ivtv", + "Benjamin Zores", + "" +}; + +LIBAO_EXTERN(ivtv) + +/* to set/get/query special features/parameters */ +static int +control (int cmd,void *arg) +{ + return CONTROL_UNKNOWN; +} + +/* open & setup audio device */ +static int +init (int rate, int channels, int format, int flags) +{ + extern int ivtv_fd; + + if (ivtv_fd < 0) + return 0; + + if (format != AF_FORMAT_MPEG2) + { + mp_msg (MSGT_AO, MSGL_FATAL, + "AO: [ivtv] can only handle MPEG audio streams.\n"); + return 0; + } + + ao_data.outburst = 2048; + ao_data.samplerate = rate; + ao_data.channels = channels; + ao_data.format = AF_FORMAT_MPEG2; + ao_data.buffersize = 2048; + ao_data.bps = rate * 2 * 2; + ao_data.pts = 0; + freq = rate; + + /* check for supported audio rate */ + if (rate != 32000 || rate != 41000 || rate != 48000) + { + mp_msg (MSGT_AO, MSGL_ERR, MSGTR_AO_MPEGPES_UnsupSamplerate, rate); + rate = 48000; + } + + return 1; +} + +/* close audio device */ +static void +uninit (int immed) +{ + /* nothing to do */ +} + +/* stop playing and empty buffers (for seeking/pause) */ +static void +reset (void) +{ + /* nothing to do */ +} + +/* stop playing, keep buffers (for pause) */ +static void +audio_pause (void) +{ + reset (); +} + +/* resume playing, after audio_pause() */ +static void +audio_resume (void) +{ + /* nothing to do */ +} + +/* how many bytes can be played without blocking */ +static int +get_space (void) +{ + extern int vo_pts; + float x; + int y; + + x = (float) (vo_pts - ao_data.pts) / 90000.0; + if (x <= 0) + return 0; + + y = freq * 4 * x; + y /= ao_data.outburst; + y *= ao_data.outburst; + + if (y > 32000) + y = 32000; + + return y; +} + +/* number of bytes played */ +static int +play (void *data, int len, int flags) +{ + extern int ivtv_write (unsigned char *data, int len); + + if (ao_data.format != AF_FORMAT_MPEG2) + return 0; + + send_mpeg_pes_packet (data, len, MPEG_AUDIO_ID, ao_data.pts, 2, ivtv_write); + + return len; +} + +/* delay in seconds between first and last sample in buffer */ +static float +get_delay (void) +{ + return 0.0; +} diff --git a/libao2/audio_out.c b/libao2/audio_out.c index a64b638803..45b037c329 100644 --- a/libao2/audio_out.c +++ b/libao2/audio_out.c @@ -65,17 +65,23 @@ extern ao_functions_t audio_out_dsound; #ifdef HAVE_DXR2 extern ao_functions_t audio_out_dxr2; #endif +#ifdef HAVE_IVTV +extern ao_functions_t audio_out_ivtv; +#endif extern ao_functions_t audio_out_mpegpes; extern ao_functions_t audio_out_pcm; extern ao_functions_t audio_out_pss; ao_functions_t* audio_out_drivers[] = { -// vo-related: will fail unless you also do -vo mpegpes/dxr2 +// vo-related: will fail unless you also do -vo mpegpes/dxr2/ivtv &audio_out_mpegpes, #ifdef HAVE_DXR2 &audio_out_dxr2, #endif +#ifdef HAVE_IVTV + &audio_out_ivtv, +#endif // native: #ifdef HAVE_DIRECTX &audio_out_dsound, -- cgit v1.2.3