After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 512382 - [playbin] race condition when pausing/playing multiple instances concurrently
[playbin] race condition when pausing/playing multiple instances concurrently
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-base
0.10.16
Other All
: Normal normal
: 0.10.20
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2008-01-27 15:03 UTC by Marcus Brinkmann
Modified: 2008-06-04 10:45 UTC
See Also:
GNOME target: ---
GNOME version: 2.19/2.20


Attachments
output of gst-feedback (69.46 KB, text/plain)
2008-01-27 15:07 UTC, Marcus Brinkmann
Details

Description Marcus Brinkmann 2008-01-27 15:03:48 UTC
Please describe the problem:
When I create multiple playbin elements in the paused or ready state quickly after each other, things get pretty messed up.  Most of the time, only one of the files actually can be heard (the other seems to "play" silently), but once in a while I get random assertion failues, crashes, etc.

If there is a one second pause between the individual element's creation and setup, all files can be heard playing.

Steps to reproduce:
Run the following example program, for example with two file:///file1.ogg and file:///file2.ogg.
#include <gst/gst.h>
GMainLoop *loop;
static gboolean
my_bus_callback (GstBus *bus, GstMessage *message, gpointer data)
{
  switch (GST_MESSAGE_TYPE (message))
    {
    case GST_MESSAGE_ERROR:
      {
	GError *err;
	gchar *debug;
	
	gst_message_parse_error (message, &err, &debug);
	g_print ("Error: %s\n", err->message);
	g_error_free (err);
	g_free (debug);
	
	g_main_quit (loop);
	break;
      }

    case GST_MESSAGE_EOS:
      /* end-of-stream */
      g_main_quit (loop);
      break;

    default:
      /* unhandled message */
      break;
  }

  /* We want to be notified again the next time there is a message on
     the bus, so returning TRUE (FALSE means we want to stop watching
     for messages on the bus and our callback should not be called
     again).  */
  return TRUE;
}

int
main (int argc, char *argv[])
{
  gst_init (&argc, &argv);

  loop = g_main_loop_new (NULL, FALSE);

  argc--;
  argv++;
  while (argc-- > 0)
    {
      GstElement *play;
      GstBus *bus;
	  
      play = gst_element_factory_make ("playbin", "play");
      g_object_set (G_OBJECT (play), "uri", argv[0], NULL);
      argv++;

      bus = gst_pipeline_get_bus (GST_PIPELINE (play));
      gst_bus_add_watch (bus, my_bus_callback, loop);
      gst_object_unref (bus);

      gst_element_set_state (play, GST_STATE_PLAYING);
      // Sleep works around it.
      // sleep (1);
    }

  g_main_loop_run (loop);

  return 0;
}


Actual results:
Most of the time, only one file is heard from the speaker.  Sometimes, various random crashes and assertion failures occur, for example:

* main3: pcm.c:725: snd_pcm_nonblock: Assertion `pcm' failed.

* (main3:16472): GLib-GObject-WARNING **: invalid (NULL) pointer instance

(main3:16472): GLib-GObject-CRITICAL **: g_signal_connect_data: assertion `G_TYPE_CHECK_INSTANCE (instance)' failed

(main3:16472): GLib-GObject-CRITICAL **: g_object_set_data: assertion `G_IS_OBJECT (object)' failed

(main3:16472): GStreamer-CRITICAL **: gst_pad_link_prepare: assertion `GST_IS_PAD (sinkpad)' failed

(main3:16472): GStreamer-CRITICAL **: gst_object_unref: assertion `object != NULL' failed
Error: Internal data stream error.

* (main3:17385): GLib-GObject-WARNING **: IA__g_object_set_valist: object class `GstStreamInfo' has no property named `mute'


Expected results:
What should happen is that both files start playing and are heard.

Does this happen every time?
Yes.

Other information:
sleep(1) after changing the state to PLAYING works around it.
Comment 1 Marcus Brinkmann 2008-01-27 15:07:14 UTC
Created attachment 103819 [details]
output of gst-feedback

My system is a single-processor Intel P4 2.8 GHz.  Note that I use the linux-rt kernel.
Comment 2 Tim-Philipp Müller 2008-04-06 20:23:15 UTC
I get different errors/assertions with CVS of things, mostly related to GLib's type system being slightly unsafe with regard to class refs. I've committed these:


 2008-04-06  Tim-Philipp Müller  <tim at centricular dot net>

        * gst-libs/gst/audio/gstbaseaudiosink.c:
          (gst_base_audio_sink_class_init):
        * gst-libs/gst/audio/gstbaseaudiosrc.c:
          (gst_base_audio_src_class_init):
        * gst/playback/gstplayback.c: (plugin_init):
        * gst/volume/gstvolume.c: (plugin_init):
          Work around missing bits of thread-safety on older GLibs some
          more to avoid assertions when starting up multiple playbin
          objects concurrently (see #512382).

and

 2008-04-06  Tim-Philipp Müller  <tim at centricular dot net>

        * ext/jack/gstjackaudiosink.c: (gst_jack_audio_sink_class_init):
          Work around missing bits of thread-safety on older GLibs some
          more to avoid assertions when starting up multiple playbin
          objects concurrently (see #512382).


to -base and -bad respectively. This fixes all issues I've been seeing so far. Now it either plays, or errors out with 'Error: Could not open resource for writing.' or crashes gdb itself in mysterious ways (no idea what that is about).

Any chance you could try with CVS? If yes, and you still have problems, backtraces from G_DEBUG=fatal_warnings would be great.
Comment 3 Tim-Philipp Müller 2008-06-04 10:45:48 UTC
Well, I declare this sort-of-fixed. Please file new bugs for any issues that you still run into with the latest CVS of all modules.