1
mirror of https://github.com/mpv-player/mpv synced 2024-08-04 14:59:58 +02:00

stream_cdda: various fixes

Fix cdda speed default value, range and use more robust condition.

Based on patch by Ingo Brückl [ib wupperonline de].

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@34458 b3059339-0415-0410-9bf9-f77b7e298cf2

Do not call paranoia_overlapset with 0, it actually causes cdparanoia to just hang.
Instead use it to set/unset PARANOIA_MODE_OVERLAP.

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@34459 b3059339-0415-0410-9bf9-f77b7e298cf2

Fail if trying to seek beyond the last chapter, not just if it is beyond the end of the disc.

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@34460 b3059339-0415-0410-9bf9-f77b7e298cf2

cdda: set position to an actual EOF position when we set EOF.

This avoids some inconsistency like the stream indicating EOF but
a read still returning more data.

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@34462 b3059339-0415-0410-9bf9-f77b7e298cf2

Allow PARANOIA_MODE_FULL with skipping.

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@34467 b3059339-0415-0410-9bf9-f77b7e298cf2

Don't call paranoia_modeset() for PARANOIA_MODE_DISABLE.

cdparanoia destroys start sector information after such a call.

Since it is pointless without setting a mode anyway, don't do it.

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@34468 b3059339-0415-0410-9bf9-f77b7e298cf2

Add comment to a condition that is just a hack around a cdparanoia bug.

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@34472 b3059339-0415-0410-9bf9-f77b7e298cf2

Add checks for errors in stream_cdda's get_track_by_sector().

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@34495 b3059339-0415-0410-9bf9-f77b7e298cf2

Fix seeking beyond EOF in stream_cdda to work with cache.

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@34577 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
reimar 2011-12-23 16:27:15 +00:00 committed by Uoti Urpala
parent 4251af8d5d
commit 61c2365dd8

View File

@ -73,7 +73,7 @@ static struct cdda_params {
char* device;
m_span_t span;
} cdda_dflts = {
-1,
0,
0,
NULL,
0,
@ -87,11 +87,11 @@ static struct cdda_params {
#define ST_OFF(f) M_ST_OFF(struct cdda_params,f)
static const m_option_t cdda_params_fields[] = {
{ "speed", ST_OFF(speed), CONF_TYPE_INT, M_OPT_RANGE,1,100, NULL },
{ "speed", ST_OFF(speed), CONF_TYPE_INT, M_OPT_RANGE,0,100, NULL },
{ "paranoia", ST_OFF(paranoia_mode), CONF_TYPE_INT,M_OPT_RANGE, 0, 2, NULL },
{ "generic-dev", ST_OFF(generic_dev), CONF_TYPE_STRING, 0, 0, 0, NULL },
{ "sector-size", ST_OFF(sector_size), CONF_TYPE_INT, M_OPT_RANGE,1,100, NULL },
{ "overlap", ST_OFF(search_overlap), CONF_TYPE_INT, M_OPT_RANGE,0,75, NULL },
{ "overlap", ST_OFF(search_overlap), CONF_TYPE_INT, M_OPT_RANGE,-1,75, NULL },
{ "toc-bias", ST_OFF(toc_bias), CONF_TYPE_INT, 0, 0, 0, NULL },
{ "toc-offset", ST_OFF(toc_offset), CONF_TYPE_INT, 0, 0, 0, NULL },
{ "noskip", ST_OFF(no_skip), CONF_TYPE_FLAG, 0 , 0, 1, NULL },
@ -185,6 +185,7 @@ static int seek(stream_t* s,off_t newpos) {
sec = s->pos/CD_FRAMESIZE_RAW;
if (s->pos < 0 || sec > p->end_sector) {
s->eof = 1;
p->sector = p->end_sector + 1;
return 0;
}
@ -249,6 +250,7 @@ static int control(stream_t *stream, int cmd, void *arg) {
{
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;
}
@ -257,11 +259,16 @@ static int control(stream_t *stream, int cmd, void *arg) {
int r;
unsigned int track = *(unsigned int *)arg;
int start_track = get_track_by_sector(p, p->start_sector);
int end_track = get_track_by_sector(p, p->end_sector);
int seek_sector;
if (start_track == -1 || end_track == -1) return STREAM_ERROR;
track += start_track;
if (track >= p->cd->tracks) {
stream->eof = 1;
return STREAM_ERROR;
if (track > end_track) {
seek(stream, (p->end_sector + 1) * CD_FRAMESIZE_RAW);
// seeking beyond EOF should not be an error,
// the cache cannot handle changing stream pos and
// returning error.
return STREAM_OK;
}
seek_sector = track <= 0 ? p->start_sector
: p->cd->disc_toc[track].dwStartSector;
@ -274,6 +281,7 @@ static int control(stream_t *stream, int cmd, void *arg) {
{
int start_track = get_track_by_sector(p, p->start_sector);
int cur_track = get_track_by_sector(p, p->sector);
if (start_track == -1 || cur_track == -1) return STREAM_ERROR;
*(unsigned int *)arg = cur_track - start_track;
return STREAM_OK;
}
@ -385,7 +393,7 @@ static int open_cdda(stream_t *st,int m, void* opts, int* file_format) {
cdd->disc_toc[i].dwStartSector += offset;
}
if(p->speed)
if(p->speed > 0)
cdda_speed_set(cdd,p->speed);
last_track = cdda_tracks(cdd);
@ -421,18 +429,28 @@ static int open_cdda(stream_t *st,int m, void* opts, int* file_format) {
if(p->no_skip)
mode |= PARANOIA_MODE_NEVERSKIP;
else
mode &= ~PARANOIA_MODE_NEVERSKIP;
if(p->search_overlap > 0)
mode |= PARANOIA_MODE_OVERLAP;
else if(p->search_overlap == 0)
mode &= ~PARANOIA_MODE_OVERLAP;
#ifndef CONFIG_LIBCDIO
// HACK against libcdparanoia's stupid caching model that
// queues up a huge number of requests leading to stuttering
paranoia_cachemodel_size(priv->cdp, 24);
paranoia_modeset(cdd, mode);
// For some incomprehensible reason cdparanoia breaks the
// track->sector lookup of calling paranoia_modeset with
// PARANOIA_MODE_DISABLE
if (mode != PARANOIA_MODE_DISABLE) paranoia_modeset(cdd, mode);
if(p->search_overlap >= 0)
if(p->search_overlap > 0)
paranoia_overlapset(cdd,p->search_overlap);
#else
paranoia_modeset(priv->cdp, mode);
if(p->search_overlap >= 0)
if(p->search_overlap > 0)
paranoia_overlapset(priv->cdp,p->search_overlap);
#endif