mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-02 09:01:50 -05:00
source: add method to mark a source idle or busy
Marking a source idle will start an idle timeout to suspend the source.
This commit is contained in:
parent
04eca27890
commit
12301b6ef1
2 changed files with 53 additions and 0 deletions
|
|
@ -42,6 +42,7 @@ struct _PinosSourcePrivate
|
||||||
|
|
||||||
PinosSourceState state;
|
PinosSourceState state;
|
||||||
GError *error;
|
GError *error;
|
||||||
|
guint idle_timeout;
|
||||||
|
|
||||||
GList *outputs;
|
GList *outputs;
|
||||||
};
|
};
|
||||||
|
|
@ -367,6 +368,17 @@ pinos_source_get_formats (PinosSource *source,
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
remove_idle_timeout (PinosSource *source)
|
||||||
|
{
|
||||||
|
PinosSourcePrivate *priv = source->priv;
|
||||||
|
|
||||||
|
if (priv->idle_timeout) {
|
||||||
|
g_source_remove (priv->idle_timeout);
|
||||||
|
priv->idle_timeout = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
pinos_source_set_state (PinosSource *source,
|
pinos_source_set_state (PinosSource *source,
|
||||||
PinosSourceState state)
|
PinosSourceState state)
|
||||||
|
|
@ -378,6 +390,8 @@ pinos_source_set_state (PinosSource *source,
|
||||||
|
|
||||||
klass = PINOS_SOURCE_GET_CLASS (source);
|
klass = PINOS_SOURCE_GET_CLASS (source);
|
||||||
|
|
||||||
|
remove_idle_timeout (source);
|
||||||
|
|
||||||
if (klass->set_state)
|
if (klass->set_state)
|
||||||
res = klass->set_state (source, state);
|
res = klass->set_state (source, state);
|
||||||
else
|
else
|
||||||
|
|
@ -412,11 +426,47 @@ pinos_source_report_error (PinosSource *source,
|
||||||
priv = source->priv;
|
priv = source->priv;
|
||||||
|
|
||||||
g_clear_error (&priv->error);
|
g_clear_error (&priv->error);
|
||||||
|
remove_idle_timeout (source);
|
||||||
priv->error = error;
|
priv->error = error;
|
||||||
priv->state = PINOS_SOURCE_STATE_ERROR;
|
priv->state = PINOS_SOURCE_STATE_ERROR;
|
||||||
|
pinos_source1_set_state (priv->iface, priv->state);
|
||||||
g_object_notify (G_OBJECT (source), "state");
|
g_object_notify (G_OBJECT (source), "state");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
idle_timeout (PinosSource *source)
|
||||||
|
{
|
||||||
|
PinosSourcePrivate *priv = source->priv;
|
||||||
|
|
||||||
|
priv->idle_timeout = 0;
|
||||||
|
pinos_source_set_state (source, PINOS_SOURCE_STATE_SUSPENDED);
|
||||||
|
|
||||||
|
return G_SOURCE_REMOVE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
pinos_source_report_idle (PinosSource *source)
|
||||||
|
{
|
||||||
|
PinosSourcePrivate *priv;
|
||||||
|
|
||||||
|
g_return_if_fail (PINOS_IS_SOURCE (source));
|
||||||
|
priv = source->priv;
|
||||||
|
|
||||||
|
pinos_source_set_state (source, PINOS_SOURCE_STATE_IDLE);
|
||||||
|
|
||||||
|
priv->idle_timeout = g_timeout_add_seconds (3,
|
||||||
|
(GSourceFunc) idle_timeout,
|
||||||
|
source);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
pinos_source_report_busy (PinosSource *source)
|
||||||
|
{
|
||||||
|
g_return_if_fail (PINOS_IS_SOURCE (source));
|
||||||
|
|
||||||
|
pinos_source_set_state (source, PINOS_SOURCE_STATE_RUNNING);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
pinos_source_update_possible_formats (PinosSource *source, GBytes *formats)
|
pinos_source_update_possible_formats (PinosSource *source, GBytes *formats)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -87,6 +87,9 @@ GBytes * pinos_source_get_formats (PinosSource *source, G
|
||||||
gboolean pinos_source_set_state (PinosSource *source, PinosSourceState state);
|
gboolean pinos_source_set_state (PinosSource *source, PinosSourceState state);
|
||||||
void pinos_source_update_state (PinosSource *source, PinosSourceState state);
|
void pinos_source_update_state (PinosSource *source, PinosSourceState state);
|
||||||
void pinos_source_report_error (PinosSource *source, GError *error);
|
void pinos_source_report_error (PinosSource *source, GError *error);
|
||||||
|
void pinos_source_report_idle (PinosSource *source);
|
||||||
|
void pinos_source_report_busy (PinosSource *source);
|
||||||
|
|
||||||
void pinos_source_update_possible_formats (PinosSource *source, GBytes *formats);
|
void pinos_source_update_possible_formats (PinosSource *source, GBytes *formats);
|
||||||
|
|
||||||
PinosSourceOutput * pinos_source_create_source_output (PinosSource *source,
|
PinosSourceOutput * pinos_source_create_source_output (PinosSource *source,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue