[MPlayer-dev-eng] [PATCH] Patch for better pause support.
Reimar Döffinger
Reimar.Doeffinger at stud.uni-karlsruhe.de
Thu Sep 25 20:03:48 CEST 2008
Hello,
On Thu, Sep 04, 2008 at 12:45:58PM -0400, Robert Cummings wrote:
> I took a look through the code some more. The is_paused command can use
> mpctx->osd_function == OSD_PAUSE instead to get it's pause status (patch
> attached).
Having looked at the overall code, while I do not exactly like how the
"osd_function" is misused I think this is the correct way.
There are just two uglynesses:
1) I think it should be done via the get_/set_property interface IMO
2) it actually reports the previous state (admittedly that is due to the
changes I suggested in part).
> This would mean setting mpctx->was_paused can be skipped
> within the pause_loop. That said, I still think for consistency that
> mpctx->was_paused should be changed to mpctx->is_paused and this should
> still be set within the pause_loop (patch attached - merge with
> pausing_keep_force patch).
Actually, I decided it is best for consistency and to minimize the
changes to set it _before_ entering the pause_loop.
Attached is an untested patch that should implement
get_property pause
It misses the documentation part though.
-------------- next part --------------
diff --git a/command.c b/command.c
index e5b17ab..15069de 100644
--- a/command.c
+++ b/command.c
@@ -543,6 +543,12 @@ static int mp_property_metadata(m_option_t * prop, int action, void *arg,
return M_PROPERTY_NOT_IMPLEMENTED;
}
+static int mp_property_pause(m_option_t * prop, int action, void *arg,
+ MPContext * mpctx)
+{
+ return m_property_flag_ro(prop, action, arg, mpctx->osd_function == OSD_PAUSE);
+}
+
///@}
@@ -1987,6 +1993,8 @@ static const m_option_t mp_properties[] = {
CONF_RANGE, -2, 10, NULL },
{ "metadata", mp_property_metadata, CONF_TYPE_STRING_LIST,
0, 0, 0, NULL },
+ { "pause", mp_property_pause, CONF_TYPE_FLAG,
+ M_OPT_RANGE, 0, 1, NULL },
// Audio
{ "volume", mp_property_volume, CONF_TYPE_FLOAT,
diff --git a/m_property.c b/m_property.c
index 2755258..d786d26 100644
--- a/m_property.c
+++ b/m_property.c
@@ -245,6 +245,17 @@ int m_property_choice(const m_option_t* prop,int action,
return m_property_int_range(prop,action,arg,var);
}
+int m_property_flag_ro(const m_option_t* prop,int action,
+ void* arg,int var) {
+ switch(action) {
+ case M_PROPERTY_PRINT:
+ if(!arg) return 0;
+ *(char**)arg = strdup((var > prop->min) ? MSGTR_Enabled : MSGTR_Disabled);
+ return 1;
+ }
+ return m_property_int_ro(prop,action,arg,var);
+}
+
int m_property_flag(const m_option_t* prop,int action,
void* arg,int* var) {
switch(action) {
@@ -253,9 +264,7 @@ int m_property_flag(const m_option_t* prop,int action,
*var = *var == prop->min ? prop->max : prop->min;
return 1;
case M_PROPERTY_PRINT:
- if(!arg) return 0;
- *(char**)arg = strdup((*var > prop->min) ? MSGTR_Enabled : MSGTR_Disabled);
- return 1;
+ return m_property_flag_ro(prop, action, arg, *var);
}
return m_property_int_range(prop,action,arg,var);
}
diff --git a/m_property.h b/m_property.h
index 7bf4328..375aea6 100644
--- a/m_property.h
+++ b/m_property.h
@@ -169,6 +169,9 @@ int m_property_int_range(const m_option_t* prop,int action,
int m_property_choice(const m_option_t* prop,int action,
void* arg,int* var);
+int m_property_flag_ro(const m_option_t* prop,int action,
+ void* arg,int var);
+
/// Switch betwen min and max.
int m_property_flag(const m_option_t* prop,int action,
void* arg,int* var);
More information about the MPlayer-dev-eng
mailing list