summaryrefslogtreecommitdiffstats
path: root/stream
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2019-09-13 17:16:18 +0200
committerwm4 <wm4@nowhere>2019-09-13 17:32:19 +0200
commitb30e85508a305d668db8419556d295a65ab08707 (patch)
treefa48444a183c97fd5081aa0206c5adece43eaf32 /stream
parent162e0f5ad92116d1a4fb740d087da2a152686b73 (diff)
downloadmpv-b30e85508a305d668db8419556d295a65ab08707.tar.bz2
mpv-b30e85508a305d668db8419556d295a65ab08707.tar.xz
Remove classic Linux analog TV support, and DVB runtime controls
Linux analog TV support (via tv://) was excessively complex, and whenever I attempted to use it (cameras or loopback devices), it didn't work well, or would have required some major work to update it. It's very much stuck in the analog past (my favorite are the frequency tables in frequencies.c for analog TV channels which don't exist anymore). Especially cameras and such work fine with libavdevice and better than tv://, for example: mpv av://v4l2:/dev/video0 (adding --profile=low-latency --untimed even makes it mostly realtime) Adding a new input layer that targets such "modern" uses would be acceptable, if anyone is interested in it. The old TV code is just too focused on actual analog TV. DVB is rather obscure, but has an active maintainer, so don't remove it. However, the demux/stream ctrl layer must go, so remove controls for channel switching. Most of these could be reimplemented by using the normal method for option runtime changes.
Diffstat (limited to 'stream')
-rw-r--r--stream/ai_alsa1x.c199
-rw-r--r--stream/ai_oss.c153
-rw-r--r--stream/ai_sndio.c52
-rw-r--r--stream/audio_in.c298
-rw-r--r--stream/audio_in.h118
-rw-r--r--stream/frequencies.c1212
-rw-r--r--stream/frequencies.h133
-rw-r--r--stream/stream.c4
-rw-r--r--stream/stream.h24
-rw-r--r--stream/stream_dvb.c5
-rw-r--r--stream/stream_tv.c52
-rw-r--r--stream/tv.c986
-rw-r--r--stream/tv.h285
-rw-r--r--stream/tvi_def.h93
-rw-r--r--stream/tvi_dummy.c126
-rw-r--r--stream/tvi_v4l2.c1786
16 files changed, 4 insertions, 5522 deletions
diff --git a/stream/ai_alsa1x.c b/stream/ai_alsa1x.c
deleted file mode 100644
index 8f2b774faf..0000000000
--- a/stream/ai_alsa1x.c
+++ /dev/null
@@ -1,199 +0,0 @@
-/*
- * This file is part of mpv.
- *
- * mpv 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.
- *
- * mpv 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 mpv. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/time.h>
-
-#include "config.h"
-
-#include <alsa/asoundlib.h>
-#include "audio_in.h"
-#include "common/msg.h"
-
-int ai_alsa_setup(audio_in_t *ai)
-{
- snd_pcm_hw_params_t *params;
- snd_pcm_sw_params_t *swparams;
- snd_pcm_uframes_t buffer_size, period_size;
- int err;
- int dir;
- 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_ERR(ai, "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_ERR(ai, "Access type not available.\n");
- return -1;
- }
-
- err = snd_pcm_hw_params_set_format(ai->alsa.handle, params, SND_PCM_FORMAT_S16);
- if (err < 0) {
- MP_ERR(ai, "Sample format not available.\n");
- return -1;
- }
-
- err = snd_pcm_hw_params_set_channels(ai->alsa.handle, params, ai->req_channels);
- if (err < 0) {
- snd_pcm_hw_params_get_channels(params, &ai->channels);
- MP_ERR(ai, "Channel count not available - reverting to default: %d\n",
- ai->channels);
- } else {
- ai->channels = ai->req_channels;
- }
-
- dir = 0;
- rate = ai->req_samplerate;
- err = snd_pcm_hw_params_set_rate_near(ai->alsa.handle, params, &rate, &dir);
- if (err < 0) {
- MP_ERR(ai, "Cannot set samplerate.\n");
- }
- ai->samplerate = rate;
-
- dir = 0;
- ai->alsa.buffer_time = 1000000;
- err = snd_pcm_hw_params_set_buffer_time_near(ai->alsa.handle, params,
- &ai->alsa.buffer_time, &dir);
- if (err < 0) {
- MP_ERR(ai, "Cannot set buffer time.\n");
- }
-
- dir = 0;
- ai->alsa.period_time = ai->alsa.buffer_time / 4;
- err = snd_pcm_hw_params_set_period_time_near(ai->alsa.handle, params,
- &ai->alsa.period_time, &dir);
- if (err < 0) {
- MP_ERR(ai, "Cannot set period time.\n");
- }
-
- err = snd_pcm_hw_params(ai->alsa.handle, params);
- if (err < 0) {
- MP_ERR(ai, "Unable to install hardware parameters: %s", snd_strerror(err));
- snd_pcm_hw_params_dump(params, ai->alsa.log);
- return -1;
- }
-
- dir = -1;
- snd_pcm_hw_params_get_period_size(params, &period_size, &dir);
- snd_pcm_hw_params_get_buffer_size(params, &buffer_size);
- ai->alsa.chunk_size = period_size;
- if (period_size == buffer_size) {
- MP_ERR(ai, "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_avail_min(ai->alsa.handle, swparams, ai->alsa.chunk_size);
-
- err = snd_pcm_sw_params_set_start_threshold(ai->alsa.handle, swparams, 0);
- err = snd_pcm_sw_params_set_stop_threshold(ai->alsa.handle, swparams, buffer_size);
-
- if (snd_pcm_sw_params(ai->alsa.handle, swparams) < 0) {
- MP_ERR(ai, "Unable to install software parameters:\n");
- snd_pcm_sw_params_dump(swparams, ai->alsa.log);
- return -1;
- }
-
- if (mp_msg_test(ai->log, 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);
- 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;
-
- const char *device = ai->alsa.device;
- if (!device)
- device = "default";
-
- err = snd_pcm_open(&ai->alsa.handle, device, SND_PCM_STREAM_CAPTURE, 0);
- if (err < 0) {
- MP_ERR(ai, "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_ERR(ai, "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_ERR(ai, "ALSA xrun!!! (at least %.3f ms long)\n",
- diff.tv_sec * 1000 + diff.tv_usec / 1000.0);
- if (mp_msg_test(ai->log, MSGL_V)) {
- MP_ERR(ai, "ALSA Status:\n");
- snd_pcm_status_dump(status, ai->alsa.log);
- }
- if ((res = snd_pcm_prepare(ai->alsa.handle))<0) {
- MP_ERR(ai, "ALSA xrun: prepare error: %s", snd_strerror(res));
- return -1;
- }
- return 0; /* ok, data should be accepted again */
- }
- MP_ERR(ai, "ALSA read/write error");
- return -1;
-}
diff --git a/stream/ai_oss.c b/stream/ai_oss.c
deleted file mode 100644
index bc22691be5..0000000000
--- a/stream/ai_oss.c
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * This file is part of mpv.
- *
- * mpv 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.
- *
- * mpv 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 mpv. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "config.h"
-
-#include <string.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <sys/ioctl.h>
-
-#include <sys/soundcard.h>
-
-#include "osdep/io.h"
-
-#include "audio_in.h"
-#include "common/common.h"
-#include "common/msg.h"
-
-int ai_oss_set_samplerate(audio_in_t *ai)
-{
- int tmp = ai->req_samplerate;
- if (ioctl(ai->oss.audio_fd, SNDCTL_DSP_SPEED, &tmp) == -1) return -1;
- ai->samplerate = tmp;
- return 0;
-}
-
-int ai_oss_set_channels(audio_in_t *ai)
-{
- int err;
- int ioctl_param;
-
- if (ai->req_channels > 2)
- {
- ioctl_param = ai->req_channels;
- MP_VERBOSE(ai, "ioctl dsp channels: %d\n",
- err = ioctl(ai->oss.audio_fd, SNDCTL_DSP_CHANNELS, &ioctl_param));
- if (err < 0) {
- MP_ERR(ai, "Unable to set channel count: %d\n",
- ai->req_channels);
- return -1;
- }
- ai->channels = ioctl_param;
- }
- else
- {
- ioctl_param = (ai->req_channels == 2);
- MP_VERBOSE(ai, "ioctl dsp stereo: %d (req: %d)\n",
- err = ioctl(ai->oss.audio_fd, SNDCTL_DSP_STEREO, &ioctl_param),
- ioctl_param);
- if (err < 0) {
- MP_ERR(ai, "Unable to set stereo: %d\n",
- ai->req_channels == 2);
- return -1;
- }
- ai->channels = ioctl_param ? 2 : 1;
- }
- return 0;
-}
-
-int ai_oss_init(audio_in_t *ai)
-{
- int err;
- int ioctl_param;
-
- const char *device = ai->oss.device;
- if (!device)
- device = "/dev/dsp";
-
- ai->oss.audio_fd = open(device, O_RDONLY | O_CLOEXEC);
- if (ai->oss.audio_fd < 0)
- {
- MP_ERR(ai, "Unable to open '%s': %s\n", device, mp_strerror(errno));
- return -1;
- }
-
- ioctl_param = 0 ;
- MP_VERBOSE(ai, "ioctl dsp getfmt: %d\n",
- ioctl(ai->oss.audio_fd, SNDCTL_DSP_GETFMTS, &ioctl_param));
-
- MP_VERBOSE(ai, "Supported formats: %x\n", ioctl_param);
- if (!(ioctl_param & AFMT_S16_NE))
- MP_ERR(ai, "unsupported format\n");
-
- ioctl_param = AFMT_S16_NE;
- MP_VERBOSE(ai, "ioctl dsp setfmt: %d\n",
- err = ioctl(ai->oss.audio_fd, SNDCTL_DSP_SETFMT, &ioctl_param));
- if (err < 0) {
- MP_ERR(ai, "Unable to set audio format.");
- return -1;
- }
-
- if (ai_oss_set_channels(ai) < 0) return -1;
-
- ioctl_param = ai->req_samplerate;
- MP_VERBOSE(ai, "ioctl dsp speed: %d\n",
- err = ioctl(ai->oss.audio_fd, SNDCTL_DSP_SPEED, &ioctl_param));
- if (err < 0) {
- MP_ERR(ai, "Unable to set samplerate: %d\n",
- ai->req_samplerate);
- return -1;
- }
- ai->samplerate = ioctl_param;
-
- MP_VERBOSE(ai, "ioctl dsp trigger: %d\n",
- ioctl(ai->oss.audio_fd, SNDCTL_DSP_GETTRIGGER, &ioctl_param));
- MP_VERBOSE(ai, "trigger: %x\n", ioctl_param);
- ioctl_param = PCM_ENABLE_INPUT;
- MP_VERBOSE(ai, "ioctl dsp trigger: %d\n",
- err = ioctl(ai->oss.audio_fd, SNDCTL_DSP_SETTRIGGER, &ioctl_param));
- if (err < 0) {
- MP_ERR(ai, "Unable to set trigger: %d\n",
- PCM_ENABLE_INPUT);
- }
-
- ai->blocksize = 0;
- MP_VERBOSE(ai, "ioctl dsp getblocksize: %d\n",
- err = ioctl(ai->oss.audio_fd, SNDCTL_DSP_GETBLKSIZE, &ai->blocksize));
- if (err < 0) {
- MP_ERR(ai, "Unable to get block size!\n");
- }
- MP_VERBOSE(ai, "blocksize: %d\n", ai->blocksize);
-
- // correct the blocksize to a reasonable value
- if (ai->blocksize <= 0) {
- ai->blocksize = 4096*ai->channels*2;
- MP_ERR(ai, "Audio block size is zero, setting to %d!\n", ai->blocksize);
- } else if (ai->blocksize < 4096*ai->channels*2) {
- ai->blocksize *= 4096*ai->channels*2/ai->blocksize;
- MP_ERR(ai, "Audio block size too low, setting to %d!\n", ai->blocksize);
- }
-
- ai->samplesize = 16;
- ai->bytes_per_sample = 2;
-
- return 0;
-}
diff --git a/stream/ai_sndio.c b/stream/ai_sndio.c
deleted file mode 100644
index 10e95cea62..0000000000
--- a/stream/ai_sndio.c
+++ /dev/null
@@ -1,52 +0,0 @@
-#include <stdio.h>
-#include <stdlib.h>
-
-#include "config.h"
-
-#include <sndio.h>
-#include "audio_in.h"
-#include "common/msg.h"
-
-int ai_sndio_setup(audio_in_t *ai)
-{
- struct sio_par par;
-
- sio_initpar(&par);
-
- par.bits = 16;
- par.sig = 1;
- par.le = SIO_LE_NATIVE;
- par.rchan = ai->req_channels;
- par.rate = ai->req_samplerate;
- par.appbufsz = ai->req_samplerate; /* 1 sec */
-
- if (!sio_setpar(ai->sndio.hdl, &par) || !sio_getpar(ai->sndio.hdl, &par)) {
- MP_ERR(ai, "could not configure sndio audio");
- return -1;
- }
-
- ai->channels = par.rchan;
- ai->samplerate = par.rate;
- ai->samplesize = par.bits;
- ai->bytes_per_sample = par.bps;
- ai->blocksize = par.round * par.bps;
-
- return 0;
-}
-
-int ai_sndio_init(audio_in_t *ai)
-{
- int err;
-
- const char *device = ai->sndio.device;
- if (!device)
- device = "default";
- if ((ai->sndio.hdl = sio_open(device, SIO_REC, 0)) == NULL) {
- MP_ERR(ai, "could not open sndio audio");
- return -1;
- }
-
- err = ai_sndio_setup(ai);
-
- return err;
-}
diff --git a/stream/audio_in.c b/stream/audio_in.c
deleted file mode 100644
index 8ed92767c1..0000000000
--- a/stream/audio_in.c
+++ /dev/null
@@ -1,298 +0,0 @@
-/*
- * This file is part of mpv.
- *
- * mpv 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.
- *
- * mpv 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 mpv. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-
-#include "config.h"
-
-#include "audio_in.h"
-#include "common/common.h"
-#include "common/msg.h"
-#include <string.h>
-#include <errno.h>
-
-// sanitizes ai structure before calling other functions
-int audio_in_init(audio_in_t *ai, struct mp_log *log, int type)
-{
- ai->type = type;
- ai->setup = 0;
- ai->log = log;
-
- ai->channels = -1;
- ai->samplerate = -1;
- ai->blocksize = -1;
- ai->bytes_per_sample = -1;
- ai->samplesize = -1;
-
- switch (ai->type) {
-#if HAVE_ALSA
- case AUDIO_IN_ALSA:
- ai->alsa.handle = NULL;
- ai->alsa.log = NULL;
- ai->alsa.device = NULL;
- return 0;
-#endif
-#if HAVE_OSS_AUDIO
- case AUDIO_IN_OSS:
- ai->oss.audio_fd = -1;
- ai->oss.device = NULL;
- return 0;
-#endif
-#if HAVE_SNDIO
- case AUDIO_IN_SNDIO:
- ai->sndio.hdl = NULL;
- ai->sndio.device = NULL;
- return 0;
-#endif
- default:
- return -1;
- }
-}
-
-int audio_in_setup(audio_in_t *ai)
-{
-
- switch (ai->type) {
-#if HAVE_ALSA
- case AUDIO_IN_ALSA:
- if (ai_alsa_init(ai) < 0) return -1;
- ai->setup = 1;
- return 0;
-#endif
-#if HAVE_OSS_AUDIO
- case AUDIO_IN_OSS:
- if (ai_oss_init(ai) < 0) return -1;
- ai->setup = 1;
- return 0;
-#endif
-#if HAVE_SNDIO
- case AUDIO_IN_SNDIO:
- if (ai_sndio_init(ai) < 0) return -1;
- ai->setup = 1;
- return 0;
-#endif
- default:
- return -1;
- }
-}
-
-int audio_in_set_samplerate(audio_in_t *ai, int rate)
-{
- switch (ai->type) {
-#if HAVE_ALSA
- case AUDIO_IN_ALSA:
- ai->req_samplerate = rate;
- if (!ai->setup) return 0;
- if (ai_alsa_setup(ai) < 0) return -1;
- return ai->samplerate;
-#endif
-#if HAVE_OSS_AUDIO
- case AUDIO_IN_OSS:
- ai->req_samplerate = rate;
- if (!ai->setup) return 0;
- if (ai_oss_set_samplerate(ai) < 0) return -1;
- return ai->samplerate;
-#endif
-#if HAVE_SNDIO
- case AUDIO_IN_SNDIO:
- ai->req_samplerate = rate;
- if (!ai->setup) return 0;
- if (ai_sndio_setup(ai) < 0) return -1;
- return ai->samplerate;
-#endif
- default:
- return -1;
- }
-}
-
-int audio_in_set_channels(audio_in_t *ai, int channels)
-{
- switch (ai->type) {
-#if HAVE_ALSA
- case AUDIO_IN_ALSA:
- ai->req_channels = channels;
- if (!ai->setup) return 0;
- if (ai_alsa_setup(ai) < 0) return -1;
- return ai->channels;
-#endif
-#if HAVE_OSS_AUDIO
- case AUDIO_IN_OSS:
- ai->req_channels = channels;
- if (!ai->setup) return 0;
- if (ai_oss_set_channels(ai) < 0) return -1;
- return ai->channels;
-#endif
-#if HAVE_SNDIO
- case AUDIO_IN_SNDIO:
- ai->req_channels = channels;
- if (!ai->setup) return 0;
- if (ai_sndio_setup(ai) < 0) return -1;
- return ai->channels;
-#endif
- default:
- return -1;
- }
-}
-
-int audio_in_set_device(audio_in_t *ai, char *device)
-{
-#if HAVE_ALSA
- int i;
-#endif
- if (ai->setup) return -1;
- switch (ai->type) {
-#if HAVE_ALSA
- case AUDIO_IN_ALSA:
- free(ai->alsa.device);
- ai->alsa.device = strdup(device);
- if (ai->alsa.device) {
- /* mplayer could not handle colons in arguments */
- for (i = 0; i < (int)strlen(ai->alsa.device); i++) {
- if (ai->alsa.device[i] == '.') ai->alsa.device[i] = ':';
- }
- }
- return 0;
-#endif
-#if HAVE_OSS_AUDIO
- case AUDIO_IN_OSS:
- free(ai->oss.device);
- ai->oss.device = strdup(device);
- return 0;
-#endif
-#if HAVE_SNDIO
- case AUDIO_IN_SNDIO:
- if (ai->sndio.device) free(ai->sndio.device);
- ai->sndio.device = strdup(device);
- return 0;
-#endif
- default:
- return -1;
- }
-}
-
-int audio_in_uninit(audio_in_t *ai)
-{
- if (ai->setup) {
- switch (ai->type) {
-#if HAVE_ALSA
- case AUDIO_IN_ALSA:
- if (ai->alsa.log)
- snd_output_close(ai->alsa.log);
- if (ai->alsa.handle) {
- snd_pcm_close(ai->alsa.handle);
- }
- ai->setup = 0;
- return 0;
-#endif
-#if HAVE_OSS_AUDIO
- case AUDIO_IN_OSS:
- close(ai->oss.audio_fd);
- ai->setup = 0;
- return 0;
-#endif
-#if HAVE_SNDIO
- case AUDIO_IN_SNDIO:
- if (ai->sndio.hdl)
- sio_close(ai->sndio.hdl);
- ai->setup = 0;
- return 0;
-#endif
- }
- }
- return -1;
-}
-
-int audio_in_start_capture(audio_in_t *ai)
-{
- switch (ai->type) {
-#if HAVE_ALSA
- case AUDIO_IN_ALSA:
- return snd_pcm_start(ai->alsa.handle);
-#endif
-#if HAVE_OSS_AUDIO
- case AUDIO_IN_OSS:
- return 0;
-#endif
-#if HAVE_SNDIO
- case AUDIO_IN_SNDIO:
- if (!sio_start(ai->sndio.hdl))
- return -1;
- return 0;
-#endif
- default:
- return -1;
- }
-}
-
-int audio_in_read_chunk(audio_in_t *ai, unsigned char *buffer)
-{
- int ret;
-
- switch (ai->type) {
-#if HAVE_ALSA
- case AUDIO_IN_ALSA:
- ret = snd_pcm_readi(ai->alsa.handle, buffer, ai->alsa.chunk_size);
- if (ret != ai->alsa.chunk_size) {
- if (ret < 0) {
- MP_ERR(ai, "\nError reading audio: %s\n", snd_strerror(ret));
- if (ret == -EPIPE) {
- if (ai_alsa_xrun(ai) == 0) {
- MP_ERR(ai, "Recovered from cross-run, some frames may be left out!\n");
- } else {
- MP_ERR(ai, "Fatal error, cannot recover!\n");
- }
- }
- } else {
- MP_ERR(ai, "\nNot enough audio samples!\n");
- }
- return -1;
- }
- return ret;
-#endif
-#if HAVE_OSS_AUDIO
- case AUDIO_IN_OSS:
- ret = read(ai->oss.audio_fd, buffer, ai->blocksize);
- if (ret != ai->blocksize) {
- if (ret < 0) {
- MP_ERR(ai, "\nError reading audio: %s\n", mp_strerror(errno));
-
- } else {
- MP_ERR(ai, "\nNot enough audio samples!\n");
- }
- return -1;
- }
- return ret;
-#endif
-#if HAVE_SNDIO
- case AUDIO_IN_SNDIO:
- ret = sio_read(ai->sndio.hdl, buffer, ai->blocksize);
- if (ret != ai->blocksize) {
- if (ret < 0) {
- MP_ERR(ai, "\nError reading audio: %s\n", mp_strerror(errno));
- } else {
- MP_ERR(ai, "\nNot enough audio samples!\n");
- }
- return -1;
- }
- return ret;
-#endif
- default:
- return -1;
- }
-}
diff --git a/stream/audio_in.h b/stream/audio_in.h
deleted file mode 100644
index 6b714f7306..0000000000
--- a/stream/audio_in.h
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * This file is part of mpv.
- *
- * mpv 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.
- *
- * mpv 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 mpv. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef MPLAYER_AUDIO_IN_H
-#define MPLAYER_AUDIO_IN_H
-
-#define AUDIO_IN_ALSA 1
-#define AUDIO_IN_OSS 2
-#define AUDIO_IN_SNDIO 3
-
-#include "config.h"
-
-#if !HAVE_GPL
-#error GPL only
-#endif
-
-struct mp_log;
-
-#if HAVE_ALSA
-#include <alsa/asoundlib.h>
-
-typedef struct {
- char *device;
-
- snd_pcm_t *handle;
- snd_output_t *log;
- int buffer_time, period_time, chunk_size;
- size_t bits_per_sample, bits_per_frame;
-} ai_alsa_t;
-#endif
-
-#if HAVE_OSS_AUDIO
-typedef struct {
- char *device;
-
- int audio_fd;
-} ai_oss_t;
-#endif
-
-#if HAVE_SNDIO
-#include <sndio.h>
-
-typedef struct {
- char *device;
-
- struct sio_hdl *hdl;
-} ai_sndio_t;
-#endif
-
-typedef struct
-{
- struct mp_log *log;
- int type;
- int setup;
-
- /* requested values */
- int req_channels;
- int req_samplerate;
-
- /* real values read-only */
- int channels;
- int samplerate;
- int blocksize;
- int bytes_per_sample;
- int samplesize;
-
-#if HAVE_ALSA
- ai_alsa_t alsa;
-#endif
-#if HAVE_OSS_AUDIO
- ai_oss_t oss;
-#endif
-#if HAVE_SNDIO
- ai_sndio_t sndio;
-#endif
-} audio_in_t;
-
-int audio_in_init(audio_in_t *ai, struct mp_log *log, int type);
-int audio_in_setup(audio_in_t *ai);
-int audio_in_set_device(audio_in_t *ai, char *device);
-int audio_in_set_samplerate(audio_in_t *ai, int rate);
-int audio_in_set_channels(audio_in_t *ai, int channels);
-int audio_in_uninit(audio_in_t *ai);
-int audio_in_start_capture(audio_in_t *ai);
-int audio_in_read_chunk(audio_in_t *ai, unsigned char *buffer);
-
-#if HAVE_ALSA
-int ai_alsa_setup(audio_in_t *ai);
-int ai_alsa_init(audio_in_t *ai);
-int ai_alsa_xrun(audio_in_t *ai);
-#endif
-
-#if HAVE_OSS_AUDIO
-int ai_oss_set_samplerate(audio_in_t *ai);
-int ai_oss_set_channels(audio_in_t *ai);
-int ai_oss_init(audio_in_t *ai);
-#endif
-
-#if HAVE_SNDIO
-int ai_sndio_setup(audio_in_t *ai);
-int ai_sndio_init(audio_in_t *ai);
-#endif
-
-#endif /* MPLAYER_AUDIO_IN_H */
diff --git a/stream/frequencies.c b/stream/frequencies.c
deleted file mode 100644
index 2e4027c680..0000000000
--- a/stream/frequencies.c
+++ /dev/null
@@ -1,1212 +0,0 @@
-/*
- * This file is part of mpv.
- *
- * mpv 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.
- *
- * mpv 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 mpv. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <stdlib.h>
-#include <sys/time.h>
-
-#include "frequencies.h"
-
-/* --------------------------------------------------------------------- */
-
-/* US broadcast */
-static const struct CHANLIST ntsc_bcast[] = {
- { "2", 55250 },
- { "3", 61250 },
- { "4", 67250 },
- { "5", 77250 },
- { "6", 83250 },
- { "7", 175250 },
- { "8", 181250 },
- { "9", 187250 },
- { "10", 193250 },
- { "11", 199250 },
- { "12", 205250 },
- { "13", 211250 },
- { "14", 471250 },
- { "15", 477250 },
- { "16", 483250 },
- { "17", 489250 },
- { "18", 495250 },
- { "19", 501250 },
- { "20", 507250 },
- { "21", 513250 },
- { "22", 519250 },
- { "23", 525250 },
- { "24", 531250 },
- { "25", 537250 },
- { "26", 543250 },
- { "27", 549250 },
- { "28", 555250 },
- { "29", 561250 },
- { "30", 567250 },
- { "31", 573250 },
- { "32", 579250 },
- { "33", 585250 },
- { "34", 591250 },
- { "35", 597250 },
- { "36", 603250 },
- { "37", 609250 },
- { "38", 615250 },
- { "39", 621250 },
- { "40", 627250 },
- { "41", 633250 },
- { "42", 639250 },
- { "43", 645250 },
- { "44", 651250 },
- { "45", 657250 },
- { "46", 663250 },
- { "47", 669250 },
- { "48", 675250 },
- { "49", 681250 },
- { "50", 687250 },
- { "51", 693250 },
- { "52", 699250 },
- { "53", 705250 },
- { "54", 711250 },
- { "55", 717250 },
- { "56", 723250 },
- { "57", 729250 },
- { "58", 735250 },
- { "59", 741250 },
- { "60", 747250 },
- { "61", 753250 },
- { "62", 759250 },
- { "63", 765250 },
- { "64", 771250 },
- { "65", 777250 },
- { "66", 783250 },
- { "67", 789250 },
- { "68", 795250 },
- { "69", 801250 },
-
- { "70", 807250 },
- { "71", 813250 },
- { "72", 819250 },
- { "73", 825250 },
- { "74", 831250 },
- { "75", 837250 },
- { "76", 843250 },
- { "77", 849250 },
- { "78", 855250 },
- { "79", 861250 },
- { "80", 867250 },
- { "81", 873250 },
- { "82", 879250 },
- { "83", 885250 },
-};
-
-/* US cable */
-static const struct CHANLIST ntsc_cable[] = {
- { "1", 73250 },
- { "2", 55250 },
- { "3", 61250 },
- { "4", 67250 },
- { "5", 77250 },
- { "6", 83250 },
- { "7", 175250 },
- { "8", 181250 },
- { "9", 187250 },
- { "10", 193250 },
- { "11", 199250 },
- { "12", 205250 },
-
- { "13", 211250 },
- { "14", 121250 },
- { "15", 127250 },
- { "16", 133250 },
- { "17", 139250 },
- { "18", 145250 },
- { "19", 151250 },
- { "20", 157250 },
-
- { "21", 163250 },
- { "22", 169250 },
- { "23", 217250 },
- { "24", 223250 },
- { "25", 229250 },
- { "26", 235250 },
- { "27", 241250 },
- { "28", 247250 },
- { "29", 253250 },
- { "30", 259250 },
- { "31", 265250 },<