stream_dvd, stream_dvdnav, stream_bluray: remove global option variables

This commit is contained in:
wm4
2014-06-10 22:09:27 +02:00
parent 959b718957
commit 35e6d1abe0
10 changed files with 78 additions and 78 deletions

View File

@@ -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;

View File

@@ -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;

View File

@@ -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");

View File

@@ -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; k<d->cur_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;

View File

@@ -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;

View File

@@ -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 <speed> KB/s */

View File

@@ -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;