[gstreamer-bugs] [Bug 438232] New: Alsasrc / alsasink's system clock threads were not been cleaned up

GStreamer (bugzilla.gnome.org) bugzilla-daemon at bugzilla.gnome.org
Sun May 13 20:18:33 PDT 2007


If you have any questions why you received this email, please see the text at
the end of this email. Replies to this email are NOT read, please see the text
at the end of this email. You can add comments to this bug at:
  http://bugzilla.gnome.org/show_bug.cgi?id=438232

  GStreamer | don't know | Ver: 0.10.11
           Summary: Alsasrc / alsasink's system clock threads were not been
                    cleaned up
           Product: GStreamer
           Version: 0.10.11
          Platform: Other
        OS/Version: Linux
            Status: UNCONFIRMED
          Severity: normal
          Priority: Normal
         Component: don't know
        AssignedTo: gstreamer-bugs at lists.sourceforge.net
        ReportedBy: james.cm.tsai at gmail.com
         QAContact: gstreamer-bugs at lists.sourceforge.net
     GNOME version: Unspecified
   GNOME milestone: Unspecified


There is a sample code which creating a simple gst pipeline which contains only
one alsasrc and one alsasink element and playing it. After 2 secs, set this
pipeline to null and unreference it. Sample code is as following :

#include <stdio.h>
#include <gst/gst.h>

typedef struct _loop_context
{
  GMainLoop *loop;
  guint steps;
} loop_context;

GstElement *pipeline = NULL;
#define TOTAL_STEPS 10

void
create_pipeline (void)
{
  GstElement *src = NULL, *sink = NULL;

  if (!pipeline)
  {
    g_print ("\n====== [CREATE AND RUN PIPELINE] ======\n");

    pipeline = gst_pipeline_new ("test_pipe");

    src = gst_element_factory_make ("alsasrc", "asrc");
    sink = gst_element_factory_make ("alsasink", "asink");

    gst_bin_add_many (GST_BIN(pipeline), src, sink, NULL);

    gst_element_link (src, sink);

    gst_element_set_state (pipeline, GST_STATE_PLAYING);
  }
}

void
destroy_pipeline (void)
{
  if(pipeline)
  {
    gst_element_set_state (pipeline, GST_STATE_NULL);
    gst_object_unref (GST_OBJECT (pipeline));
    pipeline = NULL;
    g_print ("====== [CLEANUP PIPELINE] ======\n");
  }
}

gboolean
one_more_step (gpointer data)
{
  loop_context *context = (loop_context *)data;

  if (context->steps >= TOTAL_STEPS)
  {
    destroy_pipeline ();
    g_main_loop_quit (context->loop);
    return FALSE;
  }
  else if ((context->steps)%2 == 0)
    create_pipeline ();
  else
    destroy_pipeline ();

  context->steps += 1;
  return TRUE;
}

int
main ()
{
  gst_init(NULL, NULL);

  loop_context *context = (loop_context *)g_malloc0 (sizeof (loop_context));
  g_return_val_if_fail(context, 0);

  context->loop = g_main_loop_new (NULL, 0);
  context->steps = 0;
  g_timeout_add (2000, one_more_step, context);
  g_main_loop_run (context->loop);
  g_main_loop_unref(context->loop);

  g_free (context);

  getchar ();

  return 1;
}

========================================

I use gdb to run this sample code. Each time pipeline been created and
destroyed, there is one thread not been cleaned up. So, as sample code has 5
rounds of creating and destroying, there will be 5 more threads after all
destroying are done. Following is the gdb log :

========================================

[root at localhost testing]# gdb ./pipeline-test
GNU gdb Red Hat Linux (6.5-15.fc6rh)
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-redhat-linux-gnu"...Using host libthread_db
library "/lib/i686/nosegneg/libthread_db.so.1".

(gdb) run
Starting program: /backup/testing/pipeline-test
[Thread debugging using libthread_db enabled]
[New Thread -1208617280 (LWP 3600)]

====== [CREATE AND RUN PIPELINE] ======
[New Thread -1210721392 (LWP 3604)]
[New Thread -1221211248 (LWP 3605)]
[New Thread -1231987824 (LWP 3606)]
[New Thread -1242477680 (LWP 3607)]
[New Thread -1252967536 (LWP 3608)]
[New Thread -1263457392 (LWP 3609)]
[Thread -1263457392 (LWP 3609) exited]
[Thread -1252967536 (LWP 3608) exited]
[Thread -1231987824 (LWP 3606) exited]
[Thread -1221211248 (LWP 3605) exited]
====== [CLEANUP PIPELINE] ======
[Thread -1242477680 (LWP 3607) exited]

====== [CREATE AND RUN PIPELINE] ======
[New Thread -1242477680 (LWP 3610)]
[New Thread -1221211248 (LWP 3611)]
[New Thread -1231987824 (LWP 3612)]
[New Thread -1252967536 (LWP 3613)]
[New Thread -1263457392 (LWP 3614)]
[New Thread -1273947248 (LWP 3615)]
[Thread -1273947248 (LWP 3615) exited]
[Thread -1263457392 (LWP 3614) exited]
[Thread -1231987824 (LWP 3612) exited]
[Thread -1221211248 (LWP 3611) exited]
====== [CLEANUP PIPELINE] ======
[Thread -1252967536 (LWP 3613) exited]

