2010-01-30 22:26:47 +00:00
|
|
|
/*
|
2013-07-12 20:11:08 +00:00
|
|
|
* Original author: Albeu
|
|
|
|
*
|
2015-04-13 07:36:54 +00:00
|
|
|
* This file is part of mpv.
|
|
|
|
*
|
|
|
|
* mpv is free software; you can redistribute it and/or modify
|
2010-01-30 22:26:47 +00:00
|
|
|
* 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.
|
|
|
|
*
|
2015-04-13 07:36:54 +00:00
|
|
|
* mpv is distributed in the hope that it will be useful,
|
2010-01-30 22:26:47 +00:00
|
|
|
* 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
|
2015-04-13 07:36:54 +00:00
|
|
|
* with mpv. If not, see <http://www.gnu.org/licenses/>.
|
2010-01-30 22:26:47 +00:00
|
|
|
*/
|
|
|
|
|
2023-10-18 16:16:51 +00:00
|
|
|
#include <stdbool.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
2013-01-23 21:39:24 +00:00
|
|
|
|
|
|
|
#include <cdio/cdio.h>
|
|
|
|
|
2023-10-18 16:16:51 +00:00
|
|
|
// For cdio_cddap_version
|
2023-10-14 14:12:17 +00:00
|
|
|
#pragma GCC diagnostic push
|
|
|
|
#pragma GCC diagnostic ignored "-Wstrict-prototypes"
|
2024-06-04 20:18:27 +00:00
|
|
|
#ifndef TESTING_IS_FINISHED
|
|
|
|
// Suppress Wundef warning
|
|
|
|
#define TESTING_IS_FINISHED 0
|
|
|
|
#endif
|
2013-01-23 21:39:24 +00:00
|
|
|
#include <cdio/paranoia/cdda.h>
|
|
|
|
#include <cdio/paranoia/paranoia.h>
|
2023-10-14 14:12:17 +00:00
|
|
|
#pragma GCC diagnostic pop
|
2012-03-14 05:36:46 +00:00
|
|
|
|
2023-10-18 16:16:51 +00:00
|
|
|
#include "common/msg.h"
|
|
|
|
#include "config.h"
|
2016-01-11 18:03:40 +00:00
|
|
|
#include "mpv_talloc.h"
|
2011-07-30 01:03:47 +00:00
|
|
|
|
2002-06-11 14:29:51 +00:00
|
|
|
#include "stream.h"
|
2013-12-17 01:02:25 +00:00
|
|
|
#include "options/m_option.h"
|
2014-06-10 18:46:15 +00:00
|
|
|
#include "options/m_config.h"
|
|
|
|
#include "options/options.h"
|
2002-06-11 14:29:51 +00:00
|
|
|
|
2017-10-10 13:51:16 +00:00
|
|
|
#if !HAVE_GPL
|
|
|
|
#error GPL only
|
|
|
|
#endif
|
|
|
|
|
2014-06-10 18:46:15 +00:00
|
|
|
typedef struct cdda_params {
|
2012-03-20 23:31:54 +00:00
|
|
|
cdrom_drive_t *cd;
|
|
|
|
cdrom_paranoia_t *cdp;
|
|
|
|
int sector;
|
|
|
|
int start_sector;
|
|
|
|
int end_sector;
|
2020-02-02 01:15:51 +00:00
|
|
|
uint8_t *data;
|
|
|
|
size_t data_pos;
|
2010-06-21 10:19:01 +00:00
|
|
|
|
2013-08-02 15:02:34 +00:00
|
|
|
// options
|
2023-09-19 21:14:24 +00:00
|
|
|
char *cdda_device;
|
2012-03-20 23:31:54 +00:00
|
|
|
int speed;
|
|
|
|
int paranoia_mode;
|
|
|
|
int sector_size;
|
|
|
|
int search_overlap;
|
|
|
|
int toc_offset;
|
2023-02-20 03:32:50 +00:00
|
|
|
bool skip;
|
2012-03-20 23:31:54 +00:00
|
|
|
char *device;
|
2013-04-20 23:43:09 +00:00
|
|
|
int span[2];
|
2023-02-20 03:32:50 +00:00
|
|
|
bool cdtext;
|
2013-08-02 15:02:34 +00:00
|
|
|
} cdda_priv;
|
|
|
|
|
2014-06-10 18:46:15 +00:00
|
|
|
#define OPT_BASE_STRUCT struct cdda_params
|
|
|
|
const struct m_sub_options stream_cdda_conf = {
|
|
|
|
.opts = (const m_option_t[]) {
|
2023-09-19 21:14:24 +00:00
|
|
|
{"device", OPT_STRING(cdda_device), .flags = M_OPT_FILE},
|
options: change option macros and all option declarations
Change all OPT_* macros such that they don't define the entire m_option
initializer, and instead expand only to a part of it, which sets certain
fields. This requires changing almost every option declaration, because
they all use these macros. A declaration now always starts with
{"name", ...
followed by designated initializers only (possibly wrapped in macros).
The OPT_* macros now initialize the .offset and .type fields only,
sometimes also .priv and others.
I think this change makes the option macros less tricky. The old code
had to stuff everything into macro arguments (and attempted to allow
setting arbitrary fields by letting the user pass designated
initializers in the vararg parts). Some of this was made messy due to
C99 and C11 not allowing 0-sized varargs with ',' removal. It's also
possible that this change is pointless, other than cosmetic preferences.
Not too happy about some things. For example, the OPT_CHOICE()
indentation I applied looks a bit ugly.
Much of this change was done with regex search&replace, but some places
required manual editing. In particular, code in "obscure" areas (which I
didn't include in compilation) might be broken now.
In wayland_common.c the author of some option declarations confused the
flags parameter with the default value (though the default value was
also properly set below). I fixed this with this change.
2020-03-14 20:28:01 +00:00
|
|
|
{"speed", OPT_INT(speed), M_RANGE(1, 100)},
|
|
|
|
{"paranoia", OPT_INT(paranoia_mode), M_RANGE(0, 2)},
|
|
|
|
{"sector-size", OPT_INT(sector_size), M_RANGE(1, 100)},
|
|
|
|
{"overlap", OPT_INT(search_overlap), M_RANGE(0, 75)},
|
|
|
|
{"toc-offset", OPT_INT(toc_offset)},
|
2023-02-20 03:32:50 +00:00
|
|
|
{"skip", OPT_BOOL(skip)},
|
options: change option macros and all option declarations
Change all OPT_* macros such that they don't define the entire m_option
initializer, and instead expand only to a part of it, which sets certain
fields. This requires changing almost every option declaration, because
they all use these macros. A declaration now always starts with
{"name", ...
followed by designated initializers only (possibly wrapped in macros).
The OPT_* macros now initialize the .offset and .type fields only,
sometimes also .priv and others.
I think this change makes the option macros less tricky. The old code
had to stuff everything into macro arguments (and attempted to allow
setting arbitrary fields by letting the user pass designated
initializers in the vararg parts). Some of this was made messy due to
C99 and C11 not allowing 0-sized varargs with ',' removal. It's also
possible that this change is pointless, other than cosmetic preferences.
Not too happy about some things. For example, the OPT_CHOICE()
indentation I applied looks a bit ugly.
Much of this change was done with regex search&replace, but some places
required manual editing. In particular, code in "obscure" areas (which I
didn't include in compilation) might be broken now.
In wayland_common.c the author of some option declarations confused the
flags parameter with the default value (though the default value was
also properly set below). I fixed this with this change.
2020-03-14 20:28:01 +00:00
|
|
|
{"span-a", OPT_INT(span[0])},
|
|
|
|
{"span-b", OPT_INT(span[1])},
|
2023-02-20 03:32:50 +00:00
|
|
|
{"cdtext", OPT_BOOL(cdtext)},
|
2014-06-10 18:46:15 +00:00
|
|
|
{0}
|
|
|
|
},
|
|
|
|
.size = sizeof(struct cdda_params),
|
|
|
|
.defaults = &(const struct cdda_params){
|
|
|
|
.search_overlap = -1,
|
2023-02-20 03:32:50 +00:00
|
|
|
.skip = true,
|
2014-06-10 18:46:15 +00:00
|
|
|
},
|
2002-06-11 14:29:51 +00:00
|
|
|
};
|
|
|
|
|
2014-06-10 21:56:05 +00:00
|
|
|
static const char *const cdtext_name[] = {
|
2013-01-23 21:39:24 +00:00
|
|
|
[CDTEXT_FIELD_ARRANGER] = "Arranger",
|
|
|
|
[CDTEXT_FIELD_COMPOSER] = "Composer",
|
|
|
|
[CDTEXT_FIELD_MESSAGE] = "Message",
|
|
|
|
[CDTEXT_FIELD_ISRC] = "ISRC",
|
|
|
|
[CDTEXT_FIELD_PERFORMER] = "Performer",
|
|
|
|
[CDTEXT_FIELD_SONGWRITER] = "Songwriter",
|
|
|
|
[CDTEXT_FIELD_TITLE] = "Title",
|
|
|
|
[CDTEXT_FIELD_UPC_EAN] = "UPC_EAN",
|
2012-03-14 05:36:46 +00:00
|
|
|
};
|
|
|
|
|
2015-03-03 14:29:07 +00:00
|
|
|
static void print_cdtext(stream_t *s, int track)
|
2012-03-14 05:36:46 +00:00
|
|
|
{
|
|
|
|
cdda_priv* p = (cdda_priv*)s->priv;
|
2015-03-03 14:29:07 +00:00
|
|
|
if (!p->cdtext)
|
|
|
|
return;
|
2013-01-23 21:39:24 +00:00
|
|
|
cdtext_t *text = cdio_get_cdtext(p->cd->p_cdio);
|
2014-03-26 15:57:38 +00:00
|
|
|
int header = 0;
|
2012-03-14 05:36:46 +00:00
|
|
|
if (text) {
|
|
|
|
for (int i = 0; i < sizeof(cdtext_name) / sizeof(cdtext_name[0]); i++) {
|
|
|
|
const char *name = cdtext_name[i];
|
2013-01-23 21:39:24 +00:00
|
|
|
const char *value = cdtext_get_const(text, i, track);
|
2014-03-26 15:57:38 +00:00
|
|
|
if (name && value) {
|
|
|
|
if (!header)
|
|
|
|
MP_INFO(s, "CD-Text (%s):\n", track ? "track" : "CD");
|
|
|
|
header = 1;
|
2013-12-21 19:36:45 +00:00
|
|
|
MP_INFO(s, " %s: '%s'\n", name, value);
|
2014-03-26 15:57:38 +00:00
|
|
|
}
|
2012-03-14 05:36:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void print_track_info(stream_t *s, int track)
|
|
|
|
{
|
2014-03-26 15:55:27 +00:00
|
|
|
MP_INFO(s, "Switched to track %d\n", track);
|
|
|
|
print_cdtext(s, track);
|
2012-03-14 05:36:46 +00:00
|
|
|
}
|
|
|
|
|
2012-03-20 23:31:54 +00:00
|
|
|
static void cdparanoia_callback(long int inpos, paranoia_cb_mode_t function)
|
|
|
|
{
|
2010-06-21 10:40:30 +00:00
|
|
|
}
|
|
|
|
|
2019-11-07 14:28:50 +00:00
|
|
|
static int fill_buffer(stream_t *s, void *buffer, int max_len)
|
2012-03-20 23:31:54 +00:00
|
|
|
{
|
|
|
|
cdda_priv *p = (cdda_priv *)s->priv;
|
2010-06-21 10:40:30 +00:00
|
|
|
|
2020-02-02 01:15:51 +00:00
|
|
|
if (!p->data || p->data_pos >= CDIO_CD_FRAMESIZE_RAW) {
|
|
|
|
if ((p->sector < p->start_sector) || (p->sector > p->end_sector))
|
|
|
|
return 0;
|
2013-06-05 00:04:21 +00:00
|
|
|
|
2020-02-02 01:15:51 +00:00
|
|
|
p->data_pos = 0;
|
|
|
|
p->data = (uint8_t *)paranoia_read(p->cdp, cdparanoia_callback);
|
|
|
|
if (!p->data)
|
|
|
|
return 0;
|
2010-06-21 10:40:30 +00:00
|
|
|
|
2020-02-02 01:15:51 +00:00
|
|
|
p->sector++;
|
|
|
|
}
|
2010-06-21 10:40:30 +00:00
|
|
|
|
2020-02-02 01:15:51 +00:00
|
|
|
size_t copy = MPMIN(CDIO_CD_FRAMESIZE_RAW - p->data_pos, max_len);
|
|
|
|
memcpy(buffer, p->data + p->data_pos, copy);
|
|
|
|
p->data_pos += copy;
|
|
|
|
return copy;
|
2010-06-21 10:40:30 +00:00
|
|
|
}
|
|
|
|
|
2012-11-18 19:46:12 +00:00
|
|
|
static int seek(stream_t *s, int64_t newpos)
|
2012-03-20 23:31:54 +00:00
|
|
|
{
|
|
|
|
cdda_priv *p = (cdda_priv *)s->priv;
|
|
|
|
int sec;
|
|
|
|
int current_track = 0, seeked_track = 0;
|
|
|
|
int seek_to_track = 0;
|
|
|
|
int i;
|
|
|
|
|
2014-05-24 15:07:13 +00:00
|
|
|
newpos += p->start_sector * CDIO_CD_FRAMESIZE_RAW;
|
2014-05-24 12:03:07 +00:00
|
|
|
|
2013-08-22 16:23:33 +00:00
|
|
|
sec = newpos / CDIO_CD_FRAMESIZE_RAW;
|
|
|
|
if (newpos < 0 || sec > p->end_sector) {
|
2012-03-20 23:31:54 +00:00
|
|
|
p->sector = p->end_sector + 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < p->cd->tracks; i++) {
|
|
|
|
if (p->sector >= p->cd->disc_toc[i].dwStartSector
|
|
|
|
&& p->sector < p->cd->disc_toc[i + 1].dwStartSector)
|
|
|
|
current_track = i;
|
|
|
|
if (sec >= p->cd->disc_toc[i].dwStartSector
|
|
|
|
&& sec < p->cd->disc_toc[i + 1].dwStartSector)
|
|
|
|
{
|
|
|
|
seeked_track = i;
|
|
|
|
seek_to_track = sec == p->cd->disc_toc[i].dwStartSector;
|
|
|
|
}
|
|
|
|
}
|
2012-03-14 05:36:46 +00:00
|
|
|
if (current_track != seeked_track && !seek_to_track)
|
|
|
|
print_track_info(s, seeked_track + 1);
|
2010-06-21 10:40:30 +00:00
|
|
|
|
2012-03-20 23:31:54 +00:00
|
|
|
p->sector = sec;
|
2010-06-21 10:40:30 +00:00
|
|
|
|
2012-03-20 23:31:54 +00:00
|
|
|
paranoia_seek(p->cdp, sec, SEEK_SET);
|
|
|
|
return 1;
|
2010-06-21 10:40:30 +00:00
|
|
|
}
|
|
|
|
|
2012-03-20 23:31:54 +00:00
|
|
|
static void close_cdda(stream_t *s)
|
|
|
|
{
|
|
|
|
cdda_priv *p = (cdda_priv *)s->priv;
|
|
|
|
paranoia_free(p->cdp);
|
|
|
|
cdda_close(p->cd);
|
2010-06-21 10:40:30 +00:00
|
|
|
}
|
2003-04-02 19:29:26 +00:00
|
|
|
|
2019-10-02 22:22:18 +00:00
|
|
|
static int get_track_by_sector(cdda_priv *p, unsigned int sector)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
for (i = p->cd->tracks; i >= 0; --i)
|
|
|
|
if (p->cd->disc_toc[i].dwStartSector <= sector)
|
|
|
|
break;
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
2012-03-20 23:31:54 +00:00
|
|
|
static int control(stream_t *stream, int cmd, void *arg)
|
|
|
|
{
|
|
|
|
cdda_priv *p = stream->priv;
|
|
|
|
switch (cmd) {
|
2019-10-02 22:22:18 +00:00
|
|
|
case STREAM_CTRL_GET_NUM_CHAPTERS:
|
|
|
|
{
|
|
|
|
int start_track = get_track_by_sector(p, p->start_sector);
|
|
|
|
int end_track = get_track_by_sector(p, p->end_sector);
|
|
|
|
if (start_track == -1 || end_track == -1)
|
|
|
|
return STREAM_ERROR;
|
|
|
|
*(unsigned int *)arg = end_track + 1 - start_track;
|
|
|
|
return STREAM_OK;
|
|
|
|
}
|
|
|
|
case STREAM_CTRL_GET_CHAPTER_TIME:
|
|
|
|
{
|
|
|
|
int track = *(double *)arg;
|
|
|
|
int start_track = get_track_by_sector(p, p->start_sector);
|
|
|
|
int end_track = get_track_by_sector(p, p->end_sector);
|
|
|
|
track += start_track;
|
|
|
|
if (track > end_track)
|
|
|
|
return STREAM_ERROR;
|
|
|
|
int64_t sector = p->cd->disc_toc[track].dwStartSector;
|
|
|
|
int64_t pos = sector * CDIO_CD_FRAMESIZE_RAW;
|
|
|
|
// Assume standard audio CD: 44.1khz, 2 channels, s16 samples
|
|
|
|
*(double *)arg = pos / (44100.0 * 2 * 2);
|
|
|
|
return STREAM_OK;
|
|
|
|
}
|
2007-12-17 15:20:28 +00:00
|
|
|
}
|
2012-03-20 23:31:54 +00:00
|
|
|
return STREAM_UNSUPPORTED;
|
2007-12-17 15:20:28 +00:00
|
|
|
}
|
|
|
|
|
2019-11-07 14:54:34 +00:00
|
|
|
static int64_t get_size(stream_t *st)
|
|
|
|
{
|
|
|
|
cdda_priv *p = st->priv;
|
|
|
|
return (p->end_sector + 1 - p->start_sector) * CDIO_CD_FRAMESIZE_RAW;
|
|
|
|
}
|
|
|
|
|
2014-05-24 12:06:13 +00:00
|
|
|
static int open_cdda(stream_t *st)
|
2012-03-20 23:31:54 +00:00
|
|
|
{
|
2016-09-09 15:39:22 +00:00
|
|
|
st->priv = mp_get_config_group(st, st->global, &stream_cdda_conf);
|
2013-08-02 15:02:34 +00:00
|
|
|
cdda_priv *priv = st->priv;
|
|
|
|
cdda_priv *p = priv;
|
2012-03-20 23:31:54 +00:00
|
|
|
int mode = p->paranoia_mode;
|
|
|
|
int offset = p->toc_offset;
|
|
|
|
cdrom_drive_t *cdd = NULL;
|
|
|
|
int last_track;
|
2003-04-02 19:29:26 +00:00
|
|
|
|
2016-09-09 15:39:22 +00:00
|
|
|
if (st->path[0]) {
|
|
|
|
p->device = st->path;
|
2023-09-19 21:14:24 +00:00
|
|
|
} else if (p->cdda_device && p->cdda_device[0]) {
|
|
|
|
p->device = p->cdda_device;
|
2016-09-09 15:39:22 +00:00
|
|
|
} else {
|
|
|
|
p->device = DEFAULT_CDROM_DEVICE;
|
2012-03-20 23:31:54 +00:00
|
|
|
}
|
2003-08-13 11:18:24 +00:00
|
|
|
|
2003-01-15 17:50:21 +00:00
|
|
|
#if defined(__NetBSD__)
|
2012-03-20 23:31:54 +00:00
|
|
|
cdd = cdda_identify_scsi(p->device, p->device, 0, NULL);
|
2003-01-15 17:50:21 +00:00
|
|
|
#else
|
2012-03-20 23:31:54 +00:00
|
|
|
cdd = cdda_identify(p->device, 0, NULL);
|
2003-01-15 17:50:21 +00:00
|
|
|
#endif
|
2002-06-11 14:29:51 +00:00
|
|
|
|
2012-03-20 23:31:54 +00:00
|
|
|
if (!cdd) {
|
2013-12-21 19:36:45 +00:00
|
|
|
MP_ERR(st, "Can't open CDDA device.\n");
|
2012-03-20 23:31:54 +00:00
|
|
|
return STREAM_ERROR;
|
|
|
|
}
|
2002-06-11 14:29:51 +00:00
|
|
|
|
2012-03-20 23:31:54 +00:00
|
|
|
cdda_verbose_set(cdd, CDDA_MESSAGE_FORGETIT, CDDA_MESSAGE_FORGETIT);
|
2002-06-11 14:29:51 +00:00
|
|
|
|
2012-03-20 23:57:58 +00:00
|
|
|
if (p->sector_size)
|
2012-03-20 23:31:54 +00:00
|
|
|
cdd->nsectors = p->sector_size;
|
|
|
|
|
|
|
|
if (cdda_open(cdd) != 0) {
|
2013-12-21 19:36:45 +00:00
|
|
|
MP_ERR(st, "Can't open disc.\n");
|
2012-03-20 23:31:54 +00:00
|
|
|
cdda_close(cdd);
|
|
|
|
return STREAM_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
priv->cd = cdd;
|
|
|
|
|
2023-10-18 19:19:17 +00:00
|
|
|
offset -= cdda_track_firstsector(cdd, 1);
|
2012-03-20 23:31:54 +00:00
|
|
|
if (offset) {
|
2013-07-22 22:45:23 +00:00
|
|
|
for (int n = 0; n < cdd->tracks + 1; n++)
|
|
|
|
cdd->disc_toc[n].dwStartSector += offset;
|
2012-03-20 23:31:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (p->speed > 0)
|
|
|
|
cdda_speed_set(cdd, p->speed);
|
|
|
|
|
|
|
|
last_track = cdda_tracks(cdd);
|
2013-04-20 23:43:09 +00:00
|
|
|
if (p->span[0] > last_track)
|
|
|
|
p->span[0] = last_track;
|
|
|
|
if (p->span[1] < p->span[0])
|
|
|
|
p->span[1] = p->span[0];
|
|
|
|
if (p->span[1] > last_track)
|
|
|
|
p->span[1] = last_track;
|
|
|
|
if (p->span[0])
|
|
|
|
priv->start_sector = cdda_track_firstsector(cdd, p->span[0]);
|
2012-03-20 23:31:54 +00:00
|
|
|
else
|
|
|
|
priv->start_sector = cdda_disc_firstsector(cdd);
|
|
|
|
|
2013-04-20 23:43:09 +00:00
|
|
|
if (p->span[1])
|
|
|
|
priv->end_sector = cdda_track_lastsector(cdd, p->span[1]);
|
2012-03-20 23:31:54 +00:00
|
|
|
else
|
|
|
|
priv->end_sector = cdda_disc_lastsector(cdd);
|
|
|
|
|
|
|
|
priv->cdp = paranoia_init(cdd);
|
|
|
|
if (priv->cdp == NULL) {
|
|
|
|
cdda_close(cdd);
|
|
|
|
free(priv);
|
|
|
|
return STREAM_ERROR;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mode == 0)
|
|
|
|
mode = PARANOIA_MODE_DISABLE;
|
|
|
|
else if (mode == 1)
|
|
|
|
mode = PARANOIA_MODE_OVERLAP;
|
|
|
|
else
|
|
|
|
mode = PARANOIA_MODE_FULL;
|
|
|
|
|
2014-06-10 18:46:15 +00:00
|
|
|
if (p->skip)
|
2012-03-20 23:31:54 +00:00
|
|
|
mode &= ~PARANOIA_MODE_NEVERSKIP;
|
2014-06-10 18:46:15 +00:00
|
|
|
else
|
|
|
|
mode |= PARANOIA_MODE_NEVERSKIP;
|
2012-03-20 23:31:54 +00:00
|
|
|
|
|
|
|
if (p->search_overlap > 0)
|
|
|
|
mode |= PARANOIA_MODE_OVERLAP;
|
|
|
|
else if (p->search_overlap == 0)
|
|
|
|
mode &= ~PARANOIA_MODE_OVERLAP;
|
|
|
|
|
|
|
|
paranoia_modeset(priv->cdp, mode);
|
2005-11-06 17:42:20 +00:00
|
|
|
|
2012-03-20 23:31:54 +00:00
|
|
|
if (p->search_overlap > 0)
|
|
|
|
paranoia_overlapset(priv->cdp, p->search_overlap);
|
2002-06-11 14:29:51 +00:00
|
|
|
|
2012-03-20 23:31:54 +00:00
|
|
|
paranoia_seek(priv->cdp, priv->start_sector, SEEK_SET);
|
|
|
|
priv->sector = priv->start_sector;
|
2002-06-11 14:29:51 +00:00
|
|
|
|
2012-03-20 23:31:54 +00:00
|
|
|
st->priv = priv;
|
2003-04-02 19:29:26 +00:00
|
|
|
|
2012-03-20 23:31:54 +00:00
|
|
|
st->fill_buffer = fill_buffer;
|
|
|
|
st->seek = seek;
|
2014-05-24 12:04:09 +00:00
|
|
|
st->seekable = true;
|
2012-03-20 23:31:54 +00:00
|
|
|
st->control = control;
|
2019-11-07 14:54:34 +00:00
|
|
|
st->get_size = get_size;
|
2012-03-20 23:31:54 +00:00
|
|
|
st->close = close_cdda;
|
2003-04-02 19:29:26 +00:00
|
|
|
|
2016-05-10 09:17:52 +00:00
|
|
|
st->streaming = true;
|
|
|
|
|
2014-07-05 14:57:56 +00:00
|
|
|
st->demuxer = "+disc";
|
2002-06-11 14:29:51 +00:00
|
|
|
|
2012-03-14 05:36:46 +00:00
|
|
|
print_cdtext(st, 0);
|
|
|
|
|
2012-03-20 23:31:54 +00:00
|
|
|
return STREAM_OK;
|
2002-06-11 14:29:51 +00:00
|
|
|
}
|
|
|
|
|
2007-12-02 13:22:53 +00:00
|
|
|
const stream_info_t stream_info_cdda = {
|
stream: fix url_options field, make protocols field not fixed length
The way the url_options field was handled was not entirely sane: it's
actually a flexible array member, so it points to garbage for streams
which do not initialize this member (it just points to the data right
after the struct, which is garbage in theory and practice). This was
not actually a problem, since the field is only used if priv_size is
set (due to how this stuff is used). But it doesn't allow setting
priv_size only, which might be useful in some cases.
Also, make the protocols array not a fixed size array. Most stream
implementations have only 1 protocol prefix, but stream_lavf.c has
over 10 (whitelists ffmpeg protocols). The high size of the fixed
size protocol array wastes space, and it is _still_ annoying to
add new prefixes to stream_lavf (have to bump the maximum length),
so make it arbitrary length.
The two changes (plus some more cosmetic changes) arte conflated into
one, because it was annoying going over all the stream implementations.
2013-08-25 20:49:27 +00:00
|
|
|
.name = "cdda",
|
|
|
|
.open = open_cdda,
|
2014-06-10 21:56:05 +00:00
|
|
|
.protocols = (const char*const[]){"cdda", NULL },
|
stream, demux: redo origin policy thing
mpv has a very weak and very annoying policy that determines whether a
playlist should be used or not. For example, if you play a remote
playlist, you usually don't want it to be able to read local filesystem
entries. (Although for a media player the impact is small I guess.)
It's weak and annoying as in that it does not prevent certain cases
which could be interpreted as bad in some cases, such as allowing
playlists on the local filesystem to reference remote URLs. It probably
barely makes sense, but we just want to exclude some other "definitely
not a good idea" things, all while playlists generally just work, so
whatever.
The policy is:
- from the command line anything is played
- local playlists can reference anything except "unsafe" streams
("unsafe" means special stream inputs like libavfilter graphs)
- remote playlists can reference only remote URLs
- things like "memory://" and archives are "transparent" to this
This commit does... something. It replaces the weird stream flags with a
slightly clearer "origin" value, which is now consequently passed down
and used everywhere. It fixes some deviations from the described policy.
I wanted to force archives to reference only content within them, but
this would probably have been more complicated (or required different
abstractions), and I'm too lazy to figure it out, so archives are now
"transparent" (playlists within archives behave the same outside).
There may be a lot of bugs in this.
This is unfortunately a very noisy commit because:
- every stream open call now needs to pass the origin
- so does every demuxer open call (=> params param. gets mandatory)
- most stream were changed to provide the "origin" value
- the origin value needed to be passed along in a lot of places
- I was too lazy to split the commit
Fixes: #7274
2019-12-20 08:41:42 +00:00
|
|
|
.stream_origin = STREAM_ORIGIN_UNSAFE,
|
2003-04-02 19:29:26 +00:00
|
|
|
};
|