mirror of
				https://gitlab.freedesktop.org/pipewire/pipewire.git
				synced 2025-11-03 09:01:54 -05: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);
 | 
					                    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:
 | 
					 * pinos_context_new:
 | 
				
			||||||
 * @context: a #GMainContext to run in
 | 
					 * @context: a #GMainContext to run in
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -74,6 +74,8 @@ typedef enum {
 | 
				
			||||||
  PINOS_CONTEXT_STATE_READY        = 3,
 | 
					  PINOS_CONTEXT_STATE_READY        = 3,
 | 
				
			||||||
} PinosContextState;
 | 
					} PinosContextState;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const gchar * pinos_context_state_as_string (PinosContextState state);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * PinosContext:
 | 
					 * PinosContext:
 | 
				
			||||||
 *
 | 
					 *
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -229,6 +229,25 @@ pinos_context_get_client_info_by_id (PinosContext *context,
 | 
				
			||||||
  cb (context, NULL, user_data);
 | 
					  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
 | 
					static void
 | 
				
			||||||
source_fill_info (PinosSourceInfo *info, GDBusProxy *proxy)
 | 
					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);
 | 
					  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
 | 
					static void
 | 
				
			||||||
source_output_fill_info (PinosSourceOutputInfo *info, GDBusProxy *proxy)
 | 
					source_output_fill_info (PinosSourceOutputInfo *info, GDBusProxy *proxy)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -125,6 +125,8 @@ typedef enum {
 | 
				
			||||||
  PINOS_SOURCE_STATE_RUNNING = 3,
 | 
					  PINOS_SOURCE_STATE_RUNNING = 3,
 | 
				
			||||||
} PinosSourceState;
 | 
					} PinosSourceState;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const gchar * pinos_source_state_as_string (PinosSourceState state);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * PinosSourceInfo:
 | 
					 * PinosSourceInfo:
 | 
				
			||||||
 * @id: generic id of the source
 | 
					 * @id: generic id of the source
 | 
				
			||||||
| 
						 | 
					@ -190,6 +192,8 @@ typedef enum {
 | 
				
			||||||
  PINOS_SOURCE_OUTPUT_STATE_STREAMING = 2,
 | 
					  PINOS_SOURCE_OUTPUT_STATE_STREAMING = 2,
 | 
				
			||||||
} PinosSourceOutputState;
 | 
					} PinosSourceOutputState;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const gchar * pinos_source_output_state_as_string (PinosSourceOutputState state);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * PinosSourceOutputInfo:
 | 
					 * PinosSourceOutputInfo:
 | 
				
			||||||
 * @id: generic id of the output
 | 
					 * @id: generic id of the output
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -402,6 +402,25 @@ pinos_stream_init (PinosStream * stream)
 | 
				
			||||||
  priv->state = PINOS_STREAM_STATE_UNCONNECTED;
 | 
					  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:
 | 
					 * pinos_stream_new:
 | 
				
			||||||
 * @context: a #PinosContext
 | 
					 * @context: a #PinosContext
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -49,6 +49,7 @@ typedef enum {
 | 
				
			||||||
  PINOS_STREAM_STATE_STREAMING   = 4
 | 
					  PINOS_STREAM_STATE_STREAMING   = 4
 | 
				
			||||||
} PinosStreamState;
 | 
					} PinosStreamState;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					const gchar * pinos_stream_state_as_string (PinosStreamState state);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
typedef enum {
 | 
					typedef enum {
 | 
				
			||||||
  PINOS_STREAM_FLAGS_NONE = 0,
 | 
					  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))
 | 
					  if (info->change_mask & (1 << 1))
 | 
				
			||||||
    print_properties (info->properties);
 | 
					    print_properties (info->properties);
 | 
				
			||||||
  if (info->change_mask & (1 << 2))
 | 
					  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))
 | 
					  if (info->change_mask & (1 << 3))
 | 
				
			||||||
    print_formats ("possible formats", info->possible_formats);
 | 
					    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))
 | 
					  if (info->change_mask & (1 << 2))
 | 
				
			||||||
    print_formats ("possible-formats", info->possible_formats);
 | 
					    print_formats ("possible-formats", info->possible_formats);
 | 
				
			||||||
  if (info->change_mask & (1 << 3))
 | 
					  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))
 | 
					  if (info->change_mask & (1 << 4))
 | 
				
			||||||
    print_formats ("format", info->format);
 | 
					    print_formats ("format", info->format);
 | 
				
			||||||
  if (info->change_mask & (1 << 5))
 | 
					  if (info->change_mask & (1 << 5))
 | 
				
			||||||
| 
						 | 
					@ -243,7 +243,7 @@ on_state_notify (GObject    *gobject,
 | 
				
			||||||
      break;
 | 
					      break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    default:
 | 
					    default:
 | 
				
			||||||
      g_print ("context state %d\n", state);
 | 
					      g_print ("context state: \"%s\"\n", pinos_context_state_as_string (state));
 | 
				
			||||||
      break;
 | 
					      break;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue