[Spice-devel] [PATCH 2/2] audio: Avoid bad pipelines from gst_parse_launch

Christophe Fergeau cfergeau at redhat.com
Tue Nov 25 02:14:00 PST 2014


On Mon, Nov 24, 2014 at 06:57:03PM +0100, Victor Toso wrote:
> gst_parse_launch may return not NULL even when error is set.
> This can lead to data loss when playing or recording audio.
> ---
>  gtk/spice-gstaudio.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/gtk/spice-gstaudio.c b/gtk/spice-gstaudio.c
> index df2fc8e..2b7f683 100644
> --- a/gtk/spice-gstaudio.c
> +++ b/gtk/spice-gstaudio.c
> @@ -245,7 +245,7 @@ static void record_start(SpiceRecordChannel *channel, gint format, gint channels
>                              "appsink caps=\"%s\" name=appsink", audio_caps);
>  
>          p->record.pipe = gst_parse_launch(pipeline, &error);
> -        if (p->record.pipe == NULL) {
> +        if (error != NULL || p->record.pipe == NULL) {
>              g_warning("Failed to create pipeline: %s", error->message);
>              goto lerr;
>          }
> @@ -345,7 +345,7 @@ static void playback_start(SpicePlaybackChannel *channel, gint format, gint chan
>                                         "audioconvert ! audioresample ! autoaudiosink name=\"audiosink\"", audio_caps);
>          SPICE_DEBUG("audio pipeline: %s", pipeline);
>          p->playback.pipe = gst_parse_launch(pipeline, &error);
> -        if (p->playback.pipe == NULL) {
> +        if (error != NULL || p->playback.pipe == NULL) {
>              g_warning("Failed to create pipeline: %s", error->message);
>              goto lerr;
>          }

You need to clear p->record.pipe if it's not NULL when error != NULL as
both playback_start and record_start do:

    if (p->playback.pipe)
            gst_element_set_state(p->playback.pipe, GST_STATE_PLAYING);

after the lerr: label.

Christophe

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/spice-devel/attachments/20141125/67c2c3d5/attachment.sig>


More information about the Spice-devel mailing list