From 9f07ba229cc94ff33a1c2d8c163bb46f95c4a62f Mon Sep 17 00:00:00 2001 From: Julian Bouzas Date: Thu, 25 Jul 2019 12:26:09 +0300 Subject: [PATCH] dsp: removed unneeded format property and always use the default format --- modules/module-pipewire/simple-endpoint.c | 6 ++--- modules/module-pw-audio-softdsp-endpoint.c | 15 +++-------- .../module-pw-audio-softdsp-endpoint/dsp.c | 26 ++++++------------- .../module-pw-audio-softdsp-endpoint/dsp.h | 4 +-- 4 files changed, 16 insertions(+), 35 deletions(-) diff --git a/modules/module-pipewire/simple-endpoint.c b/modules/module-pipewire/simple-endpoint.c index cb8bc9bc..b1e2e072 100644 --- a/modules/module-pipewire/simple-endpoint.c +++ b/modules/module-pipewire/simple-endpoint.c @@ -230,13 +230,13 @@ emit_endpoint_ports(WpPipewireSimpleEndpoint *self) node_proxy = wp_proxy_get_pw_proxy(WP_PROXY(self->proxy_node)); g_return_if_fail (node_proxy); - /* TODO: Assume all clients have this format for now */ + /* The default format for audio clients */ format.format = SPA_AUDIO_FORMAT_F32P; format.flags = 1; format.rate = 48000; format.channels = 2; - format.position[0] = 0; - format.position[1] = 0; + format.position[0] = SPA_AUDIO_CHANNEL_FL; + format.position[1] = SPA_AUDIO_CHANNEL_FR; /* Build the param profile */ spa_pod_builder_init(&pod_builder, buf, sizeof(buf)); diff --git a/modules/module-pw-audio-softdsp-endpoint.c b/modules/module-pw-audio-softdsp-endpoint.c index 91117135..f7c74452 100644 --- a/modules/module-pw-audio-softdsp-endpoint.c +++ b/modules/module-pw-audio-softdsp-endpoint.c @@ -169,7 +169,6 @@ on_audio_dsp_converter_created(GObject *initable, GAsyncResult *res, WpPwAudioSoftdspEndpoint *self = data; g_autoptr (WpCore) core = wp_endpoint_get_core(WP_ENDPOINT(self)); const struct pw_node_info *target = NULL; - const struct spa_audio_info_raw *format = NULL; GVariantDict d; GVariantIter iter; const gchar *stream; @@ -184,14 +183,12 @@ on_audio_dsp_converter_created(GObject *initable, GAsyncResult *res, /* Get the target and format */ target = wp_pw_audio_dsp_get_info (self->converter); g_return_if_fail (target); - g_object_get (self->converter, "format", &format, NULL); - g_return_if_fail (format); /* Create the audio dsp streams */ g_variant_iter_init (&iter, self->streams); for (i = 0; g_variant_iter_next (&iter, "&s", &stream); i++) { - wp_pw_audio_dsp_new (WP_ENDPOINT(self), i, stream, self->direction, - FALSE, target, format, on_audio_dsp_stream_created, self); + wp_pw_audio_dsp_new (WP_ENDPOINT(self), i, stream, self->direction, FALSE, + target, on_audio_dsp_stream_created, self); /* Register the stream */ g_variant_dict_init (&d, NULL); @@ -210,7 +207,6 @@ on_proxy_node_created(GObject *initable, GAsyncResult *res, gpointer data) g_autofree gchar *name = NULL; const struct spa_dict *props; const struct pw_node_info *target = NULL; - const struct spa_audio_info_raw *format = NULL; /* Get the proxy node */ self->proxy_node = WP_PROXY_NODE (object_safe_new_finish (self, initable, @@ -230,13 +226,8 @@ on_proxy_node_created(GObject *initable, GAsyncResult *res, gpointer data) /* Create the converter proxy */ target = wp_proxy_node_get_info (self->proxy_node); g_return_if_fail (target); - format = wp_proxy_port_get_format (self->proxy_port); - g_return_if_fail (format); - /* TODO: For now we create convert as a stream because convert mode does not - * generate any ports, not sure why */ wp_pw_audio_dsp_new (WP_ENDPOINT(self), WP_STREAM_ID_NONE, "master", - self->direction, TRUE, target, format, on_audio_dsp_converter_created, - self); + self->direction, TRUE, target, on_audio_dsp_converter_created, self); } static void diff --git a/modules/module-pw-audio-softdsp-endpoint/dsp.c b/modules/module-pw-audio-softdsp-endpoint/dsp.c index 8faa8273..f3282a8b 100644 --- a/modules/module-pw-audio-softdsp-endpoint/dsp.c +++ b/modules/module-pw-audio-softdsp-endpoint/dsp.c @@ -24,7 +24,6 @@ enum { PROP_DIRECTION, PROP_CONVERT, PROP_TARGET, - PROP_FORMAT, }; enum { @@ -51,7 +50,6 @@ struct _WpPwAudioDsp enum pw_direction direction; gboolean convert; const struct pw_node_info *target; - const struct spa_audio_info_raw *format; /* All ports handled by the port added callback */ GHashTable *handled_ports; @@ -420,9 +418,13 @@ on_audio_dsp_proxy_created(GObject *initable, GAsyncResult *res, pw_node_proxy_enum_params (pw_proxy, 0, SPA_PARAM_Props, 0, -1, NULL); if (!self->convert) { - /* Get the port format */ - g_return_if_fail (self->format); - format = *self->format; + /* Use the default format */ + format.format = SPA_AUDIO_FORMAT_F32P; + format.flags = 1; + format.rate = 48000; + format.channels = 2; + format.position[0] = SPA_AUDIO_CHANNEL_FL; + format.position[1] = SPA_AUDIO_CHANNEL_FR; /* Emit the ports */ spa_pod_builder_init(&pod_builder, buf, sizeof(buf)); @@ -496,9 +498,6 @@ wp_pw_audio_dsp_set_property (GObject * object, guint property_id, case PROP_TARGET: self->target = g_value_get_pointer(value); break; - case PROP_FORMAT: - self->format = g_value_get_pointer(value); - break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; @@ -530,9 +529,6 @@ wp_pw_audio_dsp_get_property (GObject * object, guint property_id, case PROP_TARGET: g_value_set_pointer (value, (gpointer)self->target); break; - case PROP_FORMAT: - g_value_set_pointer (value, (gpointer)self->format); - break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; @@ -651,17 +647,12 @@ wp_pw_audio_dsp_class_init (WpPwAudioDspClass * klass) g_param_spec_pointer ("target", "target", "The target node info of the audio DSP", G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS)); - g_object_class_install_property (object_class, PROP_FORMAT, - g_param_spec_pointer ("format", "format", - "The format of the audio DSP ports", - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS)); } void wp_pw_audio_dsp_new (WpEndpoint *endpoint, guint id, const char *name, enum pw_direction direction, gboolean convert, - const struct pw_node_info *target, const struct spa_audio_info_raw *format, - GAsyncReadyCallback callback, + const struct pw_node_info *target, GAsyncReadyCallback callback, gpointer user_data) { g_async_initable_new_async ( @@ -673,7 +664,6 @@ wp_pw_audio_dsp_new (WpEndpoint *endpoint, guint id, const char *name, "direction", direction, "convert", convert, "target", target, - "format", format, NULL); } diff --git a/modules/module-pw-audio-softdsp-endpoint/dsp.h b/modules/module-pw-audio-softdsp-endpoint/dsp.h index 5d7c6f44..f6bb7550 100644 --- a/modules/module-pw-audio-softdsp-endpoint/dsp.h +++ b/modules/module-pw-audio-softdsp-endpoint/dsp.h @@ -20,8 +20,8 @@ void wp_pw_audio_dsp_id_decode (guint id, guint *stream_id, guint *control_id); void wp_pw_audio_dsp_new (WpEndpoint *endpoint, guint id, const char *name, enum pw_direction direction, gboolean convert, - const struct pw_node_info *target, const struct spa_audio_info_raw *format, - GAsyncReadyCallback callback, gpointer user_data); + const struct pw_node_info *target, GAsyncReadyCallback callback, + gpointer user_data); WpPwAudioDsp * wp_pw_audio_dsp_new_finish (GObject *initable, GAsyncResult *res, GError **error);