add more debug statements

This commit is contained in:
Wim Taymans 2016-04-11 15:26:15 +02:00
parent d68d41b5b0
commit 44f2c3602d
6 changed files with 101 additions and 19 deletions

View file

@ -86,13 +86,13 @@ make buffer |--------->| |
(2) multisocketsink sends the buffer to N Pinos clients (2) multisocketsink sends the buffer to N Pinos clients
(3) for each client that is sent a buffer, multisocketsink sends an (3) for each client that is sent a buffer, multisocketsink sends an
event with the client object and buffer in it. event with the client object and buffer in it.
(4) pinospay maps the fd-index that was sent, to the buffer in a (4) pinospay uses the fdmanager object to map the fd-index that was
hashtable for each client. It refs the buffer so that it remains sent, to the buffer and client. The buffer is reffed and kept
alive for as long as the client is using the buffer. alive for as long as the client is using the buffer.
(5) when a message is received from a client, multisocketsink sends an (5) when a message is received from a client, multisocketsink sends an
event upstream. event upstream.
(6) pinospay parses the message and removes all fd-index entries from (6) pinospay parses the message and instructs the fdmanager to release
the client hashtable. When all clients release the fd, the buffer the fd-index again. When all clients release the fd, the buffer
will be unreffed and v4l2src can reuse the memory. will be unreffed and v4l2src can reuse the memory.
* client consumer * client consumer
@ -157,16 +157,24 @@ make buffer |--------->| |
freed. freed.
(3) multisocketsink sends the buffer to the clients (3) multisocketsink sends the buffer to the clients
(4) for each buffer that is sent, an event is sent to the payloader (4) for each buffer that is sent, an event is sent to the payloader
(5) the payloader remembers the fd-index and buffer in a per-client (5) the payloader uses the fdmanager to map the fd-index to a buffer
hashtable. it keeps a ref on the buffer and a client. it keeps a ref on the buffer
(6) release-fd is received from a client (6) release-fd is received from a client
(7) pinospay removes the fd-index from the client hashtable. If all (7) pinospay removes the fd-index from the fdmanager. If all
clients released the fd, the buffer will be freeds, triggering clients released the fd, the buffer will be freeds, triggering
the DestroyNotify. This will then trigger an event with a release-fd the DestroyNotify. This will then trigger an event with a release-fd
message to the source. message to the source.
(8) the source sends the release-fd message to Pinos (8) the source sends the release-fd message to Pinos
* client remove
When a client disconnects from pinos, it must have released all fd-indexes
that it received. Pinos will force a release and will reuse the fd-indexes
when the client disconnects.
Wire Wire
---- ----

View file

@ -322,7 +322,7 @@ release_fds (GstPinosPay *pay, GstBuffer *buffer)
for (i = 0; i < fdids->len; i++) { for (i = 0; i < fdids->len; i++) {
r.id = g_array_index (fdids, guint32, i); r.id = g_array_index (fdids, guint32, i);
GST_LOG ("release fd %d", r.id); GST_LOG ("release fd index %d", r.id);
pinos_buffer_builder_add_release_fd_payload (&b, &r); pinos_buffer_builder_add_release_fd_payload (&b, &r);
} }
pinos_buffer_builder_end (&b, &pbuf); pinos_buffer_builder_end (&b, &pbuf);

View file

@ -149,6 +149,8 @@ setup_pipeline (PinosClientSource *source)
bus = gst_pipeline_get_bus (GST_PIPELINE (priv->pipeline)); bus = gst_pipeline_get_bus (GST_PIPELINE (priv->pipeline));
priv->id = gst_bus_add_watch (bus, bus_handler, source); priv->id = gst_bus_add_watch (bus, bus_handler, source);
gst_object_unref (bus); gst_object_unref (bus);
g_debug ("client-source %p: setup pipeline", source);
} }
static GstCaps * static GstCaps *
@ -254,6 +256,8 @@ on_socket_notify (GObject *gobject,
g_object_get (gobject, "socket", &socket, NULL); g_object_get (gobject, "socket", &socket, NULL);
g_debug ("client-source %p: output socket notify %p", source, socket);
if (socket == NULL) { if (socket == NULL) {
GSocket *prev_socket = g_object_steal_data (gobject, "last-socket"); GSocket *prev_socket = g_object_steal_data (gobject, "last-socket");
if (prev_socket) { if (prev_socket) {
@ -302,6 +306,8 @@ client_create_source_output (PinosSource *source,
if (output == NULL) if (output == NULL)
return NULL; return NULL;
g_debug ("client-source %p: create output %p", source, output);
g_signal_connect (output, "notify::socket", (GCallback) on_socket_notify, source); g_signal_connect (output, "notify::socket", (GCallback) on_socket_notify, source);
return output; return output;
@ -311,6 +317,7 @@ static gboolean
client_release_source_output (PinosSource *source, client_release_source_output (PinosSource *source,
PinosSourceOutput *output) PinosSourceOutput *output)
{ {
g_debug ("client-source %p: release output %p", source, output);
return PINOS_SOURCE_CLASS (pinos_client_source_parent_class)->release_source_output (source, output); return PINOS_SOURCE_CLASS (pinos_client_source_parent_class)->release_source_output (source, output);
} }
@ -319,6 +326,8 @@ client_source_dispose (GObject * object)
{ {
PinosClientSourcePrivate *priv = PINOS_CLIENT_SOURCE (object)->priv; PinosClientSourcePrivate *priv = PINOS_CLIENT_SOURCE (object)->priv;
g_debug ("client-source %p: dispose", object);
g_source_remove (priv->id); g_source_remove (priv->id);
gst_element_set_state (priv->pipeline, GST_STATE_NULL); gst_element_set_state (priv->pipeline, GST_STATE_NULL);
@ -330,6 +339,8 @@ client_source_finalize (GObject * object)
{ {
PinosClientSourcePrivate *priv = PINOS_CLIENT_SOURCE (object)->priv; PinosClientSourcePrivate *priv = PINOS_CLIENT_SOURCE (object)->priv;
g_debug ("client-source %p: finalize", object);
g_clear_object (&priv->input); g_clear_object (&priv->input);
g_clear_object (&priv->sink); g_clear_object (&priv->sink);
g_clear_object (&priv->src); g_clear_object (&priv->src);
@ -355,6 +366,7 @@ on_input_socket_notify (GObject *gobject,
GstCaps *caps; GstCaps *caps;
g_object_get (gobject, "socket", &socket, NULL); g_object_get (gobject, "socket", &socket, NULL);
g_debug ("client-source %p: input socket notify %p", source, socket);
if (socket) { if (socket) {
/* requested format is final format */ /* requested format is final format */
@ -373,9 +385,11 @@ on_input_socket_notify (GObject *gobject,
g_object_set (priv->src, "socket", socket, NULL); g_object_set (priv->src, "socket", socket, NULL);
if (socket) { if (socket) {
g_debug ("client-source %p: set pipeline to PLAYING", source);
gst_element_set_state (priv->pipeline, GST_STATE_PLAYING); gst_element_set_state (priv->pipeline, GST_STATE_PLAYING);
g_object_unref (socket); g_object_unref (socket);
} else { } else {
g_debug ("client-source %p: set pipeline to READY", source);
gst_element_set_state (priv->pipeline, GST_STATE_READY); gst_element_set_state (priv->pipeline, GST_STATE_READY);
} }
} }
@ -384,8 +398,10 @@ static void
handle_remove_source_input (PinosSourceOutput *output, handle_remove_source_input (PinosSourceOutput *output,
gpointer user_data) gpointer user_data)
{ {
PinosClientSourcePrivate *priv = user_data; PinosClientSource *source = user_data;
PinosClientSourcePrivate *priv = source->priv;
g_debug ("client-source %p: remove source input %p", source, priv->input);
g_clear_pointer (&priv->input, g_object_unref); g_clear_pointer (&priv->input, g_object_unref);
} }
@ -420,8 +436,9 @@ pinos_client_source_get_source_input (PinosClientSource *source,
g_signal_connect (priv->input, g_signal_connect (priv->input,
"remove", "remove",
(GCallback) handle_remove_source_input, (GCallback) handle_remove_source_input,
priv); source);
g_debug ("client-source %p: get source input %p", source, priv->input);
g_signal_connect (priv->input, "notify::socket", (GCallback) on_input_socket_notify, source); g_signal_connect (priv->input, "notify::socket", (GCallback) on_input_socket_notify, source);
} }
return g_object_ref (priv->input); return g_object_ref (priv->input);
@ -462,6 +479,7 @@ pinos_client_source_init (PinosClientSource * source)
{ {
source->priv = PINOS_CLIENT_SOURCE_GET_PRIVATE (source); source->priv = PINOS_CLIENT_SOURCE_GET_PRIVATE (source);
g_debug ("client-source %p: new", source);
setup_pipeline (source); setup_pipeline (source);
} }

View file

@ -133,6 +133,7 @@ handle_remove_source_output (PinosSourceOutput *output,
PinosClient *client = user_data; PinosClient *client = user_data;
PinosClientPrivate *priv = client->priv; PinosClientPrivate *priv = client->priv;
g_debug ("client %p: remove source output %p", client, output);
priv->outputs = g_list_remove (priv->outputs, output); priv->outputs = g_list_remove (priv->outputs, output);
g_object_unref (output); g_object_unref (output);
} }
@ -189,6 +190,7 @@ handle_create_source_output (PinosClient1 *interface,
client); client);
object_path = pinos_source_output_get_object_path (output); object_path = pinos_source_output_get_object_path (output);
g_debug ("client %p: add source output %p, %s", client, output, object_path);
g_dbus_method_invocation_return_value (invocation, g_dbus_method_invocation_return_value (invocation,
g_variant_new ("(o)", object_path)); g_variant_new ("(o)", object_path));
@ -203,6 +205,7 @@ not_allowed:
} }
no_source: no_source:
{ {
g_debug ("client %p: could not find source %s, %s", client, arg_source, error->message);
g_dbus_method_invocation_return_gerror (invocation, error); g_dbus_method_invocation_return_gerror (invocation, error);
pinos_properties_free (props); pinos_properties_free (props);
g_bytes_unref (formats); g_bytes_unref (formats);
@ -211,6 +214,7 @@ no_source:
} }
no_output: no_output:
{ {
g_debug ("client %p: could not create output %s", client, error->message);
g_dbus_method_invocation_return_gerror (invocation, error); g_dbus_method_invocation_return_gerror (invocation, error);
g_clear_error (&error); g_clear_error (&error);
return TRUE; return TRUE;
@ -263,7 +267,7 @@ handle_create_source_input (PinosClient1 *interface,
g_object_unref); g_object_unref);
source_input_path = pinos_source_output_get_object_path (input); source_input_path = pinos_source_output_get_object_path (input);
g_debug ("client %p: add source input %p, %s", client, input, source_input_path);
priv->outputs = g_list_prepend (priv->outputs, input); priv->outputs = g_list_prepend (priv->outputs, input);
g_signal_connect (input, g_signal_connect (input,
@ -286,6 +290,7 @@ not_allowed:
} }
no_source: no_source:
{ {
g_debug ("client %p: could not create source", client);
g_dbus_method_invocation_return_dbus_error (invocation, g_dbus_method_invocation_return_dbus_error (invocation,
"org.pinos.Error", "Can't create source"); "org.pinos.Error", "Can't create source");
g_bytes_unref (formats); g_bytes_unref (formats);
@ -293,6 +298,7 @@ no_source:
} }
no_input: no_input:
{ {
g_debug ("client %p: could not create input %s", client, error->message);
g_dbus_method_invocation_return_gerror (invocation, error); g_dbus_method_invocation_return_gerror (invocation, error);
g_object_unref (source); g_object_unref (source);
g_clear_error (&error); g_clear_error (&error);
@ -307,6 +313,7 @@ handle_disconnect (PinosClient1 *interface,
{ {
PinosClient *client = user_data; PinosClient *client = user_data;
g_debug ("client %p: disconnect", client);
g_signal_emit (client, signals[SIGNAL_DISCONNECT], 0, NULL); g_signal_emit (client, signals[SIGNAL_DISCONNECT], 0, NULL);
g_dbus_method_invocation_return_value (invocation, g_dbus_method_invocation_return_value (invocation,
@ -343,6 +350,7 @@ client_register_object (PinosClient *client,
g_free (priv->object_path); g_free (priv->object_path);
priv->object_path = pinos_daemon_export_uniquely (daemon, G_DBUS_OBJECT_SKELETON (skel)); priv->object_path = pinos_daemon_export_uniquely (daemon, G_DBUS_OBJECT_SKELETON (skel));
g_debug ("client %p: register %s", client, priv->object_path);
} }
static void static void
@ -351,6 +359,7 @@ client_unregister_object (PinosClient *client)
PinosClientPrivate *priv = client->priv; PinosClientPrivate *priv = client->priv;
PinosDaemon *daemon = priv->daemon; PinosDaemon *daemon = priv->daemon;
g_debug ("client %p: unregister", client);
g_clear_object (&priv->client1); g_clear_object (&priv->client1);
pinos_daemon_unexport (daemon, priv->object_path); pinos_daemon_unexport (daemon, priv->object_path);
@ -361,6 +370,7 @@ static void
do_remove_output (PinosSourceOutput *output, do_remove_output (PinosSourceOutput *output,
PinosClient *client) PinosClient *client)
{ {
g_debug ("client %p: remove output %p", client, output);
pinos_source_output_remove (output); pinos_source_output_remove (output);
} }
@ -370,6 +380,7 @@ pinos_client_dispose (GObject * object)
PinosClient *client = PINOS_CLIENT (object); PinosClient *client = PINOS_CLIENT (object);
PinosClientPrivate *priv = client->priv; PinosClientPrivate *priv = client->priv;
g_debug ("client %p: dispose", client);
if (priv->object_path) if (priv->object_path)
pinos_fd_manager_remove_all (priv->fdmanager, priv->object_path); pinos_fd_manager_remove_all (priv->fdmanager, priv->object_path);
@ -379,12 +390,14 @@ pinos_client_dispose (GObject * object)
G_OBJECT_CLASS (pinos_client_parent_class)->dispose (object); G_OBJECT_CLASS (pinos_client_parent_class)->dispose (object);
} }
static void static void
pinos_client_finalize (GObject * object) pinos_client_finalize (GObject * object)
{ {
PinosClient *client = PINOS_CLIENT (object); PinosClient *client = PINOS_CLIENT (object);
PinosClientPrivate *priv = client->priv; PinosClientPrivate *priv = client->priv;
g_debug ("client %p: finalize", client);
g_free (priv->sender); g_free (priv->sender);
if (priv->properties) if (priv->properties)
pinos_properties_free (priv->properties); pinos_properties_free (priv->properties);
@ -399,6 +412,8 @@ pinos_client_constructed (GObject * object)
PinosClient *client = PINOS_CLIENT (object); PinosClient *client = PINOS_CLIENT (object);
PinosClientPrivate *priv = client->priv; PinosClientPrivate *priv = client->priv;
g_debug ("client %p: constructed", client);
client_register_object (client, priv->object_path); client_register_object (client, priv->object_path);
G_OBJECT_CLASS (pinos_client_parent_class)->constructed (object); G_OBJECT_CLASS (pinos_client_parent_class)->constructed (object);
@ -474,6 +489,7 @@ pinos_client_init (PinosClient * client)
{ {
PinosClientPrivate *priv = client->priv = PINOS_CLIENT_GET_PRIVATE (client); PinosClientPrivate *priv = client->priv = PINOS_CLIENT_GET_PRIVATE (client);
g_debug ("client %p: new", client);
priv->fdmanager = pinos_fd_manager_get (PINOS_FD_MANAGER_DEFAULT); priv->fdmanager = pinos_fd_manager_get (PINOS_FD_MANAGER_DEFAULT);
} }

View file

@ -66,10 +66,9 @@ client_name_appeared_handler (GDBusConnection *connection,
SenderData *data = user_data; SenderData *data = user_data;
PinosDaemonPrivate *priv = data->daemon->priv; PinosDaemonPrivate *priv = data->daemon->priv;
g_hash_table_insert (priv->senders, data->sender, data); g_debug ("daemon %p: appeared %s %s", data->daemon, name, name_owner);
if (!g_strcmp0 (name, g_dbus_connection_get_unique_name (connection))) g_hash_table_insert (priv->senders, data->sender, data);
return;
} }
static void static void
@ -79,12 +78,15 @@ client_name_vanished_handler (GDBusConnection *connection,
{ {
SenderData *data = user_data; SenderData *data = user_data;
g_debug ("daemon %p: vanished %s", data->daemon, name);
g_bus_unwatch_name (data->id); g_bus_unwatch_name (data->id);
} }
static void static void
data_free (SenderData *data) data_free (SenderData *data)
{ {
g_debug ("daemon %p: free sender data %p for %s", data->daemon, data, data->sender);
g_list_free_full (data->objects, g_object_unref); g_list_free_full (data->objects, g_object_unref);
g_hash_table_remove (data->daemon->priv->senders, data->sender); g_hash_table_remove (data->daemon->priv->senders, data->sender);
g_free (data->sender); g_free (data->sender);
@ -102,6 +104,8 @@ sender_data_new (PinosDaemon *daemon,
data->daemon = daemon; data->daemon = daemon;
data->sender = g_strdup (sender); data->sender = g_strdup (sender);
g_debug ("daemon %p: new sender data %p for %s", daemon, data, sender);
data->id = g_bus_watch_name_on_connection (priv->connection, data->id = g_bus_watch_name_on_connection (priv->connection,
sender, sender,
G_BUS_NAME_WATCHER_FLAGS_NONE, G_BUS_NAME_WATCHER_FLAGS_NONE,
@ -109,8 +113,6 @@ sender_data_new (PinosDaemon *daemon,
client_name_vanished_handler, client_name_vanished_handler,
data, data,
(GDestroyNotify) data_free); (GDestroyNotify) data_free);
return data; return data;
} }
@ -125,10 +127,13 @@ handle_disconnect_client (PinosClient *client,
sender = pinos_client_get_sender (client); sender = pinos_client_get_sender (client);
g_debug ("daemon %p: client %p disconnect %s", daemon, client, sender);
data = g_hash_table_lookup (priv->senders, sender); data = g_hash_table_lookup (priv->senders, sender);
if (data == NULL) if (data == NULL)
return; return;
g_debug ("daemon %p: client %p unref", daemon, client);
data->objects = g_list_remove (data->objects, client); data->objects = g_list_remove (data->objects, client);
g_object_unref (client); g_object_unref (client);
} }
@ -148,6 +153,8 @@ handle_connect_client (PinosDaemon1 *interface,
sender = g_dbus_method_invocation_get_sender (invocation); sender = g_dbus_method_invocation_get_sender (invocation);
g_debug ("daemon %p: connect client: %s", daemon, sender);
props = pinos_properties_from_variant (arg_properties); props = pinos_properties_from_variant (arg_properties);
client = pinos_client_new (daemon, sender, PINOS_DBUS_OBJECT_PREFIX, props); client = pinos_client_new (daemon, sender, PINOS_DBUS_OBJECT_PREFIX, props);
pinos_properties_free (props); pinos_properties_free (props);
@ -161,6 +168,7 @@ handle_connect_client (PinosDaemon1 *interface,
data->objects = g_list_prepend (data->objects, client); data->objects = g_list_prepend (data->objects, client);
object_path = pinos_client_get_object_path (client); object_path = pinos_client_get_object_path (client);
g_debug ("daemon %p: added client %p with path %s", daemon, client, object_path);
g_dbus_method_invocation_return_value (invocation, g_dbus_method_invocation_return_value (invocation,
g_variant_new ("(o)", object_path)); g_variant_new ("(o)", object_path));
@ -260,6 +268,8 @@ pinos_daemon_start (PinosDaemon *daemon)
priv = daemon->priv; priv = daemon->priv;
g_return_if_fail (priv->id == 0); g_return_if_fail (priv->id == 0);
g_debug ("daemon %p: start", daemon);
priv->id = g_bus_own_name (G_BUS_TYPE_SESSION, priv->id = g_bus_own_name (G_BUS_TYPE_SESSION,
PINOS_DBUS_SERVICE, PINOS_DBUS_SERVICE,
G_BUS_NAME_OWNER_FLAGS_REPLACE, G_BUS_NAME_OWNER_FLAGS_REPLACE,
@ -283,6 +293,8 @@ pinos_daemon_stop (PinosDaemon *daemon)
g_return_if_fail (PINOS_IS_DAEMON (daemon)); g_return_if_fail (PINOS_IS_DAEMON (daemon));
g_debug ("daemon %p: stop", daemon);
if (priv->id != 0) { if (priv->id != 0) {
g_bus_unown_name (priv->id); g_bus_unown_name (priv->id);
priv->id = 0; priv->id = 0;
@ -463,6 +475,8 @@ pinos_daemon_dispose (GObject * object)
{ {
PinosDaemon *daemon = PINOS_DAEMON_CAST (object); PinosDaemon *daemon = PINOS_DAEMON_CAST (object);
g_debug ("daemon %p: dispose", object);
pinos_daemon_stop (daemon); pinos_daemon_stop (daemon);
G_OBJECT_CLASS (pinos_daemon_parent_class)->dispose (object); G_OBJECT_CLASS (pinos_daemon_parent_class)->dispose (object);
@ -474,6 +488,7 @@ pinos_daemon_finalize (GObject * object)
PinosDaemon *daemon = PINOS_DAEMON_CAST (object); PinosDaemon *daemon = PINOS_DAEMON_CAST (object);
PinosDaemonPrivate *priv = daemon->priv; PinosDaemonPrivate *priv = daemon->priv;
g_debug ("daemon %p: finalize", object);
g_clear_object (&priv->server_manager); g_clear_object (&priv->server_manager);
G_OBJECT_CLASS (pinos_daemon_parent_class)->finalize (object); G_OBJECT_CLASS (pinos_daemon_parent_class)->finalize (object);
@ -509,6 +524,8 @@ pinos_daemon_init (PinosDaemon * daemon)
{ {
PinosDaemonPrivate *priv = daemon->priv = PINOS_DAEMON_GET_PRIVATE (daemon); PinosDaemonPrivate *priv = daemon->priv = PINOS_DAEMON_GET_PRIVATE (daemon);
g_debug ("daemon %p: new", daemon);
priv->server_manager = g_dbus_object_manager_server_new (PINOS_DBUS_OBJECT_PREFIX); priv->server_manager = g_dbus_object_manager_server_new (PINOS_DBUS_OBJECT_PREFIX);
priv->senders = g_hash_table_new (g_str_hash, g_str_equal); priv->senders = g_hash_table_new (g_str_hash, g_str_equal);
} }

View file

@ -192,6 +192,8 @@ clear_formats (PinosSourceOutput *output)
{ {
PinosSourceOutputPrivate *priv = output->priv; PinosSourceOutputPrivate *priv = output->priv;
g_debug ("source-output %p: clear format", output);
g_clear_pointer (&priv->requested_format, g_bytes_unref); g_clear_pointer (&priv->requested_format, g_bytes_unref);
g_clear_pointer (&priv->format, g_bytes_unref); g_clear_pointer (&priv->format, g_bytes_unref);
} }
@ -201,6 +203,8 @@ stop_transfer (PinosSourceOutput *output)
{ {
PinosSourceOutputPrivate *priv = output->priv; PinosSourceOutputPrivate *priv = output->priv;
g_debug ("source-output %p: stop transfer", output);
if (priv->socket) { if (priv->socket) {
g_clear_object (&priv->socket); g_clear_object (&priv->socket);
g_object_notify (G_OBJECT (output), "socket"); g_object_notify (G_OBJECT (output), "socket");
@ -222,6 +226,7 @@ handle_start (PinosSourceOutput1 *interface,
PinosSourceOutputPrivate *priv = output->priv; PinosSourceOutputPrivate *priv = output->priv;
GUnixFDList *fdlist; GUnixFDList *fdlist;
gint fd[2]; gint fd[2];
const gchar *format;
priv->state = PINOS_SOURCE_OUTPUT_STATE_STARTING; priv->state = PINOS_SOURCE_OUTPUT_STATE_STARTING;
@ -230,16 +235,23 @@ handle_start (PinosSourceOutput1 *interface,
socketpair (AF_UNIX, SOCK_STREAM, 0, fd); socketpair (AF_UNIX, SOCK_STREAM, 0, fd);
g_debug ("source-output %p: handle start, fd[%d,%d]", output, fd[0], fd[1]);
g_clear_object (&priv->socket); g_clear_object (&priv->socket);
priv->socket = g_socket_new_from_fd (fd[0], NULL); priv->socket = g_socket_new_from_fd (fd[0], NULL);
g_object_set_data (priv->socket, "pinos-client-path", priv->client_path); g_object_set_data (G_OBJECT (priv->socket), "pinos-client-path", priv->client_path);
g_debug ("source-output %p: notify socket %p, path %s", output, priv->socket, priv->client_path);
g_object_notify (G_OBJECT (output), "socket"); g_object_notify (G_OBJECT (output), "socket");
/* the notify of the socket above should configure the format */ /* the notify of the socket above should configure the format */
if (priv->format == NULL) if (priv->format == NULL)
goto no_format; goto no_format;
format = g_bytes_get_data (priv->format, NULL);
priv->state = PINOS_SOURCE_OUTPUT_STATE_STREAMING; priv->state = PINOS_SOURCE_OUTPUT_STATE_STREAMING;
g_debug ("source-output %p: we are now streaming in format \"%s\"", output, format);
fdlist = g_unix_fd_list_new (); fdlist = g_unix_fd_list_new ();
g_unix_fd_list_append (fdlist, fd[1], NULL); g_unix_fd_list_append (fdlist, fd[1], NULL);
@ -247,14 +259,14 @@ handle_start (PinosSourceOutput1 *interface,
g_dbus_method_invocation_return_value_with_unix_fd_list (invocation, g_dbus_method_invocation_return_value_with_unix_fd_list (invocation,
g_variant_new ("(hs@a{sv})", g_variant_new ("(hs@a{sv})",
0, 0,
g_bytes_get_data (priv->format, NULL), format,
pinos_properties_to_variant (priv->properties)), pinos_properties_to_variant (priv->properties)),
fdlist); fdlist);
g_object_unref (fdlist); g_object_unref (fdlist);
close (fd[1]); close (fd[1]);
g_object_set (priv->iface, g_object_set (priv->iface,
"format", g_bytes_get_data (priv->format, NULL), "format", format,
"state", priv->state, "state", priv->state,
NULL); NULL);
@ -263,6 +275,7 @@ handle_start (PinosSourceOutput1 *interface,
/* error */ /* error */
no_format: no_format:
{ {
g_debug ("source-output %p: no format configured", output);
g_dbus_method_invocation_return_dbus_error (invocation, g_dbus_method_invocation_return_dbus_error (invocation,
"org.pinos.Error", "No format"); "org.pinos.Error", "No format");
close (fd[0]); close (fd[0]);
@ -280,6 +293,7 @@ handle_stop (PinosSourceOutput1 *interface,
{ {
PinosSourceOutput *output = user_data; PinosSourceOutput *output = user_data;
g_debug ("source-output %p: handle stop", output);
stop_transfer (output); stop_transfer (output);
g_dbus_method_invocation_return_value (invocation, NULL); g_dbus_method_invocation_return_value (invocation, NULL);
@ -294,6 +308,7 @@ handle_remove (PinosSourceOutput1 *interface,
{ {
PinosSourceOutput *output = user_data; PinosSourceOutput *output = user_data;
g_debug ("source-output %p: handle remove", output);
stop_transfer (output); stop_transfer (output);
g_signal_emit (output, signals[SIGNAL_REMOVE], 0, NULL); g_signal_emit (output, signals[SIGNAL_REMOVE], 0, NULL);
@ -319,6 +334,7 @@ output_register_object (PinosSourceOutput *output,
g_free (priv->object_path); g_free (priv->object_path);
priv->object_path = pinos_daemon_export_uniquely (priv->daemon, G_DBUS_OBJECT_SKELETON (skel)); priv->object_path = pinos_daemon_export_uniquely (priv->daemon, G_DBUS_OBJECT_SKELETON (skel));
g_debug ("source-output %p: register object %s", output, priv->object_path);
} }
static void static void
@ -326,6 +342,7 @@ output_unregister_object (PinosSourceOutput *output)
{ {
PinosSourceOutputPrivate *priv = output->priv; PinosSourceOutputPrivate *priv = output->priv;
g_debug ("source-output %p: unregister object", output);
pinos_daemon_unexport (priv->daemon, priv->object_path); pinos_daemon_unexport (priv->daemon, priv->object_path);
} }
@ -335,6 +352,7 @@ pinos_source_output_dispose (GObject * object)
PinosSourceOutput *output = PINOS_SOURCE_OUTPUT (object); PinosSourceOutput *output = PINOS_SOURCE_OUTPUT (object);
PinosSourceOutputPrivate *priv = output->priv; PinosSourceOutputPrivate *priv = output->priv;
g_debug ("source-output %p: dispose", output);
clear_formats (output); clear_formats (output);
g_clear_object (&priv->socket); g_clear_object (&priv->socket);
output_unregister_object (output); output_unregister_object (output);
@ -348,6 +366,7 @@ pinos_source_output_finalize (GObject * object)
PinosSourceOutput *output = PINOS_SOURCE_OUTPUT (object); PinosSourceOutput *output = PINOS_SOURCE_OUTPUT (object);
PinosSourceOutputPrivate *priv = output->priv; PinosSourceOutputPrivate *priv = output->priv;
g_debug ("source-output %p: finalize", output);
if (priv->possible_formats) if (priv->possible_formats)
g_bytes_unref (priv->possible_formats); g_bytes_unref (priv->possible_formats);
if (priv->properties) if (priv->properties)
@ -367,6 +386,7 @@ pinos_source_output_constructed (GObject * object)
PinosSourceOutput *output = PINOS_SOURCE_OUTPUT (object); PinosSourceOutput *output = PINOS_SOURCE_OUTPUT (object);
PinosSourceOutputPrivate *priv = output->priv; PinosSourceOutputPrivate *priv = output->priv;
g_debug ("source-output %p: constructed", output);
output_register_object (output, priv->object_path); output_register_object (output, priv->object_path);
G_OBJECT_CLASS (pinos_source_output_parent_class)->constructed (object); G_OBJECT_CLASS (pinos_source_output_parent_class)->constructed (object);
@ -496,11 +516,14 @@ pinos_source_output_init (PinosSourceOutput * output)
priv->state = PINOS_SOURCE_OUTPUT_STATE_IDLE; priv->state = PINOS_SOURCE_OUTPUT_STATE_IDLE;
g_object_set (priv->iface, "state", priv->state, NULL); g_object_set (priv->iface, "state", priv->state, NULL);
g_debug ("source-output %p: new", output);
} }
void void
pinos_source_output_remove (PinosSourceOutput *output) pinos_source_output_remove (PinosSourceOutput *output)
{ {
g_debug ("source-output %p: remove", output);
stop_transfer (output); stop_transfer (output);
g_signal_emit (output, signals[SIGNAL_REMOVE], 0, NULL); g_signal_emit (output, signals[SIGNAL_REMOVE], 0, NULL);