Ich brauche einen echten loop einer wave Datei für ein plugin ohne mini Pause, also ein durchgehender Ton.
Geht so etwas überhaupt mit gstreamer?
Wäre echt super wenn wer eine Idee hätte.
Ich hänge mal das src file an und eine wave Datei. (nicht wundern, im src ist noch eine 7.1 Karte gesetzt)
C
/*
gcc -o out test-loop.c `pkg-config --cflags --libs gstreamer-1.0`
./out file://`pwd`/C.wav
*/
#include <assert.h>
#include <gst/gst.h>
#include <glib.h>
#include <string.h>
struct NextStreamData {
GstElement *pipeline;
int count;
int uri_count;
char **uris;
};
static void prepare_next_stream(GstElement *obj, gpointer userdata) {
struct NextStreamData *data = (struct NextStreamData*) userdata;
const char* next_uri = data->uris[MIN(data->count+1, data->uri_count)];
g_print("about-to-finish %4d; setting next to %s\n",
data->count, next_uri);
g_object_set(G_OBJECT(data->pipeline), "uri", next_uri, NULL);
data->count++;
}
int main (int argc, char *argv[]) {
GMainLoop *loop;
GstElement *pipeline;
/* Initialisation */
gst_init (&argc, &argv);
loop = g_main_loop_new (NULL, FALSE);
/* Check input arguments */
if (argc < 2) {
g_printerr ("Usage: %s <list of space-delimited filenames or URLs>\n",
argv[0]);
return -1;
}
/* Create playbin. Different names in different versions */
#if (GST_VERSION_MAJOR < 1)
pipeline = gst_element_factory_make("playbin2", "play");
g_print ("playbin2\n");
#else
pipeline = gst_element_factory_make("playbin", "play");
g_print ("playbin\n");
#endif
//gchar *device = "hw:CARD=Device,DEV=0";
gchar *device = "surround71:CARD=Device,DEV=0";
GstElement *sink;
sink = gst_element_factory_make ("alsasink", NULL);
//g_object_set (device, "device", "surround71:CARD=Device,DEV=0", NULL);
g_object_set (sink, "device", device, NULL);
g_object_set (pipeline, "audio-sink", sink, NULL);
/* Register about-to-finish callback to re-set the URI */
struct NextStreamData replay_data;
replay_data.pipeline = pipeline;
replay_data.count = 0;
replay_data.uris = &(argv[1]);
replay_data.uri_count = argc-2;
g_signal_connect(pipeline, "about-to-finish",
G_CALLBACK(prepare_next_stream), &replay_data);
/* Set initial URI */
g_object_set (G_OBJECT (pipeline), "uri", argv[1], NULL);
g_print ("Now playing: %s\n", argv[1]);
gst_element_set_state (pipeline, GST_STATE_PLAYING);
/* Iterate */
g_print ("Running...\n");
g_main_loop_run (loop);
/* since we loop endlessly, the follwing is never reached */
/* Out of the main loop, clean up nicely */
g_print ("Returned, stopping playback\n");
gst_element_set_state (pipeline, GST_STATE_NULL);
g_print ("Deleting pipeline\n");
gst_object_unref (device);
gst_object_unref (sink);
gst_object_unref (GST_OBJECT (pipeline));
g_main_loop_unref (loop);
return 0;
}
Alles anzeigen
Danke und LG