client API: don't miss property changes after updates

When update_prop() successfully fetches a changed property value, it
sets prop->changed to true. mark_property_changed() only sets
prop->need_new_value if prop->changed is false, so this had the effect
of ignoring new property values until prop->changed was set back to
false in the next call to gen_property_change_event(). This meant that
when a property change event was generated for a property that was not
observed with MPV_FORMAT_NONE, it would contain the value associated
with the earliest property change, rather than the most recent, and the
property change event for the most recent change would never be
generated.

To fix this, mark_property_changed() should unconditionally set
prop->changed and prop->need_new_value, which will cause the property
value to be re-fetched and a property change event to be generated for
the most recent value.
This commit is contained in:
James Ross-Gowan 2016-09-11 21:14:07 +10:00
parent 3f7e43c2e2
commit 6ac0ef78c5
1 changed files with 3 additions and 5 deletions

View File

@ -1373,11 +1373,9 @@ int mpv_unobserve_property(mpv_handle *ctx, uint64_t userdata)
static void mark_property_changed(struct mpv_handle *client, int index) static void mark_property_changed(struct mpv_handle *client, int index)
{ {
struct observe_property *prop = client->properties[index]; struct observe_property *prop = client->properties[index];
if (!prop->changed && !prop->need_new_value) { prop->changed = true;
prop->changed = true; prop->need_new_value = prop->format != 0;
prop->need_new_value = prop->format != 0; client->lowest_changed = MPMIN(client->lowest_changed, index);
client->lowest_changed = MPMIN(client->lowest_changed, index);
}
} }
// Broadcast that a property has changed. // Broadcast that a property has changed.