gstd-1.x icon indicating copy to clipboard operation
gstd-1.x copied to clipboard

Client stuck when using multiple bus_wait asyncs

Open emmadrigal opened this issue 3 years ago • 0 comments

The error can be reproduced by running the following code

#include <stdio.h>

#include "gstd/libgstc.h"

static GstcStatus callback(GstClient *_client, const char *pipeline_name,
                           const char *message_name, const long long timeout,
                           char *message, void *user_data) {
  /* Unlock the mutex */
  return GSTC_OK;
}

int main() {
  static GstClient *client;
  int ret;

  ret = gstc_client_new("127.0.0.1", 5000, -1, 0, &client);
  if (GSTC_OK != ret) {
    fprintf(stderr, "There was a problem creating a GstClient: %d\n", ret);
    goto out;
  }

  ret = gstc_pipeline_create(client, "pipe", "videotestsrc ! fakesink");
  if (GSTC_OK == ret) {
    printf("Pipeline created successfully!\n");
  } else {
    fprintf(stderr, "Error creating pipeline: %d\n", ret);
    goto pipeline_delete;
  }

  ret =
      gstc_pipeline_bus_wait_async(client, "pipe", "error", -1, callback, NULL);
  if (GSTC_OK == ret) {
    printf("Start first bus wait async!\n");
  } else {
    fprintf(stderr, "Error starting the first bus wait: %d\n", ret);
    goto close_pipeline;
  }

  ret =
      gstc_pipeline_bus_wait_async(client, "pipe", "error", -1, callback, NULL);
  if (GSTC_OK == ret) {
    printf("Start second bus wait async!\n");
  } else {
    fprintf(stderr, "Error starting the second bus wait: %d\n", ret);
    goto close_pipeline;
  }

  ret = gstc_pipeline_play(client, "pipe");
  if (GSTC_OK == ret) {
    printf("Played pipeline!\n");
  } else {
    fprintf(stderr, "Error playing pipeline: %d\n", ret);
    goto close_pipeline;
  }

  printf("This preposition is never called");

close_pipeline:
  ret = gstc_pipeline_stop(client, "pipe");
  if (GSTC_OK == ret) {
    printf("Pipeline set to null!\n");
  } else {
    fprintf(stderr, "Unable to stop pipeline: %d\n", ret);
    goto free_client;
  }

pipeline_delete:
  ret = gstc_pipeline_delete(client, "pipe");
  if (GSTC_OK == ret) {
    printf("Pipeline deleted!\n");
  } else {
    fprintf(stderr, "Unable to delete pipeline: %d\n", ret);
    goto free_client;
  }

free_client:
  gstc_client_free(client);
out:
  return 0;
}

emmadrigal avatar Mar 31 '21 17:03 emmadrigal