mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-02 09:01:50 -05:00
Handle error cases
Add a link state Add error quark Track the state of node we create and error when it is in error. Handle stream error states when negotiating Make the node error when a link is in error
This commit is contained in:
parent
6497c82a7d
commit
2bf322ee71
15 changed files with 422 additions and 71 deletions
|
|
@ -433,6 +433,26 @@ pinos_direction_as_string (PinosDirection direction)
|
|||
return val == NULL ? "invalid-direction" : val->value_nick;
|
||||
}
|
||||
|
||||
/**
|
||||
* pinos_link_state_as_string:
|
||||
* @state: a #PinosLinkeState
|
||||
*
|
||||
* Return the string representation of @state.
|
||||
*
|
||||
* Returns: the string representation of @state.
|
||||
*/
|
||||
const gchar *
|
||||
pinos_link_state_as_string (PinosLinkState state)
|
||||
{
|
||||
GEnumValue *val;
|
||||
|
||||
val = g_enum_get_value (G_ENUM_CLASS (g_type_class_ref (PINOS_TYPE_LINK_STATE)),
|
||||
state);
|
||||
|
||||
return val == NULL ? "invalid-state" : val->value_nick;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
link_fill_info (PinosLinkInfo *info, GDBusProxy *proxy)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -64,6 +64,30 @@ typedef enum {
|
|||
|
||||
const gchar * pinos_direction_as_string (PinosDirection direction);
|
||||
|
||||
/**
|
||||
* PinosLinkState:
|
||||
* @PINOS_LINK_STATE_ERROR: the link is in error
|
||||
* @PINOS_LINK_STATE_UNLINKED: the link is unlinked
|
||||
* @PINOS_LINK_STATE_INIT: the link is initialized
|
||||
* @PINOS_LINK_STATE_NEGOTIATING: the link is negotiating formats
|
||||
* @PINOS_LINK_STATE_ALLOCATING: the link is allocating buffers
|
||||
* @PINOS_LINK_STATE_PAUSED: the link is paused
|
||||
* @PINOS_LINK_STATE_RUNNING: the link is running
|
||||
*
|
||||
* The different link states
|
||||
*/
|
||||
typedef enum {
|
||||
PINOS_LINK_STATE_ERROR = -2,
|
||||
PINOS_LINK_STATE_UNLINKED = -1,
|
||||
PINOS_LINK_STATE_INIT = 0,
|
||||
PINOS_LINK_STATE_NEGOTIATING = 1,
|
||||
PINOS_LINK_STATE_ALLOCATING = 2,
|
||||
PINOS_LINK_STATE_PAUSED = 3,
|
||||
PINOS_LINK_STATE_RUNNING = 4,
|
||||
} PinosLinkState;
|
||||
|
||||
const gchar * pinos_link_state_as_string (PinosLinkState state);
|
||||
|
||||
#include <pinos/client/context.h>
|
||||
#include <pinos/client/properties.h>
|
||||
|
||||
|
|
|
|||
|
|
@ -22,6 +22,16 @@
|
|||
#include "pinos/client/pinos.h"
|
||||
#include "spa/include/spa/memory.h"
|
||||
|
||||
GQuark
|
||||
pinos_error_quark (void)
|
||||
{
|
||||
static GQuark quark = 0;
|
||||
if (!quark)
|
||||
quark = g_quark_from_static_string ("pinos-error-quark");
|
||||
return quark;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* pinos_init:
|
||||
* @argc: pointer to argc
|
||||
|
|
|
|||
|
|
@ -36,6 +36,18 @@
|
|||
#define PINOS_DBUS_OBJECT_NODE PINOS_DBUS_OBJECT_PREFIX "/node"
|
||||
#define PINOS_DBUS_OBJECT_LINK PINOS_DBUS_OBJECT_PREFIX "/link"
|
||||
|
||||
typedef enum {
|
||||
PINOS_ERROR_FAILED,
|
||||
PINOS_ERROR_FORMAT_NEGOTIATION,
|
||||
PINOS_ERROR_BUFFER_ALLOCATION,
|
||||
PINOS_ERROR_NODE_STATE,
|
||||
PINOS_ERROR_NODE_PORT,
|
||||
PINOS_ERROR_NODE_LINK,
|
||||
} PinosErrorEnum;
|
||||
|
||||
GQuark pinos_error_quark (void);
|
||||
#define PINOS_ERROR pinos_error_quark()
|
||||
|
||||
void pinos_init (int *argc, char **argv[]);
|
||||
|
||||
gchar *pinos_client_name (void);
|
||||
|
|
|
|||
|
|
@ -230,6 +230,34 @@ stream_set_state (PinosStream *stream,
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
on_node_info (PinosContext *c,
|
||||
const PinosNodeInfo *info,
|
||||
gpointer user_data)
|
||||
{
|
||||
PinosStream *stream = PINOS_STREAM (user_data);
|
||||
|
||||
if (info->state == PINOS_NODE_STATE_ERROR) {
|
||||
g_debug ("stream %p: node %s in error", stream, info->node_path);
|
||||
stream_set_state (stream,
|
||||
PINOS_STREAM_STATE_ERROR,
|
||||
g_error_new (PINOS_ERROR,
|
||||
PINOS_ERROR_NODE_STATE,
|
||||
"node is in error"));
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
info_ready (GObject *o, GAsyncResult *res, gpointer user_data)
|
||||
{
|
||||
GError *error = NULL;
|
||||
|
||||
if (!pinos_context_info_finish (o, res, &error)) {
|
||||
g_printerr ("introspection failure: %s\n", error->message);
|
||||
g_clear_error (&error);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
subscription_cb (PinosSubscribe *subscribe,
|
||||
PinosSubscriptionEvent event,
|
||||
|
|
@ -250,6 +278,16 @@ subscription_cb (PinosSubscribe *subscribe,
|
|||
G_IO_ERROR_CLOSED,
|
||||
"Node disappeared"));
|
||||
}
|
||||
} else if (event == PINOS_SUBSCRIPTION_EVENT_CHANGE) {
|
||||
if (object == priv->node && !priv->disconnecting) {
|
||||
pinos_context_get_node_info_by_id (priv->context,
|
||||
object,
|
||||
PINOS_NODE_INFO_FLAGS_NONE,
|
||||
on_node_info,
|
||||
NULL,
|
||||
info_ready,
|
||||
stream);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue