summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUoti Urpala <uau@mplayer2.org>2012-02-27 16:29:21 +0200
committerUoti Urpala <uau@mplayer2.org>2012-02-27 16:46:56 +0200
commit9ab501443c37888ee0d286897ebb985b2056ba49 (patch)
treed300ec816d1154a7fe8f6da1890ff25b4a94b6ef
parent8d20859716db53fb6a2aa4975c8172a9d6aa7a3d (diff)
downloadmpv-9ab501443c37888ee0d286897ebb985b2056ba49.tar.bz2
mpv-9ab501443c37888ee0d286897ebb985b2056ba49.tar.xz
configure, ao_alsa: drop support for obsolete ALSA versions
Drop compatibility code for ALSA versions prior to 1.0.9. Change the configure check to use pkg-config only.
-rw-r--r--Makefile7
-rwxr-xr-xconfigure107
-rw-r--r--libao2/ao_alsa.c21
-rw-r--r--libao2/ao_alsa5.c383
-rw-r--r--libao2/audio_out.c4
-rw-r--r--stream/ai_alsa.c184
6 files changed, 11 insertions, 695 deletions
diff --git a/Makefile b/Makefile
index 55d69f9fa1..1b2d144091 100644
--- a/Makefile
+++ b/Makefile
@@ -23,8 +23,7 @@ include config.mak
###### variable declarations #######
-SRCS_AUDIO_INPUT-$(ALSA1X) += stream/ai_alsa1x.c
-SRCS_AUDIO_INPUT-$(ALSA9) += stream/ai_alsa.c
+SRCS_AUDIO_INPUT-$(ALSA) += stream/ai_alsa1x.c
SRCS_AUDIO_INPUT-$(OSS) += stream/ai_oss.c
SRCS_COMMON-$(AUDIO_INPUT) += $(SRCS_AUDIO_INPUT-yes)
SRCS_COMMON-$(BITMAP_FONT) += sub/font_load.c
@@ -431,9 +430,7 @@ SRCS_COMMON = asxparser.c \
SRCS_MPLAYER-$(3DFX) += libvo/vo_3dfx.c
SRCS_MPLAYER-$(AA) += libvo/vo_aa.c
-SRCS_MPLAYER-$(ALSA1X) += libao2/ao_alsa.c
-SRCS_MPLAYER-$(ALSA5) += libao2/ao_alsa5.c
-SRCS_MPLAYER-$(ALSA9) += libao2/ao_alsa.c
+SRCS_MPLAYER-$(ALSA) += libao2/ao_alsa.c
SRCS_MPLAYER-$(APPLE_IR) += input/appleir.c
SRCS_MPLAYER-$(APPLE_REMOTE) += input/ar.c
SRCS_MPLAYER-$(ARTS) += libao2/ao_arts.c
diff --git a/configure b/configure
index df7058aa73..ad4e1f9b46 100755
--- a/configure
+++ b/configure
@@ -4950,100 +4950,18 @@ if test "$_alloca" != yes ; then
_alsa=no
res_comment="alloca missing"
fi
-if test "$_alsa" != no ; then
- _alsa=no
- cat > $TMPC << EOF
-#include <sys/asoundlib.h>
-#if !((SND_LIB_MAJOR == 0) && (SND_LIB_MINOR == 5))
-#error "alsa version != 0.5.x"
-#endif
-int main(void) { return 0; }
-EOF
- cc_check -lasound $_ld_dl $_ld_pthread && _alsaver='0.5.x'
-
- cat > $TMPC << EOF
-#include <sys/asoundlib.h>
-#if !((SND_LIB_MAJOR == 0) && (SND_LIB_MINOR == 9))
-#error "alsa version != 0.9.x"
-#endif
-int main(void) { return 0; }
-EOF
- cc_check -lasound $_ld_dl $_ld_pthread && _alsaver='0.9.x-sys'
- cat > $TMPC << EOF
-#include <alsa/asoundlib.h>
-#if !((SND_LIB_MAJOR == 0) && (SND_LIB_MINOR == 9))
-#error "alsa version != 0.9.x"
-#endif
-int main(void) { return 0; }
-EOF
- cc_check -lasound $_ld_dl $_ld_pthread && _alsaver='0.9.x-alsa'
-
- cat > $TMPC << EOF
-#include <sys/asoundlib.h>
-#if !((SND_LIB_MAJOR == 1) && (SND_LIB_MINOR == 0))
-#error "alsa version != 1.0.x"
-#endif
-int main(void) { return 0; }
-EOF
- cc_check -lasound $_ld_dl $_ld_pthread && _alsaver='1.0.x-sys'
- cat > $TMPC << EOF
-#include <alsa/asoundlib.h>
-#if !((SND_LIB_MAJOR == 1) && (SND_LIB_MINOR == 0))
-#error "alsa version != 1.0.x"
-#endif
-int main(void) { return 0; }
-EOF
- cc_check -lasound $_ld_dl $_ld_pthread && _alsaver='1.0.x-alsa'
+if test "$_alsa" = auto ; then
+ _alsa=no
+ if pkg_config_add "alsa >= 1.0.9" ; then
+ _alsa=yes
+ fi
fi
def_alsa='#undef CONFIG_ALSA'
-def_alsa5='#undef CONFIG_ALSA5'
-def_alsa9='#undef CONFIG_ALSA9'
-def_alsa1x='#undef CONFIG_ALSA1X'
-def_sys_asoundlib_h='#undef HAVE_SYS_ASOUNDLIB_H'
-def_alsa_asoundlib_h='#undef HAVE_ALSA_ASOUNDLIB_H'
-if test "$_alsaver" ; then
- _alsa=yes
- if test "$_alsaver" = '0.5.x' ; then
- _alsa5=yes
- aomodules="alsa5 $aomodules"
- def_alsa5='#define CONFIG_ALSA5 1'
- def_sys_asoundlib_h='#define HAVE_SYS_ASOUNDLIB_H 1'
- res_comment="using alsa 0.5.x and sys/asoundlib.h"
- elif test "$_alsaver" = '0.9.x-sys' ; then
- _alsa9=yes
+if test "$_alsa" = yes ; then
aomodules="alsa $aomodules"
def_alsa='#define CONFIG_ALSA 1'
- def_alsa9='#define CONFIG_ALSA9 1'
- def_sys_asoundlib_h='#define HAVE_SYS_ASOUNDLIB_H 1'
- res_comment="using alsa 0.9.x and sys/asoundlib.h"
- elif test "$_alsaver" = '0.9.x-alsa' ; then
- _alsa9=yes
- aomodules="alsa $aomodules"
- def_alsa='#define CONFIG_ALSA 1'
- def_alsa9='#define CONFIG_ALSA9 1'
- def_alsa_asoundlib_h='#define HAVE_ALSA_ASOUNDLIB_H 1'
- res_comment="using alsa 0.9.x and alsa/asoundlib.h"
- elif test "$_alsaver" = '1.0.x-sys' ; then
- _alsa1x=yes
- aomodules="alsa $aomodules"
- def_alsa='#define CONFIG_ALSA 1'
- def_alsa1x="#define CONFIG_ALSA1X 1"
- def_alsa_asoundlib_h='#define HAVE_SYS_ASOUNDLIB_H 1'
- res_comment="using alsa 1.0.x and sys/asoundlib.h"
- elif test "$_alsaver" = '1.0.x-alsa' ; then
- _alsa1x=yes
- aomodules="alsa $aomodules"
- def_alsa='#define CONFIG_ALSA 1'
- def_alsa1x="#define CONFIG_ALSA1X 1"
- def_alsa_asoundlib_h='#define HAVE_ALSA_ASOUNDLIB_H 1'
- res_comment="using alsa 1.0.x and alsa/asoundlib.h"
- else
- _alsa=no
- res_comment="unknown version"
- fi
- extra_ldflags="$extra_ldflags -lasound $_ld_dl $_ld_pthread"
else
- noaomodules="alsa $noaomodules"
+ noaomodules="alsa $noaomodules"
fi
echores "$_alsa"
@@ -6115,7 +6033,7 @@ echocheck "Radio interface"
if test "$_radio" = yes ; then
def_radio='#define CONFIG_RADIO 1'
inputmodules="radio $inputmodules"
- if test "$_alsa9" != yes -a "$_alsa1x" != yes -a "$_ossaudio" != yes ; then
+ if test "$_alsa" != yes -a "$_ossaudio" != yes ; then
_radio_capture=no
fi
if test "$_radio_capture" = yes ; then
@@ -6508,9 +6426,7 @@ NEED_VSSCANF = $need_vsscanf
# features
3DFX = $_3dfx
AA = $_aa
-ALSA1X = $_alsa1x
-ALSA9 = $_alsa9
-ALSA5 = $_alsa5
+ALSA = $_alsa
APPLE_IR = $_apple_ir
APPLE_REMOTE = $_apple_remote
ARTS = $_arts
@@ -6720,13 +6636,11 @@ $def_dvdcss
/* system headers */
$def_alloca_h
-$def_alsa_asoundlib_h
$def_altivec_h
$def_malloc_h
$def_mman_h
$def_mman_has_map_failed
$def_soundcard_h
-$def_sys_asoundlib_h
$def_sys_soundcard_h
$def_sys_sysinfo_h
$def_sys_videoio_h
@@ -6853,9 +6767,6 @@ $def_xmms
/* Audio output drivers */
$def_alsa
-$def_alsa1x
-$def_alsa5
-$def_alsa9
$def_arts
$def_coreaudio
$def_dart
diff --git a/libao2/ao_alsa.c b/libao2/ao_alsa.c
index 1806a36d56..8ce80cdfbb 100644
--- a/libao2/ao_alsa.c
+++ b/libao2/ao_alsa.c
@@ -43,14 +43,7 @@
#define ALSA_PCM_NEW_HW_PARAMS_API
#define ALSA_PCM_NEW_SW_PARAMS_API
-#ifdef HAVE_SYS_ASOUNDLIB_H
-#include <sys/asoundlib.h>
-#elif defined(HAVE_ALSA_ASOUNDLIB_H)
#include <alsa/asoundlib.h>
-#else
-#error "asoundlib.h is not in sys/ or alsa/ - please bugreport"
-#endif
-
#include "audio_out.h"
#include "audio_out_internal.h"
@@ -342,11 +335,7 @@ static int init(int rate_hz, int channels, int format, int flags)
mp_msg(MSGT_AO,MSGL_V,"alsa-init: requested format: %d Hz, %d channels, %x\n", rate_hz,
channels, format);
alsa_handler = NULL;
-#if SND_LIB_VERSION >= 0x010005
mp_msg(MSGT_AO,MSGL_V,"alsa-init: using ALSA %s\n", snd_asoundlib_version());
-#else
- mp_msg(MSGT_AO,MSGL_V,"alsa-init: compiled for ALSA-%s\n", SND_LIB_VERSION_STR);
-#endif
prepause_frames = 0;
@@ -554,7 +543,6 @@ static int init(int rate_hz, int channels, int format, int flags)
/* workaround for buggy rate plugin (should be fixed in ALSA 1.0.11)
prefer our own resampler, since that allows users to choose the resampler,
even per file if desired */
-#if SND_LIB_VERSION >= 0x010009
if ((err = snd_pcm_hw_params_set_rate_resample(alsa_handler, alsa_hwparams,
0)) < 0)
{
@@ -562,7 +550,6 @@ static int init(int rate_hz, int channels, int format, int flags)
snd_strerror(err));
return 0;
}
-#endif
if ((err = snd_pcm_hw_params_set_rate_near(alsa_handler, alsa_hwparams,
&ao_data.samplerate, NULL)) < 0)
@@ -626,15 +613,11 @@ static int init(int rate_hz, int channels, int format, int flags)
snd_strerror(err));
return 0;
}
-#if SND_LIB_VERSION >= 0x000901
if ((err = snd_pcm_sw_params_get_boundary(alsa_swparams, &boundary)) < 0) {
mp_tmsg(MSGT_AO,MSGL_ERR,"[AO_ALSA] Unable to get boundary: %s\n",
snd_strerror(err));
return 0;
}
-#else
- boundary = 0x7fffffff;
-#endif
/* start playing when one period has been written */
if ((err = snd_pcm_sw_params_set_start_threshold(alsa_handler, alsa_swparams, chunk_size)) < 0) {
mp_tmsg(MSGT_AO,MSGL_ERR,"[AO_ALSA] Unable to set start threshold: %s\n",
@@ -647,14 +630,12 @@ static int init(int rate_hz, int channels, int format, int flags)
snd_strerror(err));
return 0;
}
-#if SND_LIB_VERSION >= 0x000901
/* play silence when there is an underrun */
if ((err = snd_pcm_sw_params_set_silence_size(alsa_handler, alsa_swparams, boundary)) < 0) {
mp_tmsg(MSGT_AO,MSGL_ERR,"[AO_ALSA] Unable to set silence size: %s\n",
snd_strerror(err));
return 0;
}
-#endif
if ((err = snd_pcm_sw_params(alsa_handler, alsa_swparams)) < 0) {
mp_tmsg(MSGT_AO,MSGL_ERR,"[AO_ALSA] Unable to get sw-parameters: %s\n",
snd_strerror(err));
@@ -851,9 +832,7 @@ static float get_delay(void)
if (delay < 0) {
/* underrun - move the application pointer forward to catch up */
-#if SND_LIB_VERSION >= 0x000901 /* snd_pcm_forward() exists since 0.9.0rc8 */
snd_pcm_forward(alsa_handler, -delay);
-#endif
delay = 0;
}
return (float)delay / (float)ao_data.samplerate;
diff --git a/libao2/ao_alsa5.c b/libao2/ao_alsa5.c
deleted file mode 100644
index d6ab7eeb22..0000000000
--- a/libao2/ao_alsa5.c
+++ /dev/null
@@ -1,383 +0,0 @@
-/*
- * ALSA 0.5.x audio output driver
- *
- * Copyright (C) 2001 Alex Beregszaszi
- *
- * Thanks to Arpi for helping me ;)
- *
- * MPlayer 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.
- *
- * MPlayer 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 MPlayer; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#include <errno.h>
-#include <sys/asoundlib.h>
-
-#include "config.h"
-
-#include "audio_out.h"
-#include "audio_out_internal.h"
-#include "libaf/af_format.h"
-
-#include "mp_msg.h"
-
-static const ao_info_t info =
-{
- "ALSA-0.5.x audio output",
- "alsa5",
- "Alex Beregszaszi",
- ""
-};
-
-LIBAO_EXTERN(alsa5)
-
-static snd_pcm_t *alsa_handler;
-static snd_pcm_format_t alsa_format;
-static int alsa_rate = SND_PCM_RATE_CONTINUOUS;
-
-/* to set/get/query special features/parameters */
-static int control(int cmd, void *arg)
-{
- return CONTROL_UNKNOWN;
-}
-
-/*
- open & setup audio device
- return: 1=success 0=fail
-*/
-static int init(int rate_hz, int channels, int format, int flags)
-{
- int err;
- int cards = -1;
- snd_pcm_channel_params_t params;
- snd_pcm_channel_setup_t setup;
- snd_pcm_info_t info;
- snd_pcm_channel_info_t chninfo;
-
- mp_tmsg(MSGT_AO, MSGL_INFO, "[AO ALSA5] alsa-init: requested format: %d Hz, %d channels, %s\n", rate_hz,
- channels, af_fmt2str_short(format));
-
- alsa_handler = NULL;
-
- mp_msg(MSGT_AO, MSGL_V, "alsa-init: compiled for ALSA-%s (%d)\n", SND_LIB_VERSION_STR,
- SND_LIB_VERSION);
-
- if ((cards = snd_cards()) < 0)
- {
- mp_tmsg(MSGT_AO, MSGL_ERR, "[AO ALSA5] alsa-init: no soundcards found.\n");
- return 0;
- }
-
- ao_data.format = format;
- ao_data.channels = channels;
- ao_data.samplerate = rate_hz;
- ao_data.bps = ao_data.samplerate*ao_data.channels;
- ao_data.outburst = OUTBURST;
- ao_data.buffersize = 16384;
-
- memset(&alsa_format, 0, sizeof(alsa_format));
- switch (format)
- {
- case AF_FORMAT_S8:
- alsa_format.format = SND_PCM_SFMT_S8;
- break;
- case AF_FORMAT_U8:
- alsa_format.format = SND_PCM_SFMT_U8;
- break;
- case AF_FORMAT_U16_LE:
- alsa_format.format = SND_PCM_SFMT_U16_LE;
- break;
- case AF_FORMAT_U16_BE:
- alsa_format.format = SND_PCM_SFMT_U16_BE;
- break;
- case AF_FORMAT_AC3_LE:
- case AF_FORMAT_S16_LE:
- alsa_format.format = SND_PCM_SFMT_S16_LE;
- break;
- case AF_FORMAT_AC3_BE:
- case AF_FORMAT_S16_BE:
- alsa_format.format = SND_PCM_SFMT_S16_BE;
- break;
- default:
- alsa_format.format = SND_PCM_SFMT_MPEG;
- break;
- }
-
- switch(alsa_format.format)
- {
- case SND_PCM_SFMT_S16_LE:
- case SND_PCM_SFMT_U16_LE:
- ao_data.bps *= 2;
- break;
- case -1:
- mp_tmsg(MSGT_AO, MSGL_ERR, "[AO ALSA5] alsa-init: invalid format (%s) requested - output disabled.\n",af_fmt2str_short(format));
- return 0;
- default:
- break;
- }
-
- switch(rate_hz)
- {
- case 8000:
- alsa_rate = SND_PCM_RATE_8000;
- break;
- case 11025:
- alsa_rate = SND_PCM_RATE_11025;
- break;
- case 16000:
- alsa_rate = SND_PCM_RATE_16000;
- break;
- case 22050:
- alsa_rate = SND_PCM_RATE_22050;
- break;
- case 32000:
- alsa_rate = SND_PCM_RATE_32000;
- break;
- case 44100:
- alsa_rate = SND_PCM_RATE_44100;
- break;
- case 48000:
- alsa_rate = SND_PCM_RATE_48000;
- break;
- case 88200:
- alsa_rate = SND_PCM_RATE_88200;
- break;
- case 96000:
- alsa_rate = SND_PCM_RATE_96000;
- break;
- case 176400:
- alsa_rate = SND_PCM_RATE_176400;
- break;
- case 192000:
- alsa_rate = SND_PCM_RATE_192000;
- break;
- default:
- alsa_rate = SND_PCM_RATE_CONTINUOUS;
- break;
- }
-
- alsa_format.rate = ao_data.samplerate;
- alsa_format.voices = ao_data.channels;
- alsa_format.interleave = 1;
-
- if ((err = snd_pcm_open(&alsa_handler, 0, 0, SND_PCM_OPEN_PLAYBACK)) < 0)
- {
- mp_tmsg(MSGT_AO, MSGL_ERR, "[AO ALSA5] alsa-init: playback open error: %s\n", snd_strerror(err));
- return 0;
- }
-
- if ((err = snd_pcm_info(alsa_handler, &info)) < 0)
- {
- mp_tmsg(MSGT_AO, MSGL_ERR, "[AO ALSA5] alsa-init: PCM info error: %s\n", snd_strerror(err));
- return 0;
- }
-
- mp_tmsg(MSGT_AO, MSGL_INFO, "[AO ALSA5] alsa-init: %d soundcard(s) found, using: %s\n",
- cards, info.name);
-
- if (info.flags & SND_PCM_INFO_PLAYBACK)
- {
- memset(&chninfo, 0, sizeof(chninfo));
- chninfo.channel = SND_PCM_CHANNEL_PLAYBACK;
- if ((err = snd_pcm_channel_info(alsa_handler, &chninfo)) < 0)
- {
- mp_tmsg(MSGT_AO, MSGL_ERR, "[AO ALSA5] alsa-init: PCM channel info error: %s\n", snd_strerror(err));
- return 0;
- }
-
-#ifndef __QNX__
- if (chninfo.buffer_size)
- ao_data.buffersize = chninfo.buffer_size;
-#endif
-
- mp_msg(MSGT_AO, MSGL_V, "alsa-init: setting preferred buffer size from driver: %d bytes\n",
- ao_data.buffersize);
- }
-
- memset(&params, 0, sizeof(params));
- params.channel = SND_PCM_CHANNEL_PLAYBACK;
- params.mode = SND_PCM_MODE_STREAM;
- params.format = alsa_format;
- params.start_mode = SND_PCM_START_DATA;
- params.stop_mode = SND_PCM_STOP_ROLLOVER;
- params.buf.stream.queue_size = ao_data.buffersize;
- params.buf.stream.fill = SND_PCM_FILL_NONE;
-
- if ((err = snd_pcm_channel_params(alsa_handler, &params)) < 0)
- {
- mp_tmsg(MSGT_AO, MSGL_ERR, "[AO ALSA5] alsa-init: error setting parameters: %s\n", snd_strerror(err));
- return 0;
- }
-
- memset(&setup, 0, sizeof(setup));
- setup.channel = SND_PCM_CHANNEL_PLAYBACK;
- setup.mode = SND_PCM_MODE_STREAM;
- setup.format = alsa_format;
- setup.buf.stream.queue_size = ao_data.buffersize;
- setup.msbits_per_sample = ao_data.bps;
-
- if ((err = snd_pcm_channel_setup(alsa_handler, &setup)) < 0)
- {
- mp_tmsg(MSGT_AO, MSGL_ERR, "[AO ALSA5] alsa-init: error setting up channel: %s\n", snd_strerror(err));
- return 0;
- }
-
- if ((err = snd_pcm_channel_prepare(alsa_handler, SND_PCM_CHANNEL_PLAYBACK)) < 0)
- {
- mp_tmsg(MSGT_AO, MSGL_ERR, "[AO ALSA5] alsa-init: channel prepare error: %s\n", snd_strerror(err));
- return 0;
- }
-
- mp_msg(MSGT_AO, MSGL_INFO, "AUDIO: %d Hz/%d channels/%d bps/%d bytes buffer/%s\n",
- ao_data.samplerate, ao_data.channels, ao_data.bps, ao_data.buffersize,
- snd_pcm_get_format_name(alsa_format.format));
- return 1;
-}
-
-/* close audio device */
-static void uninit(int immed)
-{
- int err;
-
- if ((err = snd_pcm_playback_drain(alsa_handler)) < 0)
- {
- mp_tmsg(MSGT_AO, MSGL_ERR, "[AO ALSA5] alsa-uninit: playback drain error: %s\n", snd_strerror(err));
- return;
- }
-
- if ((err = snd_pcm_channel_flush(alsa_handler, SND_PCM_CHANNEL_PLAYBACK)) < 0)
- {
- mp_tmsg(MSGT_AO, MSGL_ERR, "[AO ALSA5] alsa-uninit: playback flush error: %s\n", snd_strerror(err));
- return;
- }
-
- if ((err = snd_pcm_close(alsa_handler)) < 0)
- {
- mp_tmsg(MSGT_AO, MSGL_ERR, "[AO ALSA5] alsa-uninit: PCM close error: %s\n", snd_strerror(err));
- return;
- }
-}
-
-/* stop playing and empty buffers (for seeking/pause) */
-static void reset(void)
-{
- int err;
-
- if ((err = snd_pcm_playback_drain(alsa_handler)) < 0)
- {
- mp_tmsg(MSGT_AO, MSGL_ERR, "[AO ALSA5] alsa-reset: playback drain error: %s\n", snd_strerror(err));
- return;
- }
-
- if ((err = snd_pcm_channel_flush(alsa_handler, SND_PCM_CHANNEL_PLAYBACK)) < 0)
- {
- mp_tmsg(MSGT_AO, MSGL_ERR, "[AO ALSA5] alsa-reset: playback flush error: %s\n", snd_strerror(err));
- return;
- }
-
- if ((err = snd_pcm_channel_prepare(alsa_handler, SND_PCM_CHANNEL_PLAYBACK)) < 0)
- {
- mp_tmsg(MSGT_AO, MSGL_ERR, "[AO ALSA5] alsa-reset: channel prepare error: %s\n", snd_strerror(err));
- return;
- }
-}
-
-/* stop playing, keep buffers (for pause) */
-static void audio_pause(void)
-{
- int err;
-
- if ((err = snd_pcm_playback_drain(alsa_handler)) < 0)
- {
- mp_tmsg(MSGT_AO, MSGL_ERR, "[AO ALSA5] alsa-pause: playback drain error: %s\n", snd_strerror(err));
- return;
- }
-
- if ((err = snd_pcm_channel_flush(alsa_handler, SND_PCM_CHANNEL_PLAYBACK)) < 0)
- {
- mp_tmsg(MSGT_AO, MSGL_ERR, "[AO ALSA5] alsa-pause: playback flush error: %s\n", snd_strerror(err));
- return;
- }
-}
-
-/* resume playing, after audio_pause() */
-static void audio_resume(void)
-{
- int err;
- if ((err = snd_pcm_channel_prepare(alsa_handler, SND_PCM_CHANNEL_PLAYBACK)) < 0)
- {
- mp_tmsg(MSGT_AO, MSGL_ERR, "[AO ALSA5] alsa-resume: channel prepare error: %s\n", snd_strerror(err));
- return;
- }
-}
-
-/*
- plays 'len' bytes of 'data'
- returns: number of bytes played
-*/
-static int play(void* data, int len, int flags)
-{
- int got_len;
-
- if (!len)
- return 0;
-
- if ((got_len = snd_pcm_write(alsa_handler, data, len)) < 0)
- {
- if (got_len == -EPIPE) /* underrun? */
- {
- mp_tmsg(MSGT_AO, MSGL_ERR, "[AO ALSA5] alsa-play: alsa underrun, resetting stream.\n");
- if ((got_len = snd_pcm_channel_prepare(alsa_handler, SND_PCM_CHANNEL_PLAYBACK)) < 0)
- {
- mp_tmsg(MSGT_AO, MSGL_ERR, "[AO ALSA5] alsa-play: playback prepare error: %s\n", snd_strerror(got_len));
- return 0;
- }
- if ((got_len = snd_pcm_write(alsa_handler, data, len)) < 0)
- {
- mp_tmsg(MSGT_AO, MSGL_ERR, "[AO ALSA5] alsa-play: write error after reset: %s - giving up.\n",
- snd_strerror(got_len));
- return 0;
- }
- return got_len; /* 2nd write was ok */
- }
- mp_tmsg(MSGT_AO, MSGL_ERR, "[AO ALSA5] alsa-play: output error: %s\n", snd_strerror(got_len));
- return 0;
- }
- return got_len;
-}
-
-/* how many byes are free in the buffer */
-static int get_space(void)
-{
- snd_pcm_channel_status_t ch_stat;
-
- ch_stat.channel = SND_PCM_CHANNEL_PLAYBACK;
-
- if (snd_pcm_channel_status(alsa_handler, &ch_stat) < 0)
- return 0; /* error occurred */
- else
- return ch_stat.free;
-}
-
-/* delay in seconds between first and last sample in buffer */
-static float get_delay(void)
-{
- snd_pcm_channel_status_t ch_stat;
-
- ch_stat.channel = SND_PCM_CHANNEL_PLAYBACK;
-
- if (snd_pcm_channel_status(alsa_handler, &ch_stat) < 0)
- return (float)ao_data.buffersize/(float)ao_data.bps; /* error occurred */
- else
- return (float)ch_stat.count/(float)ao_data.bps;
-}
diff --git a/libao2/audio_out.c b/libao2/audio_out.c
index b1b5c0e901..a91a0d6d72 100644
--- a/libao2/audio_out.c
+++ b/libao2/audio_out.c
@@ -41,7 +41,6 @@ extern const struct ao_driver audio_out_pulse;
extern const struct ao_driver audio_out_jack;
extern const struct ao_driver audio_out_openal;
extern const struct ao_driver audio_out_null;
-extern const struct ao_driver audio_out_alsa5;
extern const struct ao_driver audio_out_alsa;
extern const struct ao_driver audio_out_nas;
extern const struct ao_driver audio_out_sdl;
@@ -83,9 +82,6 @@ static const struct ao_driver * const audio_out_drivers[] = {
#ifdef CONFIG_OSS_AUDIO
&audio_out_oss,
#endif
-#ifdef CONFIG_ALSA5
- &audio_out_alsa5,
-#endif
#ifdef CONFIG_SGI_AUDIO
&audio_out_sgi,
#endif
diff --git a/stream/ai_alsa.c b/stream/ai_alsa.c
deleted file mode 100644
index c5e2f3f623..0000000000
--- a/stream/ai_alsa.c
+++ /dev/null
@@ -1,184 +0,0 @@
-/*
- * This file is part of MPlayer.
- *
- * MPlayer 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.
- *
- * MPlayer 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 MPlayer; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/time.h>
-#include <alloca.h>
-
-#include "config.h"
-
-#include <alsa/asoundlib.h>
-#include "audio_in.h"
-#include "mp_msg.h"
-
-int ai_alsa_setup(audio_in_t *ai)
-{
- snd_pcm_hw_params_t *params;
- snd_pcm_sw_params_t *swparams;
- int buffer_size;
- int err;
- unsigned int rate;
-
- snd_pcm_hw_params_alloca(&params);
- snd_pcm_sw_params_alloca(&swparams);
-
- err = snd_pcm_hw_params_any(ai->alsa.handle, params);
- if (err < 0) {
- mp_tmsg(MSGT_TV, MSGL_ERR, "Broken configuration for this PCM: no configurations available.\n");
- return -1;
- }
- err = snd_pcm_hw_params_set_access(ai->alsa.handle, params,
- SND_PCM_ACCESS_RW_INTERLEAVED);
- if (err < 0) {
- mp_tmsg(MSGT_TV, MSGL_ERR, "Access type not available.\n");
- return -1;
- }
- err = snd_pcm_hw_params_set_format(ai->alsa.handle, params, SND_PCM_FORMAT_S16_LE);
- if (err < 0) {
- mp_tmsg(MSGT_TV, MSGL_ERR, "Sample format not available.\n");
- return -1;
- }
- err = snd_pcm_hw_params_set_channels(ai->alsa.handle, params, ai->req_channels);
- if (err < 0) {
- ai->channels = snd_pcm_hw_params_get_channels(params);
- mp_tmsg(MSGT_TV, MSGL_ERR, "Channel count not available - reverting to default: %d\n",
- ai->channels);
- } else {
- ai->channels = ai->req_channels;
- }
-
- err = snd_pcm_hw_params_set_rate_near(ai->alsa.handle, params, ai->req_samplerate, 0);
- assert(err >= 0);
- rate = err;
- ai->samplerate = rate;
-
- ai->alsa.buffer_time = 1000000;
- ai->alsa.buffer_time = snd_pcm_hw_params_set_buffer_time_near(ai->alsa.handle, params,
- ai->alsa.buffer_time, 0);
- assert(ai->alsa.buffer_time >= 0);
- ai->alsa.period_time = ai->alsa.buffer_time / 4;
- ai->alsa.period_time = snd_pcm_hw_params_set_period_time_near(ai->alsa.handle, params,
- ai->alsa.period_time, 0);
- assert(ai->alsa.period_time >= 0);
- err = snd_pcm_hw_params(ai->alsa.handle, params);
- if (err < 0) {
- mp_tmsg(MSGT_TV, MSGL_ERR, "Unable to install hardware parameters: %s");
- snd_pcm_hw_params_dump(params, ai->alsa.log);
- return -1;
- }
- ai->alsa.chunk_size = snd_pcm_hw_params_get_period_size(params, 0);
- buffer_size = snd_pcm_hw_params_get_buffer_size(params);
- if (ai->alsa.chunk_size == buffer_size) {
- mp_tmsg(MSGT_TV, MSGL_ERR, "Can't use period equal to buffer size (%u == %lu)\n", ai->alsa.chunk_size, (long)buffer_size);
- return -1;
- }
- snd_pcm_sw_params_current(ai->alsa.handle, swparams);
- err = snd_pcm_sw_params_set_sleep_min(ai->alsa.handle, swparams,0);
- assert(err >= 0);
- err = snd_pcm_sw_params_set_avail_min(ai->alsa.handle, swparams, ai->alsa.chunk_size);
- assert(err >= 0);
-
- err = snd_pcm_sw_params_set_start_threshold(ai->alsa.handle, swparams, 0);
- assert(err >= 0);
- err = snd_pcm_sw_params_set_stop_threshold(ai->alsa.handle, swparams, buffer_size);
- assert(err >= 0);
-
- assert(err >= 0);
- if (snd_pcm_sw_params(ai->alsa.handle, swparams) < 0) {
- mp_tmsg(MSGT_TV, MSGL_ERR, "Unable to install software parameters:\n");
- snd_pcm_sw_params_dump(swparams, ai->alsa.log);
- return -1;
- }
-
- if (mp_msg_test(MSGT_TV, MSGL_V)) {
- snd_pcm_dump(ai->alsa.handle, ai->alsa.log);
- }
-
- ai->alsa.bits_per_sample = snd_pcm_format_physical_width(SND_PCM_FORMAT_S16_LE);
- ai->alsa.bits_per_frame = ai->alsa.bits_per_sample * ai->channels;
- ai->blocksize = ai->alsa.chunk_size * ai->alsa.bits_per_frame / 8;
- ai->samplesize = ai->alsa.bits_per_sample;
- ai->bytes_per_sample = ai->alsa.bits_per_sample/8;
-
- return 0;
-}
-
-int ai_alsa_init(audio_in_t *ai)
-{
- int err;
-
- err = snd_pcm_open(&ai->alsa.handle, ai->alsa.device, SND_PCM_STREAM_CAPTURE, 0);
- if (err < 0) {
- mp_tmsg(MSGT_TV, MSGL_ERR, "Error opening audio: %s\n", snd_strerror(err));
- return -1;
- }
-
- err = snd_output_stdio_attach(&ai->alsa.log, stderr, 0);
-
- if (err < 0) {
- return -1;
- }
-
- err = ai_alsa_setup(ai);
-
- return err;
-}
-
-#ifndef timersub
-#define timersub(a, b, result) \
-do { \
- (result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \
- (result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \
- if ((result)->tv_usec < 0) { \
- --(result)->tv_sec; \
- (result)->tv_usec += 1000000; \
- } \
-} while (0)
-#endif
-
-int ai_alsa_xrun(audio_in_t *ai)
-{
- snd_pcm_status_t *status;
- int res;
-
- snd_pcm_status_alloca(&status);
- if ((res = snd_pcm_status(ai->alsa.handle, status))<0) {
- mp_tmsg(MSGT_TV, MSGL_ERR, "ALSA status error: %s", snd_strerror(res));
- return -1;
- }
- if (snd_pcm_status_get_state(status) == SND_PCM_STATE_XRUN) {
- struct timeval now, diff, tstamp;
- gettimeofday(&now, 0);
- snd_pcm_status_get_trigger_tstamp(status, &tstamp);
- timersub(&now, &tstamp, &diff);
- mp_tmsg(MSGT_TV, MSGL_ERR, "ALSA xrun!!! (at least %.3f ms long)\n",
- diff.tv_sec * 1000 + diff.tv_usec / 1000.0);
- if (mp_msg_test(MSGT_TV, MSGL_V)) {
- mp_tmsg(MSGT_TV, MSGL_ERR, "ALSA Status:\n");
- snd_pcm_status_dump(status, ai->alsa.log);
- }
- if ((res = snd_pcm_prepare(ai->alsa.handle))<0) {
- mp_tmsg(MSGT_TV, MSGL_ERR, "ALSA xrun: prepare error: %s", snd_strerror(res));
- return -1;
- }
- return 0; /* ok, data should be accepted again */
- }
- mp_tmsg(MSGT_TV, MSGL_ERR, "ALSA read/write error");
- return -1;
-}