mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
Improve state output in pinos-monitor
Make a method to return the string representation of the states and use that in pinos-monitor to improve output
This commit is contained in:
parent
c75efac3f9
commit
205a471e49
7 changed files with 86 additions and 3 deletions
|
|
@ -295,6 +295,25 @@ pinos_context_init (PinosContext * context)
|
|||
context);
|
||||
}
|
||||
|
||||
/**
|
||||
* pinos_context_state_as_string:
|
||||
* @state: a #PinosContextState
|
||||
*
|
||||
* Return the string representation of @state.
|
||||
*
|
||||
* Returns: the string representation of @state.
|
||||
*/
|
||||
const gchar *
|
||||
pinos_context_state_as_string (PinosContextState state)
|
||||
{
|
||||
GEnumValue *val;
|
||||
|
||||
val = g_enum_get_value (G_ENUM_CLASS (g_type_class_ref (PINOS_TYPE_CONTEXT_STATE)),
|
||||
state);
|
||||
|
||||
return val == NULL ? "invalid-state" : val->value_nick;
|
||||
}
|
||||
|
||||
/**
|
||||
* pinos_context_new:
|
||||
* @context: a #GMainContext to run in
|
||||
|
|
|
|||
|
|
@ -74,6 +74,8 @@ typedef enum {
|
|||
PINOS_CONTEXT_STATE_READY = 3,
|
||||
} PinosContextState;
|
||||
|
||||
const gchar * pinos_context_state_as_string (PinosContextState state);
|
||||
|
||||
/**
|
||||
* PinosContext:
|
||||
*
|
||||
|
|
|
|||
|
|
@ -229,6 +229,25 @@ pinos_context_get_client_info_by_id (PinosContext *context,
|
|||
cb (context, NULL, user_data);
|
||||
}
|
||||
|
||||
/**
|
||||
* pinos_source_state_as_string:
|
||||
* @state: a #PinosSourceState
|
||||
*
|
||||
* Return the string representation of @state.
|
||||
*
|
||||
* Returns: the string representation of @state.
|
||||
*/
|
||||
const gchar *
|
||||
pinos_source_state_as_string (PinosSourceState state)
|
||||
{
|
||||
GEnumValue *val;
|
||||
|
||||
val = g_enum_get_value (G_ENUM_CLASS (g_type_class_ref (PINOS_TYPE_SOURCE_STATE)),
|
||||
state);
|
||||
|
||||
return val == NULL ? "invalid-state" : val->value_nick;
|
||||
}
|
||||
|
||||
static void
|
||||
source_fill_info (PinosSourceInfo *info, GDBusProxy *proxy)
|
||||
{
|
||||
|
|
@ -325,6 +344,25 @@ pinos_context_get_source_info_by_id (PinosContext *context,
|
|||
cb (context, NULL, user_data);
|
||||
}
|
||||
|
||||
/**
|
||||
* pinos_source_output_state_as_string:
|
||||
* @state: a #PinosSourceOutputState
|
||||
*
|
||||
* Return the string representation of @state.
|
||||
*
|
||||
* Returns: the string representation of @state.
|
||||
*/
|
||||
const gchar *
|
||||
pinos_source_output_state_as_string (PinosSourceOutputState state)
|
||||
{
|
||||
GEnumValue *val;
|
||||
|
||||
val = g_enum_get_value (G_ENUM_CLASS (g_type_class_ref (PINOS_TYPE_SOURCE_OUTPUT_STATE)),
|
||||
state);
|
||||
|
||||
return val == NULL ? "invalid-state" : val->value_nick;
|
||||
}
|
||||
|
||||
static void
|
||||
source_output_fill_info (PinosSourceOutputInfo *info, GDBusProxy *proxy)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -125,6 +125,8 @@ typedef enum {
|
|||
PINOS_SOURCE_STATE_RUNNING = 3,
|
||||
} PinosSourceState;
|
||||
|
||||
const gchar * pinos_source_state_as_string (PinosSourceState state);
|
||||
|
||||
/**
|
||||
* PinosSourceInfo:
|
||||
* @id: generic id of the source
|
||||
|
|
@ -190,6 +192,8 @@ typedef enum {
|
|||
PINOS_SOURCE_OUTPUT_STATE_STREAMING = 2,
|
||||
} PinosSourceOutputState;
|
||||
|
||||
const gchar * pinos_source_output_state_as_string (PinosSourceOutputState state);
|
||||
|
||||
/**
|
||||
* PinosSourceOutputInfo:
|
||||
* @id: generic id of the output
|
||||
|
|
|
|||
|
|
@ -402,6 +402,25 @@ pinos_stream_init (PinosStream * stream)
|
|||
priv->state = PINOS_STREAM_STATE_UNCONNECTED;
|
||||
}
|
||||
|
||||
/**
|
||||
* pinos_stream_state_as_string:
|
||||
* @state: a #PinosStreamState
|
||||
*
|
||||
* Return the string representation of @state.
|
||||
*
|
||||
* Returns: the string representation of @state.
|
||||
*/
|
||||
const gchar *
|
||||
pinos_stream_state_as_string (PinosStreamState state)
|
||||
{
|
||||
GEnumValue *val;
|
||||
|
||||
val = g_enum_get_value (G_ENUM_CLASS (g_type_class_ref (PINOS_TYPE_STREAM_STATE)),
|
||||
state);
|
||||
|
||||
return val == NULL ? "invalid-state" : val->value_nick;
|
||||
}
|
||||
|
||||
/**
|
||||
* pinos_stream_new:
|
||||
* @context: a #PinosContext
|
||||
|
|
|
|||
|
|
@ -49,6 +49,7 @@ typedef enum {
|
|||
PINOS_STREAM_STATE_STREAMING = 4
|
||||
} PinosStreamState;
|
||||
|
||||
const gchar * pinos_stream_state_as_string (PinosStreamState state);
|
||||
|
||||
typedef enum {
|
||||
PINOS_STREAM_FLAGS_NONE = 0,
|
||||
|
|
|
|||
|
|
@ -133,7 +133,7 @@ dump_source_info (PinosContext *c, const PinosSourceInfo *info, gpointer userdat
|
|||
if (info->change_mask & (1 << 1))
|
||||
print_properties (info->properties);
|
||||
if (info->change_mask & (1 << 2))
|
||||
g_print ("\tstate: %d\n", info->state);
|
||||
g_print ("\tstate: \"%s\"\n", pinos_source_state_as_string (info->state));
|
||||
if (info->change_mask & (1 << 3))
|
||||
print_formats ("possible formats", info->possible_formats);
|
||||
|
||||
|
|
@ -155,7 +155,7 @@ dump_source_output_info (PinosContext *c, const PinosSourceOutputInfo *info, gpo
|
|||
if (info->change_mask & (1 << 2))
|
||||
print_formats ("possible-formats", info->possible_formats);
|
||||
if (info->change_mask & (1 << 3))
|
||||
g_print ("\tstate: \"%d\"\n", info->state);
|
||||
g_print ("\tstate: \"%s\"\n", pinos_source_output_state_as_string (info->state));
|
||||
if (info->change_mask & (1 << 4))
|
||||
print_formats ("format", info->format);
|
||||
if (info->change_mask & (1 << 5))
|
||||
|
|
@ -243,7 +243,7 @@ on_state_notify (GObject *gobject,
|
|||
break;
|
||||
|
||||
default:
|
||||
g_print ("context state %d\n", state);
|
||||
g_print ("context state: \"%s\"\n", pinos_context_state_as_string (state));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue