diff options
author | Michal Ratajsky <[email protected]> | 2014-08-12 04:56:55 +0200 |
---|---|---|
committer | Michal Ratajsky <[email protected]> | 2014-08-12 04:56:55 +0200 |
commit | 6c6d4239ddc807e922df3874654f99eea291aadb (patch) | |
tree | 558f48fc965476344a946d93088680db3b5bac41 /libmatemixer/matemixer-client-stream.c | |
parent | 8436ec1641eee8868128755f6d1475230cea25e6 (diff) | |
download | libmatemixer-6c6d4239ddc807e922df3874654f99eea291aadb.tar.bz2 libmatemixer-6c6d4239ddc807e922df3874654f99eea291aadb.tar.xz |
Add ALSA, improve OSS and remove OSS4
Diffstat (limited to 'libmatemixer/matemixer-client-stream.c')
-rw-r--r-- | libmatemixer/matemixer-client-stream.c | 311 |
1 files changed, 186 insertions, 125 deletions
diff --git a/libmatemixer/matemixer-client-stream.c b/libmatemixer/matemixer-client-stream.c index 3ff3c54..fc34622 100644 --- a/libmatemixer/matemixer-client-stream.c +++ b/libmatemixer/matemixer-client-stream.c @@ -35,68 +35,170 @@ * A typical example of a client stream is a stream provided by an application. */ -G_DEFINE_INTERFACE (MateMixerClientStream, mate_mixer_client_stream, G_TYPE_OBJECT) +struct _MateMixerClientStreamPrivate +{ + gchar *app_name; + gchar *app_id; + gchar *app_version; + gchar *app_icon; + MateMixerStream *parent; + MateMixerClientStreamFlags client_flags; + MateMixerClientStreamRole client_role; +}; + +enum { + PROP_0, + PROP_CLIENT_FLAGS, + PROP_CLIENT_ROLE, + PROP_PARENT, + PROP_APP_NAME, + PROP_APP_ID, + PROP_APP_VERSION, + PROP_APP_ICON, + N_PROPERTIES +}; + +static GParamSpec *properties[N_PROPERTIES] = { NULL, }; + +static void mate_mixer_client_stream_class_init (MateMixerClientStreamClass *klass); + +static void mate_mixer_client_stream_init (MateMixerClientStream *client); + +static void mate_mixer_client_stream_get_property (GObject *object, + guint param_id, + GValue *value, + GParamSpec *pspec); +static void mate_mixer_client_stream_set_property (GObject *object, + guint param_id, + const GValue *value, + GParamSpec *pspec); + +static void mate_mixer_client_stream_dispose (GObject *object); +static void mate_mixer_client_stream_finalize (GObject *object); + +G_DEFINE_ABSTRACT_TYPE (MateMixerClientStream, mate_mixer_client_stream, MATE_MIXER_TYPE_STREAM) + +static void +mate_mixer_client_stream_class_init (MateMixerClientStreamClass *klass) +{ + GObjectClass *object_class; + + object_class = G_OBJECT_CLASS (klass); + object_class->dispose = mate_mixer_client_stream_dispose; + object_class->finalize = mate_mixer_client_stream_finalize; + object_class->get_property = mate_mixer_client_stream_get_property; + object_class->set_property = mate_mixer_client_stream_set_property; + + properties[PROP_CLIENT_FLAGS] = + g_param_spec_flags ("client-flags", + "Client flags", + "Capability flags of the client stream", + MATE_MIXER_TYPE_CLIENT_STREAM_FLAGS, + MATE_MIXER_CLIENT_STREAM_NO_FLAGS, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS); + + properties[PROP_CLIENT_ROLE] = + g_param_spec_enum ("role", + "Role", + "Role of the client stream", + MATE_MIXER_TYPE_CLIENT_STREAM_ROLE, + MATE_MIXER_CLIENT_STREAM_ROLE_NONE, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS); + + properties[PROP_PARENT] = + g_param_spec_object ("parent", + "Parent", + "Parent stream of the client stream", + MATE_MIXER_TYPE_STREAM, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS); + + properties[PROP_APP_NAME] = + g_param_spec_string ("app-name", + "App name", + "Name of the client stream application", + NULL, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS); + + properties[PROP_APP_ID] = + g_param_spec_string ("app-id", + "App ID", + "Identifier of the client stream application", + NULL, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS); + + properties[PROP_APP_VERSION] = + g_param_spec_string ("app-version", + "App version", + "Version of the client stream application", + NULL, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS); + + properties[PROP_APP_ICON] = + g_param_spec_string ("app-icon", + "App icon", + "Icon name of the client stream application", + NULL, + G_PARAM_READABLE | + G_PARAM_STATIC_STRINGS); + + g_object_class_install_properties (object_class, N_PROPERTIES, properties); +} + +static void +mate_mixer_client_stream_init (MateMixerClientStream *client) +{ + client->priv = G_TYPE_INSTANCE_GET_PRIVATE (client, + MATE_MIXER_TYPE_CLIENT_STREAM, + MateMixerClientStreamPrivate); +} static void -mate_mixer_client_stream_default_init (MateMixerClientStreamInterface *iface) +mate_mixer_client_stream_get_property (GObject *object, + guint param_id, + GValue *value, + GParamSpec *pspec) { - g_object_interface_install_property (iface, - g_param_spec_flags ("client-flags", - "Client flags", - "Capability flags of the client stream", - MATE_MIXER_TYPE_CLIENT_STREAM_FLAGS, - MATE_MIXER_CLIENT_STREAM_NO_FLAGS, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS)); - - g_object_interface_install_property (iface, - g_param_spec_enum ("role", - "Role", - "Role of the client stream", - MATE_MIXER_TYPE_CLIENT_STREAM_ROLE, - MATE_MIXER_CLIENT_STREAM_ROLE_NONE, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS)); - - g_object_interface_install_property (iface, - g_param_spec_object ("parent", - "Parent", - "Parent stream of the client stream", - MATE_MIXER_TYPE_STREAM, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS)); - - g_object_interface_install_property (iface, - g_param_spec_string ("app-name", - "App name", - "Name of the client stream application", - NULL, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS)); - - g_object_interface_install_property (iface, - g_param_spec_string ("app-id", - "App ID", - "Identifier of the client stream application", - NULL, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS)); - - g_object_interface_install_property (iface, - g_param_spec_string ("app-version", - "App version", - "Version of the client stream application", - NULL, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS)); - - g_object_interface_install_property (iface, - g_param_spec_string ("app-icon", - "App icon", - "Icon name of the client stream application", - NULL, - G_PARAM_READABLE | - G_PARAM_STATIC_STRINGS)); +} + +static void +mate_mixer_client_stream_set_property (GObject *object, + guint param_id, + const GValue *value, + GParamSpec *pspec) +{ +} + +static void +mate_mixer_client_stream_dispose (GObject *object) +{ + MateMixerClientStream *client; + + client = MATE_MIXER_CLIENT_STREAM (object); + + g_clear_object (&client->priv->parent); + + G_OBJECT_CLASS (mate_mixer_client_stream_parent_class)->dispose (object); +} + +static void +mate_mixer_client_stream_finalize (GObject *object) +{ + MateMixerClientStream *client; + + client = MATE_MIXER_CLIENT_STREAM (object); + + g_free (client->priv->app_name); + g_free (client->priv->app_id); + g_free (client->priv->app_version); + g_free (client->priv->app_icon); + + G_OBJECT_CLASS (mate_mixer_client_stream_parent_class)->finalize (object); } /** @@ -107,16 +209,9 @@ mate_mixer_client_stream_default_init (MateMixerClientStreamInterface *iface) MateMixerClientStreamFlags mate_mixer_client_stream_get_flags (MateMixerClientStream *client) { - MateMixerClientStreamInterface *iface; - g_return_val_if_fail (MATE_MIXER_IS_CLIENT_STREAM (client), MATE_MIXER_CLIENT_STREAM_NO_FLAGS); - iface = MATE_MIXER_CLIENT_STREAM_GET_INTERFACE (client); - - if (iface->get_flags) - return iface->get_flags (client); - - return MATE_MIXER_CLIENT_STREAM_NO_FLAGS; + return client->priv->client_flags; } /** @@ -127,16 +222,9 @@ mate_mixer_client_stream_get_flags (MateMixerClientStream *client) MateMixerClientStreamRole mate_mixer_client_stream_get_role (MateMixerClientStream *client) { - MateMixerClientStreamInterface *iface; - g_return_val_if_fail (MATE_MIXER_IS_CLIENT_STREAM (client), MATE_MIXER_CLIENT_STREAM_ROLE_NONE); - iface = MATE_MIXER_CLIENT_STREAM_GET_INTERFACE (client); - - if (iface->get_role) - return iface->get_role (client); - - return MATE_MIXER_CLIENT_STREAM_ROLE_NONE; + return client->priv->client_role; } /** @@ -150,16 +238,9 @@ mate_mixer_client_stream_get_role (MateMixerClientStream *client) MateMixerStream * mate_mixer_client_stream_get_parent (MateMixerClientStream *client) { - MateMixerClientStreamInterface *iface; - g_return_val_if_fail (MATE_MIXER_IS_CLIENT_STREAM (client), NULL); - iface = MATE_MIXER_CLIENT_STREAM_GET_INTERFACE (client); - - if (iface->get_parent) - return iface->get_parent (client); - - return NULL; + return client->priv->parent; } /** @@ -175,17 +256,25 @@ mate_mixer_client_stream_get_parent (MateMixerClientStream *client) gboolean mate_mixer_client_stream_set_parent (MateMixerClientStream *client, MateMixerStream *parent) { - MateMixerClientStreamInterface *iface; - g_return_val_if_fail (MATE_MIXER_IS_CLIENT_STREAM (client), FALSE); g_return_val_if_fail (MATE_MIXER_IS_STREAM (parent), FALSE); - iface = MATE_MIXER_CLIENT_STREAM_GET_INTERFACE (client); + if (client->priv->parent != parent) { + MateMixerClientStreamClass *klass; - if (iface->set_parent) - return iface->set_parent (client, parent); + klass = MATE_MIXER_CLIENT_STREAM_GET_CLASS (client); - return FALSE; + if (klass->set_parent == NULL || + klass->set_parent (client, parent) == FALSE) + return FALSE; + + if (client->priv->parent != NULL) + g_object_unref (client->priv->parent); + + client->priv->parent = g_object_ref (parent); + } + + return TRUE; } /** @@ -199,14 +288,14 @@ mate_mixer_client_stream_set_parent (MateMixerClientStream *client, MateMixerStr gboolean mate_mixer_client_stream_remove (MateMixerClientStream *client) { - MateMixerClientStreamInterface *iface; + MateMixerClientStreamClass *klass; g_return_val_if_fail (MATE_MIXER_IS_CLIENT_STREAM (client), FALSE); - iface = MATE_MIXER_CLIENT_STREAM_GET_INTERFACE (client); + klass = MATE_MIXER_CLIENT_STREAM_GET_CLASS (client); - if (iface->remove) - return iface->remove (client); + if (klass->remove != NULL) + return klass->remove (client); return FALSE; } @@ -224,16 +313,9 @@ mate_mixer_client_stream_remove (MateMixerClientStream *client) const gchar * mate_mixer_client_stream_get_app_name (MateMixerClientStream *client) { - MateMixerClientStreamInterface *iface; - g_return_val_if_fail (MATE_MIXER_IS_CLIENT_STREAM (client), NULL); - iface = MATE_MIXER_CLIENT_STREAM_GET_INTERFACE (client); - - if (iface->get_app_name) - return iface->get_app_name (client); - - return NULL; + return client->priv->app_name; } /** @@ -249,16 +331,9 @@ mate_mixer_client_stream_get_app_name (MateMixerClientStream *client) const gchar * mate_mixer_client_stream_get_app_id (MateMixerClientStream *client) { - MateMixerClientStreamInterface *iface; - g_return_val_if_fail (MATE_MIXER_IS_CLIENT_STREAM (client), NULL); - iface = MATE_MIXER_CLIENT_STREAM_GET_INTERFACE (client); - - if (iface->get_app_id) - return iface->get_app_id (client); - - return NULL; + return client->priv->app_id; } /** @@ -274,16 +349,9 @@ mate_mixer_client_stream_get_app_id (MateMixerClientStream *client) const gchar * mate_mixer_client_stream_get_app_version (MateMixerClientStream *client) { - MateMixerClientStreamInterface *iface; - g_return_val_if_fail (MATE_MIXER_IS_CLIENT_STREAM (client), NULL); - iface = MATE_MIXER_CLIENT_STREAM_GET_INTERFACE (client); - - if (iface->get_app_version) - return iface->get_app_version (client); - - return NULL; + return client->priv->app_version; } /** @@ -299,14 +367,7 @@ mate_mixer_client_stream_get_app_version (MateMixerClientStream *client) const gchar * mate_mixer_client_stream_get_app_icon (MateMixerClientStream *client) { - MateMixerClientStreamInterface *iface; - g_return_val_if_fail (MATE_MIXER_IS_CLIENT_STREAM (client), NULL); - iface = MATE_MIXER_CLIENT_STREAM_GET_INTERFACE (client); - - if (iface->get_app_icon) - return iface->get_app_icon (client); - - return NULL; + return client->priv->app_icon; } |