From db8cdc73e38c3490389212d94ae9b92dfddd5975 Mon Sep 17 00:00:00 2001 From: Uoti Urpala Date: Sat, 28 Jan 2012 13:41:36 +0200 Subject: Update Libav API uses Change various code to use the latest Libav API. The libavcodec error_recognition setting has been removed and replaced with different semantics. I removed the "--lavdopts=er=" option accordingly, as I don't think it's widely enough used to be worth attempting to emulate the old option semantics using the new API. A new option with the new semantics can be added later if needed. Libav dropped APIs that were necessary with all Libav versions until quite recently (like setting avctx->age), and it would thus not be possible to keep compatibility with previous Libav versions without adding workarounds. The new APIs also had some bugs/limitations in the recent Libav release 0.8, and it would not work fully (at least some avcodec options would not be set correctly). Because of those issues, this commit makes no attempt to maintain compatibility with anything but the latest Libav git head. Hopefully the required fixes and improvements will be included in a following Libav point release. --- stream/stream_ffmpeg.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'stream') diff --git a/stream/stream_ffmpeg.c b/stream/stream_ffmpeg.c index 74e9db791c..a76b9e5f3b 100644 --- a/stream/stream_ffmpeg.c +++ b/stream/stream_ffmpeg.c @@ -101,9 +101,9 @@ static int open_f(stream_t *stream, int mode, void *opts, int *file_format) int dummy; if (mode == STREAM_READ) - flags = URL_RDONLY; + flags = AVIO_FLAG_READ; else if (mode == STREAM_WRITE) - flags = URL_WRONLY; + flags = AVIO_FLAG_WRITE; else { mp_msg(MSGT_OPEN, MSGL_ERR, "[ffmpeg] Unknown open mode %d\n", mode); res = STREAM_UNSUPPORTED; -- cgit v1.2.3 From fc6a9e4a3e0278e1a1f5c0bf570667306f716fed Mon Sep 17 00:00:00 2001 From: Uoti Urpala Date: Wed, 1 Feb 2012 20:01:16 +0200 Subject: build: switch to libavutil bswap.h and intreadwrite.h Remove the private bswap and intreadwrite.h implementations and use libavutil headers instead. Originally these headers weren't publicly installed by libavutil at all. That already changed in 2010, but the pure C bswap version in installed headers was very inefficient. That was recently (2011-12) improved and now using the public bswap version probably shouldn't cause noticeable performance problems, at least if using a new enough compiler. --- stream/asf_streaming.c | 4 ++-- stream/pnm.c | 8 ++++---- stream/realrtsp/real.c | 14 +++++++------- stream/realrtsp/rmff.c | 3 ++- stream/stream.c | 6 +++--- stream/stream_dvd_common.c | 7 +++++-- stream/vcd_read.h | 4 +++- stream/vcd_read_fbsd.h | 4 +++- 8 files changed, 29 insertions(+), 21 deletions(-) (limited to 'stream') diff --git a/stream/asf_streaming.c b/stream/asf_streaming.c index 73197f4f54..8c747abfdf 100644 --- a/stream/asf_streaming.c +++ b/stream/asf_streaming.c @@ -23,6 +23,8 @@ #include #include +#include + #include "config.h" #include "mp_msg.h" #include "options.h" @@ -41,8 +43,6 @@ #include "network.h" #include "tcp.h" -#include "ffmpeg_files/intreadwrite.h" - #include "libmpdemux/asfguid.h" extern int network_bandwidth; diff --git a/stream/pnm.c b/stream/pnm.c index 46c22361d9..b1baad70a3 100644 --- a/stream/pnm.c +++ b/stream/pnm.c @@ -23,8 +23,6 @@ * based upon code from joschka */ -#include "config.h" - #include #include #include @@ -35,6 +33,10 @@ #include #include #include + +#include + +#include "config.h" #if !HAVE_WINSOCK2_H #include //#include @@ -43,8 +45,6 @@ #include #endif -#include "ffmpeg_files/intreadwrite.h" - #include "stream.h" #include "libmpdemux/demuxer.h" #include "osdep/timer.h" diff --git a/stream/realrtsp/real.c b/stream/realrtsp/real.c index 3d06b4d667..daee0cd34a 100644 --- a/stream/realrtsp/real.c +++ b/stream/realrtsp/real.c @@ -30,18 +30,18 @@ #include #include +#include +#include +#include +#include +#include +#include + #include "config.h" -#include "libavutil/common.h" -#include "libavutil/attributes.h" #include "real.h" #include "asmrp.h" #include "sdpplin.h" #include "xbuffer.h" -#include "libavutil/md5.h" -#include "ffmpeg_files/intreadwrite.h" -#include "libavutil/base64.h" - -#include #include "stream/http.h" #include "mp_msg.h" diff --git a/stream/realrtsp/rmff.c b/stream/realrtsp/rmff.c index d538222141..d85e696727 100644 --- a/stream/realrtsp/rmff.c +++ b/stream/realrtsp/rmff.c @@ -26,10 +26,11 @@ * adopted from joschkas real tools */ +#include + #include "rmff.h" #include "xbuffer.h" #include "mp_msg.h" -#include "ffmpeg_files/intreadwrite.h" /* #define LOG diff --git a/stream/stream.c b/stream/stream.c index 99225ca3b4..772c87dd9c 100644 --- a/stream/stream.c +++ b/stream/stream.c @@ -30,6 +30,9 @@ #include #include +#include +#include + #include "talloc.h" #include "config.h" @@ -38,15 +41,12 @@ #include #endif -#include - #include "mp_msg.h" #include "osdep/shmem.h" #include "osdep/timer.h" #include "network.h" #include "stream.h" #include "libmpdemux/demuxer.h" -#include "ffmpeg_files/intreadwrite.h" #include "m_option.h" #include "m_struct.h" diff --git a/stream/stream_dvd_common.c b/stream/stream_dvd_common.c index b2f3a14fee..db566e5136 100644 --- a/stream/stream_dvd_common.c +++ b/stream/stream_dvd_common.c @@ -16,13 +16,17 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include "config.h" #include #include #include #include #include +#include + +#include "config.h" + #include + #ifdef __FreeBSD__ #include #endif @@ -37,7 +41,6 @@ #include "mp_msg.h" #include "stream_dvd_common.h" -#include "ffmpeg_files/intreadwrite.h" const char * const dvd_audio_stream_types[8] = { "ac3","unknown","mpeg1","mpeg2ext","lpcm","unknown","dts" }; const char * const dvd_audio_stream_channels[6] = { "mono", "stereo", "unknown", "unknown", "5.1/6.1", "5.1" }; diff --git a/stream/vcd_read.h b/stream/vcd_read.h index 8b8d2ab817..ed435e3317 100644 --- a/stream/vcd_read.h +++ b/stream/vcd_read.h @@ -23,9 +23,11 @@ #include #include #include + +#include + #include "mp_msg.h" #include "stream.h" -#include "ffmpeg_files/intreadwrite.h" //=================== VideoCD ========================== #if defined(__linux__) || defined(sun) || defined(__bsdi__) diff --git a/stream/vcd_read_fbsd.h b/stream/vcd_read_fbsd.h index 8a59a2a8ee..406cb902da 100644 --- a/stream/vcd_read_fbsd.h +++ b/stream/vcd_read_fbsd.h @@ -24,9 +24,11 @@ #include #include #include -#include "ffmpeg_files/intreadwrite.h" #include #include + +#include + #if defined(__NetBSD__) || defined(__OpenBSD__) #define VCD_NETBSD 1 #endif -- cgit v1.2.3 From 9ab501443c37888ee0d286897ebb985b2056ba49 Mon Sep 17 00:00:00 2001 From: Uoti Urpala Date: Mon, 27 Feb 2012 16:29:21 +0200 Subject: 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. --- stream/ai_alsa.c | 184 ------------------------------------------------------- 1 file changed, 184 deletions(-) delete mode 100644 stream/ai_alsa.c (limited to 'stream') 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 -#include -#include -#include - -#include "config.h" - -#include -#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(¶ms); - 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; -} -- cgit v1.2.3