All pastes #767661 Raw Edit

Sonicadvance1

public c v1 · immutable
·published 2007-11-09 22:48 UTC
rendered paste body
#include <gst/gst.h>#include "info.h"#include "misc.h"#include "misc_track.h"#include "mp3file.h"#include "prefs.h"#include "tools.h"  GMainLoop *loop;  GstBus *bus;  GstElement *play = NULL;static gbooleanmy_bus_callback (GstBus     *bus,	  GstMessage *msg,	  gpointer    data){  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(GList *songs){			GPtrArray *args;			gchar *str;			/* Create the command line */			args = g_ptr_array_sized_new (g_list_length (songs) + 10);			GList *l;			int a = 0;			for(l = songs; l; l = l->next)			{				Track *tr = l->data;				g_return_if_fail (tr);				str = get_file_name_from_source(tr, SOURCE_PREFER_LOCAL);				if(str)				{					g_ptr_array_add (args, str);					printf("yes, %s\n",str);					a++;				}			}			int b = 0;			for(b = 0; b < a;b++)				{					char *sn = g_ptr_array_index(args,b);					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;}