Skip to content

Commit

Permalink
core: remove a number of global variables
Browse files Browse the repository at this point in the history
Move them into per-instance structs. This should get rid of all global
variables in mplayer.c (not counting those referenced by cfg-mplayer.h).

In core/input/ar.c, just remove checking the slave_mode variable. I'm
not sure what this code was supposed to achieve, but slave mode is
broken, slave mode is actually infeasible on OSX (ar.c is completely OSX
specific), and the correct way of doing this would be to disable this
input device per command line switch.
  • Loading branch information
wm4 committed Mar 8, 2013
1 parent 14427ae commit bc20f2c
Show file tree
Hide file tree
Showing 9 changed files with 103 additions and 112 deletions.
26 changes: 13 additions & 13 deletions core/cfg-mplayer.h
Expand Up @@ -342,11 +342,11 @@ const m_option_t common_opts[] = {

// ------------------------- demuxer options --------------------

// number of frames to play/convert
{"frames", &play_n_frames_mf, CONF_TYPE_INT, CONF_MIN, 0, 0, NULL},
OPT_CHOICE_OR_INT("frames", play_frames, 0, 0, INT_MAX,
({"all", -1})),

// seek to byte/seconds position
{"sb", &seek_to_byte, CONF_TYPE_INT64, CONF_MIN, 0, 0, NULL},
OPT_INT64("sb", seek_to_byte, 0),
OPT_REL_TIME("start", play_start, 0),
OPT_REL_TIME("end", play_end, 0),
OPT_REL_TIME("length", play_length, 0),
Expand Down Expand Up @@ -412,20 +412,20 @@ const m_option_t common_opts[] = {
{"bps", &pts_from_bps, CONF_TYPE_FLAG, 0, 0, 1, NULL},

// set A-V sync correction speed (0=disables it):
{"mc", &default_max_pts_correction, CONF_TYPE_FLOAT, CONF_RANGE, 0, 100, NULL},
OPT_FLOATRANGE("mc", default_max_pts_correction, 0, 0, 100),

// force video/audio rate:
{"fps", &force_fps, CONF_TYPE_DOUBLE, CONF_MIN, 0, 0, NULL},
{"srate", &force_srate, CONF_TYPE_INT, CONF_RANGE, 1000, 8*48000, NULL},
OPT_DOUBLE("fps", force_fps, CONF_MIN, 0),
OPT_INTRANGE("srate", force_srate, 0, 1000, 8*48000),
OPT_INTRANGE("channels", audio_output_channels, 0, 1, 8),
OPT_AUDIOFORMAT("format", audio_output_format, 0),
OPT_FLOATRANGE("speed", playback_speed, 0, 0.01, 100.0),

// set a-v distance
{"audio-delay", &audio_delay, CONF_TYPE_FLOAT, CONF_RANGE, -100.0, 100.0, NULL},
OPT_FLOATRANGE("audio-delay", audio_delay, 0, -100.0, 100.0),

// ignore header-specified delay (dwStart)
{"ignore-start", &ignore_start, CONF_TYPE_FLAG, 0, 0, 1, NULL},
OPT_FLAG("ignore-start", ignore_start, 0),

OPT_FLOATRANGE("a52drc", drc_level, 0, 0, 2),

Expand Down Expand Up @@ -478,7 +478,7 @@ const m_option_t common_opts[] = {
{"sub-delay", &sub_delay, CONF_TYPE_FLOAT, 0, 0.0, 10.0, NULL},
{"subfps", &sub_fps, CONF_TYPE_FLOAT, 0, 0.0, 10.0, NULL},
OPT_FLAG("autosub", sub_auto, 0),
{"sub-forced-only", &forced_subs_only, CONF_TYPE_FLAG, 0, 0, 1, NULL},
OPT_FLAG("sub-forced-only", forced_subs_only, 0),
// enable Closed Captioning display
{"overlapsub", &suboverlap_enabled, CONF_TYPE_FLAG, 0, 0, 2, NULL},
{"sub-no-text-pp", &sub_no_text_pp, CONF_TYPE_FLAG, 0, 0, 1, NULL},
Expand Down Expand Up @@ -595,7 +595,7 @@ const m_option_t mplayer_opts[]={
OPT_FLAG("stop-xscreensaver", vo.stop_screensaver, 0),
OPT_STRINGLIST("fstype", vo.fstype_list, 0),
#endif
{"heartbeat-cmd", &heartbeat_cmd, CONF_TYPE_STRING, 0, 0, 0, NULL},
OPT_STRING("heartbeat-cmd", heartbeat_cmd, 0),
OPT_FLAG("mouseinput", vo.nomouse_input, 0),

OPT_CHOICE_OR_INT("screen", vo.screen_id, 0, 0, 32,
Expand All @@ -613,13 +613,13 @@ const m_option_t mplayer_opts[]={

//---------------------- mplayer-only options ------------------------

{"use-filedir-conf", &use_filedir_conf, CONF_TYPE_FLAG, CONF_GLOBAL, 0, 1, NULL},
OPT_FLAG("use-filedir-conf", use_filedir_conf, CONF_GLOBAL),
OPT_CHOICE("osd-level", osd_level, 0,
({"0", 0}, {"1", 1}, {"2", 2}, {"3", 3})),
OPT_INTRANGE("osd-duration", osd_duration, 0, 0, 3600000),
OPT_FLAG("osd-fractions", osd_fractions, 0),

{"sstep", &step_sec, CONF_TYPE_DOUBLE, CONF_MIN, 0, 0, NULL},
OPT_DOUBLE("sstep", step_sec, CONF_MIN, 0),

OPT_CHOICE("framedrop", frame_dropping, 0,
({"no", 0},
Expand Down Expand Up @@ -670,7 +670,7 @@ const m_option_t mplayer_opts[]={
OPT_STRING("status-msg", status_msg, M_OPT_PARSE_ESCAPES),
OPT_STRING("osd-status-msg", osd_status_msg, M_OPT_PARSE_ESCAPES),

{"slave-broken", &slave_mode, CONF_TYPE_FLAG,CONF_GLOBAL , 0, 1, NULL},
OPT_FLAG("slave-broken", slave_mode, CONF_GLOBAL),
OPT_FLAG("idle", player_idle_mode, CONF_GLOBAL),
OPT_INTRANGE("key-fifo-size", input.key_fifo_size, CONF_GLOBAL, 2, 65000),
OPT_FLAG("consolecontrols", consolecontrols, CONF_GLOBAL),
Expand Down
12 changes: 7 additions & 5 deletions core/command.c
Expand Up @@ -594,14 +594,14 @@ static int mp_property_audio_delay(m_option_t *prop, int action,
{
if (!(mpctx->sh_audio && mpctx->sh_video))
return M_PROPERTY_UNAVAILABLE;
float delay = audio_delay;
float delay = mpctx->opts.audio_delay;
switch (action) {
case M_PROPERTY_PRINT:
*(char **)arg = format_delay(delay);
return M_PROPERTY_OK;
case M_PROPERTY_SET:
audio_delay = *(float *)arg;
mpctx->delay -= audio_delay - delay;
mpctx->audio_delay = mpctx->opts.audio_delay = *(float *)arg;
mpctx->delay -= mpctx->audio_delay - delay;
return M_PROPERTY_OK;
}
return mp_property_generic_option(prop, action, arg, mpctx);
Expand Down Expand Up @@ -1247,12 +1247,14 @@ static int mp_property_sub_visibility(m_option_t *prop, int action,
static int mp_property_sub_forced_only(m_option_t *prop, int action,
void *arg, MPContext *mpctx)
{
struct MPOpts *opts = &mpctx->opts;

if (!vo_spudec)
return M_PROPERTY_UNAVAILABLE;

if (action == M_PROPERTY_SET) {
forced_subs_only = *(int *)arg;
spudec_set_forced_subs_only(vo_spudec, forced_subs_only);
opts->forced_subs_only = *(int *)arg;
spudec_set_forced_subs_only(vo_spudec, opts->forced_subs_only);
return M_PROPERTY_OK;
}
return mp_property_generic_option(prop, action, arg, mpctx);
Expand Down
1 change: 1 addition & 0 deletions core/defaultopts.c
Expand Up @@ -57,6 +57,7 @@ void set_default_mplayer_options(struct MPOpts *opts)
.term_osd = 2,
.consolecontrols = 1,
.doubleclick_time = 300,
.play_frames = -1,
.keep_open = 0,
.audio_id = -1,
.video_id = -1,
Expand Down
5 changes: 0 additions & 5 deletions core/input/ar.c
Expand Up @@ -33,8 +33,6 @@
#include "ar.h"
#include "keycodes.h"

extern int slave_mode;

extern const double NSAppKitVersionNumber;

typedef struct cookie_keycode_map {
Expand Down Expand Up @@ -313,9 +311,6 @@ static int is_mplayer_front(void)
&& SameProcess(&frProc, &myProc, &sameProc) == noErr) {
if (sameProc)
return 1;
// If MPlayer is running in slave mode, also check parent process.
if (slave_mode && GetProcessPID(&frProc, &parentPID) == noErr)
return parentPID==getppid();
}
return 0;
}
Expand Down
3 changes: 3 additions & 0 deletions core/m_option.h
Expand Up @@ -563,6 +563,9 @@ static inline void m_option_free(const m_option_t *opt, void *dst)
#define OPT_FLOAT(...) \
OPT_GENERAL(float, __VA_ARGS__, .type = &m_option_type_float)

#define OPT_DOUBLE(...) \
OPT_GENERAL(double, __VA_ARGS__, .type = &m_option_type_double)

#define OPT_STRING(...) \
OPT_GENERAL(char*, __VA_ARGS__, .type = &m_option_type_string)

Expand Down
9 changes: 9 additions & 0 deletions core/mp_core.h
Expand Up @@ -199,6 +199,11 @@ typedef struct MPContext {
// How much video timing has been changed to make it match the audio
// timeline. Used for status line information only.
double total_avsync_change;
// Total number of dropped frames that were "approved" to be dropped.
// Actual dropping depends on --framedrop and decoder internals.
int drop_frame_cnt;
// Number of frames dropped in a row.
int dropped_frames;
// A-V sync difference when last frame was displayed. Kept to display
// the same value if the status line is updated at a time where no new
// video frame is shown.
Expand All @@ -211,6 +216,8 @@ typedef struct MPContext {
// period of time until a new frame is decoded and shown.)
double last_vo_pts;

float audio_delay;

// used to prevent hanging in some error cases
unsigned int start_timestamp;

Expand Down Expand Up @@ -246,6 +253,8 @@ typedef struct MPContext {
int paused;
// step this many frames, then pause
int step_frames;
// Counted down each frame, stop playback if 0 is reached. (-1 = disable)
int max_frames;

bool paused_for_cache;

Expand Down

0 comments on commit bc20f2c

Please sign in to comment.