command: fix audio-out-detected-device property

Used a wrong condition, and I suppose it could crash in some situations.

Change it to lazily initialize the hotplug stuff, like the
audio-device-list property does.
This commit is contained in:
wm4 2015-06-09 18:14:15 +02:00
parent bd64763076
commit 3399b775b7
1 changed files with 3 additions and 2 deletions

View File

@ -1610,8 +1610,9 @@ static int mp_property_ao_detected_device(void *ctx,struct m_property *prop,
{
struct MPContext *mpctx = ctx;
struct command_ctx *cmd = mpctx->command_ctx;
if (!mpctx->ao)
return M_PROPERTY_UNAVAILABLE;
if (!cmd->hotplug)
cmd->hotplug = ao_hotplug_create(mpctx->global, mpctx->input);
const char *d = ao_hotplug_get_detected_device(cmd->hotplug);
return m_property_strdup_ro(action, arg, d);
}