[gst-devel] gstreamer, JNI and swing

Robert Scott robert.b.scott at sbcglobal.net
Tue Mar 14 23:33:01 CET 2006


Hello,

I recently started working with gstreamer0.10, and I ran into a  
pretty serious hurdle up front.  To give you some background on what  
I am doing, I am writing a car computer (yeah, I know not that  
original) in Java.  I am a fairly proficient C programmer, and I am  
very comfortable using JNI to create a binding between java and C.  I  
have most of the user interface for the music player written in a  
combination of Swing and XUI, and recently found gstreamer which  
seems like the perfect library to playback music files.

I read the development manual and wrote a simple program that played  
a file, calling in from java, but after realizing that  
g_run_main_loop is blocking, i decided to put that call into another  
thread and then run the rest of the program in other threads, and  
here is where the problems began.  For some reason, the program seg  
faults at a random point relatively soon after starting the GUI,  
furthermore if I don't start the GUI the program doesn't segfault.   
If I don't initialize gstreamer, but I do start the GUI, the program  
doesn't segfault.

To investigate, I tried stripping the program all the way down to the  
core, removing all calls to the gstreamer library except for the call  
to gst_init( NULL, NULL );.  And even then, the program segfaults.  I  
am running with the latest JDK (1.5.0-06), on ubuntu dapper-drake.

the packages are:
ii  libgstreamer-plugins-base0.1 0.10.4-1ubuntu2               
GStreamer libraries from the "base" set
ii  libgstreamer0.10-0           0.10.4-1ubuntu1              Core  
GStreamer libraries and elements
ii  libgstreamer0.10-0-dbg       0.10.4-1ubuntu1              Core  
GStreamer libraries and elements
ii  libgstreamer0.10-dev         0.10.4-1ubuntu1               
GStreamer core development files
ii  gstreamer0.10-alsa           0.10.4-1ubuntu2               
GStreamer plugin for ALSA
ii  gstreamer0.10-plugins-bad    0.10.1-0ubuntu1               
GStreamer plugins from the "bad" set
ii  gstreamer0.10-plugins-base   0.10.4-1ubuntu2               
GStreamer plugins from the "base" set
ii  gstreamer0.10-plugins-good   0.10.2-2ubuntu2               
GStreamer plugins from the "good" set
ii  gstreamer0.10-plugins-ugly   0.10.2-0ubuntu2               
GStreamer plugins from the "ugly" set

This is pretty much the extent of the code:
static int _media_init( _media_t* media, gint argc, gchar* argv[] )
{
     int _critical_section()
     {
         if ( media->is_initialized == _INITIALIZED ) {
             return cadvium_log_msg( ERR_CRITICAL, "Multiple media  
initializations." );
         }

         /* I believe this can only occur once */
         gst_init( NULL, NULL );

         /* Test to see if the media loop has to run in the same  
thread */
         media->loop = NULL;

         if (( media->play = gst_element_factory_make( "playbin",  
"play" )) == NULL ) {
             return cadvium_log_msg( ERR_CRITICAL,  
"gst_element_factory_make" );
         }

         // gst_bus_add_watch( gst_pipeline_get_bus( GST_PIPELINE 
( media->play )), _bus_callback, media );

         /* Set the callback to the empty callback */
         media->callback = _empty_callback;

         media->is_initialized = _INITIALIZED;

         media->key = _CADVIUM_KEY;

         cadvium_log_msg( 0, "gstreamer media library initialized  
successfully" );
         return 0;
     }

     int ret;

     if ( pthread_mutex_init( &media->mutex, NULL ) < 0 ) return  
cadvium_log_perr( "pthread_mutex_init" );

     if ( pthread_mutex_lock( &media->mutex ) < 0 ) return  
cadvium_log_perr( "pthread_mutex_lock" );

     ret = _critical_section();

     pthread_mutex_unlock( &media->mutex );

     return ret;
}



the cores are pretty much useless, i think memory is being corrupted  
because it doesn't show any symbols in the stack trace.

any help would be immensly appreciated.  gstreamer seems to have all  
of the features that i need, and all other libraries don't really  
stack up at all.

thanks,
--robert




More information about the gstreamer-devel mailing list