All pastes #767676 Raw Edit

Sonicadvance1

public c v1 · immutable
·published 2007-11-09 22:59 UTC
rendered paste body
#include <gst/gst.h>  GMainLoop *loop;  GstBus *bus;  GstElement *play = NULL;static gbooleanmy_bus_callback (GstBus     *bus,	  GstMessage *msg,	  gpointer    data){  g_print ("Have message of type %d from %s\n",    GST_MESSAGE_TYPE (msg), gst_object_get_name (GST_MESSAGE_SRC (msg)));  if (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_ERROR ||      GST_MESSAGE_TYPE (msg) == GST_MESSAGE_EOS)    g_main_loop_quit (loop);  return TRUE;}int init_audio(int argc, char *argv[]){	const gchar *nano_str;	guint major, minor, micro, nano;	gst_init (&argc, &argv);	gst_version (&major, &minor, &micro, &nano);	if (nano == 1)	nano_str = "(CVS)";	else if (nano == 2)	nano_str = "(Prerelease)";	else	nano_str = "";	printf ("This program is linked against GStreamer %d.%d.%d %s\n",		  major, minor, micro, nano_str);	loop = g_main_loop_new (NULL, FALSE);	return 0;}int playsong(gchar *sn){					printf("Song: %s\n",sn);					char* str2 = malloc(strlen(sn) + 16);					sprintf(str2,"file://%s", sn);					/* set up */					play = gst_element_factory_make ("playbin", "play");					g_object_set (G_OBJECT (play), "uri", str2, NULL);					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);					/* now run */					g_main_loop_run (loop);					/* also clean up */					gst_element_set_state (play, GST_STATE_NULL);					gst_object_unref (GST_OBJECT (play));	return 0;}int main (int argc, char **argv){  init_audio (argc, argv);  playsong (argv[1]);}