====== [CREATE AND RUN PIPELINE] ======
[New Thread -1252967536 (LWP 3616)]
[New Thread -1221211248 (LWP 3617)]
[New Thread -1231987824 (LWP 3618)]
[New Thread -1263457392 (LWP 3619)]
[New Thread -1273947248 (LWP 3620)]
[New Thread -1284437104 (LWP 3621)]
[Thread -1284437104 (LWP 3621) exited]
[Thread -1273947248 (LWP 3620) exited]
[Thread -1231987824 (LWP 3618) exited]
[Thread -1221211248 (LWP 3617) exited]
====== [CLEANUP PIPELINE] ======
[Thread -1263457392 (LWP 3619) exited]

====== [CREATE AND RUN PIPELINE] ======
[New Thread -1263457392 (LWP 3627)]
[New Thread -1221211248 (LWP 3628)]
[New Thread -1231987824 (LWP 3629)]
[New Thread -1273947248 (LWP 3630)]
[New Thread -1284437104 (LWP 3631)]
[New Thread -1294926960 (LWP 3632)]
[Thread -1294926960 (LWP 3632) exited]
[Thread -1284437104 (LWP 3631) exited]
[Thread -1231987824 (LWP 3629) exited]
[Thread -1221211248 (LWP 3628) exited]
====== [CLEANUP PIPELINE] ======
[Thread -1273947248 (LWP 3630) exited]

====== [CREATE AND RUN PIPELINE] ======
[New Thread -1273947248 (LWP 3695)]
[New Thread -1221211248 (LWP 3696)]
[New Thread -1231987824 (LWP 3697)]
[New Thread -1284437104 (LWP 3698)]
[New Thread -1294926960 (LWP 3699)]
[New Thread -1305416816 (LWP 3700)]
[Thread -1305416816 (LWP 3700) exited]
[Thread -1294926960 (LWP 3699) exited]
[Thread -1231987824 (LWP 3697) exited]
[Thread -1221211248 (LWP 3696) exited]
====== [CLEANUP PIPELINE] ======
[Thread -1284437104 (LWP 3698) exited]

Program received signal SIGINT, Interrupt.
[Switching to Thread -1208617280 (LWP 3600)]
0x00d31402 in __kernel_vsyscall ()
(gdb) info threads
  26 Thread -1273947248 (LWP 3695)  0x00d31402 in __kernel_vsyscall ()
  20 Thread -1263457392 (LWP 3627)  0x00d31402 in __kernel_vsyscall ()
  14 Thread -1252967536 (LWP 3616)  0x00d31402 in __kernel_vsyscall ()
  8 Thread -1242477680 (LWP 3610)  0x00d31402 in __kernel_vsyscall ()
  2 Thread -1210721392 (LWP 3604)  0x00d31402 in __kernel_vsyscall ()
* 1 Thread -1208617280 (LWP 3600)  0x00d31402 in __kernel_vsyscall ()
(gdb) thread 2
[Switching to thread 2 (Thread -1210721392 (LWP 3604))]#0  0x00d31402 in
__kernel_vsyscall ()
(gdb) bt
#0  0x00d31402 in __kernel_vsyscall ()
#1  0x4886f206 in pthread_cond_wait@@GLIBC_2.3.2 () from
/lib/i686/nosegneg/libpthread.so.0
#2  0x002d36a8 in gst_system_clock_async_thread (clock=0x81e1170) at
gstsystemclock.c:258
#3  0x48a0129f in g_thread_create_full () from /lib/libglib-2.0.so.0
#4  0x4886b402 in start_thread () from /lib/i686/nosegneg/libpthread.so.0
#5  0x4869d4ce in clone () from /lib/i686/nosegneg/libc.so.6
(gdb) thread 8
[Switching to thread 8 (Thread -1242477680 (LWP 3610))]#0  0x00d31402 in
__kernel_vsyscall ()
(gdb) bt
#0  0x00d31402 in __kernel_vsyscall ()
#1  0x4886f206 in pthread_cond_wait@@GLIBC_2.3.2 () from
/lib/i686/nosegneg/libpthread.so.0
#2  0x002d36a8 in gst_system_clock_async_thread (clock=0x81e15f8) at
gstsystemclock.c:258
#3  0x48a0129f in g_thread_create_full () from /lib/libglib-2.0.so.0
#4  0x4886b402 in start_thread () from /lib/i686/nosegneg/libpthread.so.0
#5  0x4869d4ce in clone () from /lib/i686/nosegneg/libc.so.6
(gdb)


-- 
See http://bugzilla.gnome.org/page.cgi?id=email.html for more info about why you received
this email, why you can't respond via email, how to stop receiving
emails (or reduce the number you receive), and how to contact someone
if you are having problems with the system.

You can add comments to this bug at http://bugzilla.gnome.org/show_bug.cgi?id=438232.




More information about the Gstreamer-bugs mailing list