From 35e6d1abe0315caee3f21ca3853d76423baa0c91 Mon Sep 17 00:00:00 2001 From: wm4 Date: Tue, 10 Jun 2014 22:09:27 +0200 Subject: stream_dvd, stream_dvdnav, stream_bluray: remove global option variables --- options/options.c | 12 ++++---- options/options.h | 6 ++++ player/configfiles.c | 10 +++---- stream/stream.c | 4 --- stream/stream.h | 9 ------ stream/stream_bluray.c | 15 +++++----- stream/stream_dvd.c | 74 ++++++++++++++++++++++++---------------------- stream/stream_dvd.h | 5 ++++ stream/stream_dvd_common.c | 3 -- stream/stream_dvdnav.c | 18 ++++++----- 10 files changed, 78 insertions(+), 78 deletions(-) diff --git a/options/options.c b/options/options.c index 12057c6e9a..09820aa6bf 100644 --- a/options/options.c +++ b/options/options.c @@ -171,16 +171,16 @@ const m_option_t mp_opts[] = { OPT_INTRANGE("cache-pause-restart", stream_cache_unpause, 0, 0, 0x7fffffff), #if HAVE_DVDREAD || HAVE_DVDNAV - {"dvd-device", &dvd_device, CONF_TYPE_STRING, 0, 0, 0, NULL}, - {"dvd-speed", &dvd_speed, CONF_TYPE_INT, 0, 0, 0, NULL}, - {"dvd-angle", &dvd_angle, CONF_TYPE_INT, CONF_RANGE, 1, 99, NULL}, + OPT_STRING("dvd-device", dvd_device, 0), + OPT_INT("dvd-speed", dvd_speed, 0), + OPT_INTRANGE("dvd-angle", dvd_angle, 0, 1, 99), #endif /* HAVE_DVDREAD */ OPT_INTPAIR("chapter", chapterrange, 0), OPT_CHOICE_OR_INT("edition", edition_id, 0, 0, 8190, ({"auto", -1})), #if HAVE_LIBBLURAY - {"bluray-device", &bluray_device, CONF_TYPE_STRING, 0, 0, 0, NULL}, - {"bluray-angle", &bluray_angle, CONF_TYPE_INT, CONF_RANGE, 0, 999, NULL}, + OPT_STRING("bluray-device", bluray_device, 0), + OPT_INTRANGE("bluray-angle", bluray_angle, 0, 0, 999), #endif /* HAVE_LIBBLURAY */ OPT_STRINGLIST("http-header-fields", network_http_header_fields, 0), @@ -671,6 +671,8 @@ const struct MPOpts mp_default_opts = { .index_mode = -1, + .dvd_angle = 1, + .ad_lavc_param = { .ac3drc = 1., .downmix = 1, diff --git a/options/options.h b/options/options.h index 229361f767..7e8c22451d 100644 --- a/options/options.h +++ b/options/options.h @@ -244,6 +244,12 @@ typedef struct MPOpts { struct dvb_params *stream_dvb_opts; char *cdrom_device; + int dvd_title; + int dvd_angle; + int dvd_speed; + char *dvd_device; + int bluray_angle; + char *bluray_device; struct lavc_param { int fast; diff --git a/player/configfiles.c b/player/configfiles.c index fd0a8231c0..94b8e33f85 100644 --- a/player/configfiles.c +++ b/player/configfiles.c @@ -31,6 +31,7 @@ #include "osdep/io.h" +#include "common/global.h" #include "common/msg.h" #include "options/path.h" #include "options/m_config.h" @@ -175,6 +176,7 @@ void mp_load_auto_profiles(struct MPContext *mpctx) static char *mp_get_playback_resume_config_filename(struct mpv_global *global, const char *fname) { + struct MPOpts *opts = global->opts; char *res = NULL; void *tmp = talloc_new(NULL); const char *realpath = fname; @@ -185,15 +187,11 @@ static char *mp_get_playback_resume_config_filename(struct mpv_global *global, goto exit; realpath = mp_path_join(tmp, bstr0(cwd), bstr0(fname)); } -#if HAVE_DVDREAD || HAVE_DVDNAV if (bstr_startswith0(bfname, "dvd://")) - realpath = talloc_asprintf(tmp, "%s - %s", realpath, dvd_device); -#endif -#if HAVE_LIBBLURAY + realpath = talloc_asprintf(tmp, "%s - %s", realpath, opts->dvd_device); if (bstr_startswith0(bfname, "br://") || bstr_startswith0(bfname, "bd://") || bstr_startswith0(bfname, "bluray://")) - realpath = talloc_asprintf(tmp, "%s - %s", realpath, bluray_device); -#endif + realpath = talloc_asprintf(tmp, "%s - %s", realpath, opts->bluray_device); uint8_t md5[16]; av_md5_sum(md5, realpath, strlen(realpath)); char *conf = talloc_strdup(tmp, ""); diff --git a/stream/stream.c b/stream/stream.c index 8542515567..171d6781a1 100644 --- a/stream/stream.c +++ b/stream/stream.c @@ -52,10 +52,6 @@ // Includes additional padding in case sizes get rounded up by sector size. #define TOTAL_BUFFER_SIZE (STREAM_MAX_BUFFER_SIZE + STREAM_MAX_SECTOR_SIZE) -/// We keep these 2 for the gui atm, but they will be removed. -char *dvd_device = NULL; -int dvd_title = 0; - extern const stream_info_t stream_info_cdda; extern const stream_info_t stream_info_dvb; extern const stream_info_t stream_info_tv; diff --git a/stream/stream.h b/stream/stream.h index cb6c60c197..cd81e7daeb 100644 --- a/stream/stream.h +++ b/stream/stream.h @@ -245,15 +245,6 @@ bool stream_check_interrupt(struct stream *s); bool stream_manages_timeline(stream_t *s); -/* stream/stream_dvd.c */ -extern int dvd_title; -extern int dvd_angle; -extern int dvd_speed; -extern char *dvd_device; - -extern int bluray_angle; -extern char *bluray_device; - typedef struct { int id; // 0 - 31 mpeg; 128 - 159 ac3; 160 - 191 pcm int language; diff --git a/stream/stream_bluray.c b/stream/stream_bluray.c index 5ef9fc8c60..a40856643b 100644 --- a/stream/stream_bluray.c +++ b/stream/stream_bluray.c @@ -42,6 +42,7 @@ #include "common/common.h" #include "common/msg.h" #include "options/m_option.h" +#include "options/options.h" #include "stream.h" #include "osdep/timer.h" #include "discnav.h" @@ -72,9 +73,6 @@ #define AACS_ERROR_MMC_FAILURE -7 /* MMC failed */ #define AACS_ERROR_NO_DK -8 /* no matching device key */ -char *bluray_device = NULL; -int bluray_angle = 0; - struct bluray_overlay { struct sub_bitmap *image; bool clean, hidden; @@ -703,8 +701,9 @@ static void select_initial_angle(stream_t *s) { if (!info) return; /* Select angle */ - unsigned int angle = 0; - angle = bluray_angle ? bluray_angle : BLURAY_DEFAULT_ANGLE; + unsigned int angle = s->opts->bluray_angle; + if (!angle) + angle = BLURAY_DEFAULT_ANGLE; angle = FFMIN(angle, info->angle_count); if (angle) bd_select_angle(b->bd, angle); @@ -718,10 +717,10 @@ static int bluray_stream_open(stream_t *s) const char *device = NULL; /* find the requested device */ - if (b->cfg_device) + if (b->cfg_device && b->cfg_device[0]) device = b->cfg_device; - else if (bluray_device) - device = bluray_device; + else if (s->opts->bluray_device && s->opts->bluray_device[0]) + device = s->opts->bluray_device; if (!device) { MP_ERR(s, "No Blu-ray device/location was specified ...\n"); diff --git a/stream/stream_dvd.c b/stream/stream_dvd.c index ae3ed09b5e..6b370de114 100644 --- a/stream/stream_dvd.c +++ b/stream/stream_dvd.c @@ -40,13 +40,11 @@ #include "stream.h" #include "options/m_option.h" +#include "options/options.h" #include "stream_dvd.h" #include "stream_dvd_common.h" -static char* dvd_device_current; -int dvd_angle=1; - #define LIBDVDREAD_VERSION(maj,min,micro) ((maj)*10000 + (min)*100 + (micro)) /* * Try to autodetect the libdvd-0.9.0 library @@ -191,7 +189,7 @@ static int dvd_next_cell(stream_t *stream, dvd_priv_t *d) { if(next_cell>=d->last_cell) return -1; // EOF if(d->cur_pgc->cell_playback[next_cell].block_type == BLOCK_TYPE_ANGLE_BLOCK ) { - next_cell+=dvd_angle-1; + next_cell+=d->dvd_angle-1; if(next_cell>=d->last_cell) return -1; // EOF } @@ -271,7 +269,7 @@ read_next: if(skip && skip!=0x7fffffff) { // sml_agli table has valid data (at least one non-zero): d->cur_pack=d->dsi_pack.dsi_gi.nv_pck_lbn+ - d->dsi_pack.sml_agli.data[dvd_angle-1].address; + d->dsi_pack.sml_agli.data[d->dvd_angle-1].address; d->angle_seek=0; d->cur_pack--; MP_VERBOSE(stream, "Angle-seek synced using sml_agli map! new_lba=0x%X \n",d->cur_pack); @@ -322,7 +320,8 @@ static void stream_dvd_close(stream_t *s) { ifoClose(d->vmg_file); DVDCloseFile(d->title); DVDClose(d->dvd); - dvd_set_speed(s,dvd_device_current, -1); /* -1 => restore default */ + if (d->dvd_speed) + dvd_set_speed(s,d->dvd_device_current, -1); /* -1 => restore default */ } static int mp_get_titleset_length(ifo_handle_t *vts_file, tt_srpt_t *tt_srpt, int title_no) @@ -603,20 +602,20 @@ static int control(stream_t *stream,int cmd,void* arg) } case STREAM_CTRL_GET_NUM_ANGLES: { - *((int *)arg) = d->vmg_file->tt_srpt->title[dvd_title].nr_of_angles; + *((int *)arg) = d->vmg_file->tt_srpt->title[d->dvd_title].nr_of_angles; return 1; } case STREAM_CTRL_GET_ANGLE: { - *((int *)arg) = dvd_angle; + *((int *)arg) = d->dvd_angle; return 1; } case STREAM_CTRL_SET_ANGLE: { int ang = *((int *)arg); - if(ang>d->vmg_file->tt_srpt->title[dvd_title].nr_of_angles || ang<=0) + if(ang>d->vmg_file->tt_srpt->title[d->dvd_title].nr_of_angles || ang<=0) break; - dvd_angle = ang; + d->dvd_angle = ang; d->angle_seek = 1; return 1; } @@ -668,8 +667,10 @@ static int open_s(stream_t *stream) int k; dvd_priv_t *d = stream->priv; + d->dvd_angle = stream->opts->dvd_angle; + MP_VERBOSE(stream, "URL: %s\n", stream->url); - dvd_title = d->cfg_title + 1; + d->dvd_title = d->cfg_title + 1; if(1){ //int ret,ret2; int ttn,pgc_id,pgn; @@ -682,18 +683,19 @@ static int open_s(stream_t *stream) /** * Open the disc. */ - if(d->cfg_device) - dvd_device_current = d->cfg_device; - else if(dvd_device) - dvd_device_current = dvd_device; + if(d->cfg_device && d->cfg_device[0]) + d->dvd_device_current = d->cfg_device; + else if(stream->opts->dvd_device && stream->opts->dvd_device[0]) + d->dvd_device_current = talloc_strdup(stream, stream->opts->dvd_device); else - dvd_device_current = DEFAULT_DVD_DEVICE; - dvd_set_speed(stream,dvd_device_current, dvd_speed); + d->dvd_device_current = DEFAULT_DVD_DEVICE; + d->dvd_speed = stream->opts->dvd_speed; + dvd_set_speed(stream,d->dvd_device_current, d->dvd_speed); #if defined(__APPLE__) || defined(__DARWIN__) /* Dynamic DVD drive selection on Darwin */ - if(!strcmp(dvd_device_current, "/dev/rdiskN")) { + if(!strcmp(d->dvd_device_current, "/dev/rdiskN")) { int i; - size_t len = strlen(dvd_device_current)+1; + size_t len = strlen(d->dvd_device_current)+1; char *temp_device = malloc(len); for (i = 1; i < 10; i++) { @@ -703,7 +705,7 @@ static int open_s(stream_t *stream) MP_ERR(stream, "Couldn't open DVD device: %s (%s)\n",temp_device, strerror(errno)); } else { #if DVDREAD_VERSION <= LIBDVDREAD_VERSION(0,9,4) - dvd_file_t *dvdfile = DVDOpenFile(dvd,dvd_title,DVD_READ_INFO_FILE); + dvd_file_t *dvdfile = DVDOpenFile(dvd,d->dvd_title,DVD_READ_INFO_FILE); if(!dvdfile) { MP_ERR(stream, "Couldn't open DVD device: %s (%s)\n",temp_device, strerror(errno)); DVDClose(dvd); @@ -722,9 +724,9 @@ static int open_s(stream_t *stream) } else #endif /* defined(__APPLE__) || defined(__DARWIN__) */ { - dvd = DVDOpen(dvd_device_current); + dvd = DVDOpen(d->dvd_device_current); if(!dvd) { - MP_ERR(stream, "Couldn't open DVD device: %s (%s)\n",dvd_device_current, strerror(errno)); + MP_ERR(stream, "Couldn't open DVD device: %s (%s)\n",d->dvd_device_current, strerror(errno)); return STREAM_UNSUPPORTED; } } @@ -746,37 +748,37 @@ static int open_s(stream_t *stream) * Make sure our title number is valid. */ MP_INFO(stream, "There are %d titles on this DVD.\n", tt_srpt->nr_of_srpts ); - if(dvd_title < 1 || dvd_title > tt_srpt->nr_of_srpts) { - MP_ERR(stream, "Invalid DVD title number: %d\n", dvd_title); + if(d->dvd_title < 1 || d->dvd_title > tt_srpt->nr_of_srpts) { + MP_ERR(stream, "Invalid DVD title number: %d\n", d->dvd_title); ifoClose( vmg_file ); DVDClose( dvd ); return STREAM_UNSUPPORTED; } - --dvd_title; // remap 1.. -> 0.. + --(d->dvd_title); // remap 1.. -> 0.. /** * Make sure the angle number is valid for this title. */ - MP_INFO(stream, "There are %d angles in this DVD title.\n", tt_srpt->title[dvd_title].nr_of_angles); - if(dvd_angle<1 || dvd_angle>tt_srpt->title[dvd_title].nr_of_angles) { - MP_ERR(stream, "Invalid DVD angle number: %d\n", dvd_angle); + MP_INFO(stream, "There are %d angles in this DVD title.\n", tt_srpt->title[d->dvd_title].nr_of_angles); + if(d->dvd_angle<1 || d->dvd_angle>tt_srpt->title[d->dvd_title].nr_of_angles) { + MP_ERR(stream, "Invalid DVD angle number: %d\n", d->dvd_angle); goto fail; } - ttn = tt_srpt->title[dvd_title].vts_ttn - 1; + ttn = tt_srpt->title[d->dvd_title].vts_ttn - 1; /** * Load the VTS information for the title set our title is in. */ - vts_file = ifoOpen( dvd, tt_srpt->title[dvd_title].title_set_nr ); + vts_file = ifoOpen( dvd, tt_srpt->title[d->dvd_title].title_set_nr ); if(!vts_file) { - MP_ERR(stream, "Cannot open the IFO file for DVD title %d.\n", tt_srpt->title[dvd_title].title_set_nr ); + MP_ERR(stream, "Cannot open the IFO file for DVD title %d.\n", tt_srpt->title[d->dvd_title].title_set_nr ); goto fail; } /** * We've got enough info, time to open the title set data. */ - title = DVDOpenFile(dvd, tt_srpt->title[dvd_title].title_set_nr, DVD_READ_TITLE_VOBS); + title = DVDOpenFile(dvd, tt_srpt->title[d->dvd_title].title_set_nr, DVD_READ_TITLE_VOBS); if(!title) { - MP_ERR(stream, "Cannot open title VOBS (VTS_%02d_1.VOB).\n", tt_srpt->title[dvd_title].title_set_nr); + MP_ERR(stream, "Cannot open title VOBS (VTS_%02d_1.VOB).\n", tt_srpt->title[d->dvd_title].title_set_nr); ifoClose( vts_file ); goto fail; } @@ -788,7 +790,7 @@ static int open_s(stream_t *stream) d->vmg_file=vmg_file; d->tt_srpt=tt_srpt; d->vts_file=vts_file; - d->cur_title = dvd_title; + d->cur_title = d->dvd_title; pgc = vts_file->vts_pgcit ? vts_file->vts_pgcit->pgci_srp[ttn].pgc : NULL; /** @@ -898,7 +900,7 @@ static int open_s(stream_t *stream) d->last_cell=d->cur_pgc->nr_of_cells; if(d->cur_pgc->cell_playback[d->cur_cell].block_type == BLOCK_TYPE_ANGLE_BLOCK ) - d->cur_cell+=dvd_angle-1; + d->cur_cell+=d->dvd_angle-1; d->cur_pack = d->cur_pgc->cell_playback[ d->cur_cell ].first_sector; d->cell_last_pack=d->cur_pgc->cell_playback[ d->cur_cell ].last_sector; MP_VERBOSE(stream, "DVD start cell: %d pack: 0x%X-0x%X \n",d->cur_cell,d->cur_pack,d->cell_last_pack); @@ -909,7 +911,7 @@ static int open_s(stream_t *stream) return STREAM_UNSUPPORTED; for(k=0; kcur_pgc->nr_of_cells; k++) d->cell_times_table[k] = mp_dvdtimetomsec(&d->cur_pgc->cell_playback[k].playback_time); - list_chapters(stream, vts_file,tt_srpt,dvd_title); + list_chapters(stream, vts_file,tt_srpt,d->dvd_title); // ... (unimplemented) // return NULL; diff --git a/stream/stream_dvd.h b/stream/stream_dvd.h index 29087c93d9..0f509b3e35 100644 --- a/stream/stream_dvd.h +++ b/stream/stream_dvd.h @@ -55,6 +55,11 @@ typedef struct { int nr_of_subtitles; stream_language_t subtitles[32]; + int dvd_angle; + char *dvd_device_current; + int dvd_speed; + int dvd_title; + int cfg_title; char *cfg_device; } dvd_priv_t; diff --git a/stream/stream_dvd_common.c b/stream/stream_dvd_common.c index 6c29d446c5..677b70a1bc 100644 --- a/stream/stream_dvd_common.c +++ b/stream/stream_dvd_common.c @@ -47,8 +47,6 @@ 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" }; -int dvd_speed=0; /* 0 => don't touch speed */ - void dvd_set_speed(stream_t *stream, char *device, unsigned speed) { #if defined(__linux__) && defined(SG_IO) && defined(GPCMD_SET_STREAMING) @@ -68,7 +66,6 @@ void dvd_set_speed(stream_t *stream, char *device, unsigned speed) case 0: /* don't touch speed setting */ return; case -1: /* restore default value */ - if (dvd_speed == 0) return; /* we haven't touched the speed setting */ MP_INFO(stream, "Restoring DVD speed... "); break; default: /* limit to KB/s */ diff --git a/stream/stream_dvdnav.c b/stream/stream_dvdnav.c index b438e7205c..20382a14e4 100644 --- a/stream/stream_dvdnav.c +++ b/stream/stream_dvdnav.c @@ -57,6 +57,8 @@ struct priv { bool nav_enabled; bool had_initial_vts; + int dvd_speed; + int track; char *device; }; @@ -630,7 +632,8 @@ static void stream_dvdnav_close(stream_t *s) struct priv *priv = s->priv; dvdnav_close(priv->dvdnav); priv->dvdnav = NULL; - dvd_set_speed(s, priv->filename, -1); + if (priv->dvd_speed) + dvd_set_speed(s, priv->filename, -1); } static struct priv *new_dvdnav_stream(stream_t *stream, char *filename) @@ -644,7 +647,8 @@ static struct priv *new_dvdnav_stream(stream_t *stream, char *filename) if (!(priv->filename = strdup(filename))) return NULL; - dvd_set_speed(stream, priv->filename, dvd_speed); + priv->dvd_speed = stream->opts->dvd_speed; + dvd_set_speed(stream, priv->filename, priv->dvd_speed); if (dvdnav_open(&(priv->dvdnav), priv->filename) != DVDNAV_STATUS_OK) { free(priv->filename); @@ -670,10 +674,10 @@ static int open_s(stream_t *stream) priv = p = stream->priv; char *filename; - if (p->device) + if (p->device && p->device[0]) filename = p->device; - else if (dvd_device) - filename = dvd_device; + else if (stream->opts->dvd_device && stream->opts->dvd_device[0]) + filename = stream->opts->dvd_device; else filename = DEFAULT_DVD_DEVICE; if (!new_dvdnav_stream(stream, filename)) { @@ -715,8 +719,8 @@ static int open_s(stream_t *stream) if (dvdnav_menu_call(priv->dvdnav, DVD_MENU_Root) != DVDNAV_STATUS_OK) dvdnav_menu_call(priv->dvdnav, DVD_MENU_Title); } - if (dvd_angle > 1) - dvdnav_angle_change(priv->dvdnav, dvd_angle); + if (stream->opts->dvd_angle > 1) + dvdnav_angle_change(priv->dvdnav, stream->opts->dvd_angle); stream->sector_size = 2048; stream->fill_buffer = fill_buffer; -- cgit v1.2.3