configure.ac: Put DEFAULT_AUDIOSINK in config.h and use whereever possible. (Fixes #165997)
Original commit message from CVS:
* configure.ac: Put DEFAULT_AUDIOSINK in config.h and use
whereever possible. (Fixes #165997)
* examples/capsfilter/capsfilter1.c: (main):
* examples/dynparams/filter.c: (create_ui):
* examples/seeking/cdparanoia.c: (get_track_info), (main):
* examples/seeking/chained.c: (main):
* examples/seeking/seek.c: (make_mod_pipeline), (make_dv_pipeline),
(make_wav_pipeline), (make_flac_pipeline), (make_sid_pipeline),
(make_vorbis_pipeline), (make_mp3_pipeline), (make_avi_pipeline),
(make_mpeg_pipeline), (make_mpegnt_pipeline):
* examples/seeking/spider_seek.c: (make_spider_pipeline):
* examples/switch/switcher.c: (main):
* ext/dv/demo-play.c: (main):
* ext/faad/gstfaad.c: (gst_faad_change_state):
* ext/mad/gstmad.c: (gst_mad_chain):
* ext/smoothwave/demo-osssrc.c: (main):
* gst-libs/gst/gconf/gconf.c: (gst_gconf_set_string),
(gst_gconf_render_bin_from_description),
(gst_gconf_get_default_audio_sink),
(gst_gconf_get_default_video_sink),
(gst_gconf_get_default_audio_src),
(gst_gconf_get_default_video_src),
(gst_gconf_get_default_visualization_element):
* gst/level/demo.c: (main):
* gst/level/plot.c: (main):
* gst/playback/gstplaybin.c: (gen_video_element),
(gen_audio_element):
* gst/playback/test.c: (gen_video_element), (gen_audio_element):
* gst/playondemand/demo-mp3.c: (setup_pipeline):
* gst/sine/demo-dparams.c: (main):
* gst/spectrum/demo-osssrc.c: (main):
* gst/speed/demo-mp3.c: (main):
* gst/volume/demo.c: (main):
* testsuite/embed/embed.c: (main):
2005-02-02 08:14:01 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
2002-08-11 11:29:39 +00:00
|
|
|
#include <stdlib.h>
|
2002-03-30 17:06:26 +00:00
|
|
|
#include <glib.h>
|
2002-01-04 21:39:32 +00:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
#include <gst/gst.h>
|
|
|
|
|
2003-06-16 22:20:52 +00:00
|
|
|
#define NUM_BEATS 12
|
2003-11-16 21:48:55 +00:00
|
|
|
#define TICK_RATE(x) (x * 1e-6)
|
2003-01-17 14:04:39 +00:00
|
|
|
|
|
|
|
GtkWidget *window, *vbox, *beat_box, *button_box;
|
|
|
|
GtkWidget *play_button, *clear_button, *reset_button, *quit_button;
|
|
|
|
GtkWidget **beat_button;
|
|
|
|
GtkWidget *speed_scale;
|
|
|
|
GtkObject *speed_adj;
|
2003-11-16 21:48:55 +00:00
|
|
|
GstElement *src, *dec, *pod, *sink, *pipeline;
|
2002-10-17 20:05:58 +00:00
|
|
|
GstClock *element_clock;
|
2003-06-16 22:20:52 +00:00
|
|
|
guint32 *beats;
|
2003-01-17 14:04:39 +00:00
|
|
|
|
|
|
|
void
|
2004-03-14 22:34:33 +00:00
|
|
|
played (GstElement * pod, gpointer data)
|
2003-01-17 14:04:39 +00:00
|
|
|
{
|
2003-06-16 22:20:52 +00:00
|
|
|
gint i;
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
g_print ("Played beat at %02u, beats are ",
|
|
|
|
(guint) (gst_clock_get_time (element_clock) / GST_SECOND *
|
2004-03-15 19:32:27 +00:00
|
|
|
(GTK_ADJUSTMENT (speed_adj))->value) % NUM_BEATS);
|
2003-06-16 22:20:52 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
for (i = 0; i <= NUM_BEATS / 32; i++)
|
|
|
|
g_print ("%08x ", beats[i]);
|
2003-06-16 22:20:52 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
g_print ("\n");
|
2003-01-17 14:04:39 +00:00
|
|
|
}
|
2002-10-17 20:05:58 +00:00
|
|
|
|
|
|
|
void
|
2004-03-14 22:34:33 +00:00
|
|
|
play (GtkButton * button, gpointer data)
|
2002-01-04 21:39:32 +00:00
|
|
|
{
|
2004-03-14 22:34:33 +00:00
|
|
|
g_signal_emit_by_name (G_OBJECT (pod), "play", NULL, NULL);
|
2002-01-04 21:39:32 +00:00
|
|
|
}
|
2002-10-17 20:05:58 +00:00
|
|
|
|
2003-01-17 14:04:39 +00:00
|
|
|
void
|
2004-03-14 22:34:33 +00:00
|
|
|
clear (GtkButton * button, gpointer data)
|
2003-01-17 14:04:39 +00:00
|
|
|
{
|
2004-03-14 22:34:33 +00:00
|
|
|
g_signal_emit_by_name (G_OBJECT (pod), "clear", NULL, NULL);
|
2003-01-17 14:04:39 +00:00
|
|
|
}
|
|
|
|
|
2002-10-17 20:05:58 +00:00
|
|
|
void
|
2004-03-14 22:34:33 +00:00
|
|
|
reset (GtkButton * button, gpointer data)
|
2002-01-04 21:39:32 +00:00
|
|
|
{
|
2003-01-17 14:04:39 +00:00
|
|
|
guint i;
|
2004-03-14 22:34:33 +00:00
|
|
|
|
|
|
|
g_signal_emit_by_name (G_OBJECT (pod), "reset", NULL, NULL);
|
2003-01-17 14:04:39 +00:00
|
|
|
for (i = 0; i < NUM_BEATS; i++)
|
2004-03-14 22:34:33 +00:00
|
|
|
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (beat_button[i]), 0);
|
2002-01-04 21:39:32 +00:00
|
|
|
}
|
2002-10-17 20:05:58 +00:00
|
|
|
|
|
|
|
void
|
2004-03-14 22:34:33 +00:00
|
|
|
beat (GtkToggleButton * button, gpointer data)
|
2002-10-17 20:05:58 +00:00
|
|
|
{
|
2004-03-14 22:34:33 +00:00
|
|
|
guint b = GPOINTER_TO_UINT (data);
|
2003-06-16 22:20:52 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)))
|
2003-06-16 22:20:52 +00:00
|
|
|
beats[b / 32] |= 1 << (b % 32);
|
2003-01-17 14:04:39 +00:00
|
|
|
else
|
2004-03-14 22:34:33 +00:00
|
|
|
beats[b / 32] &= ~(1 << (b % 32));
|
2002-10-17 20:05:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-03-14 22:34:33 +00:00
|
|
|
speed (GtkAdjustment * adjustment, gpointer data)
|
2002-10-17 20:05:58 +00:00
|
|
|
{
|
2004-03-14 22:34:33 +00:00
|
|
|
/*g_signal_stop_emission_by_name(G_OBJECT(pod), "deep-notify"); */
|
|
|
|
g_object_set (G_OBJECT (pod), "tick-rate", TICK_RATE (adjustment->value),
|
|
|
|
NULL);
|
|
|
|
/*gst_clock_set_speed(element_clock, adjustment->value); */
|
2002-10-17 20:05:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2004-03-14 22:34:33 +00:00
|
|
|
setup_pipeline (gchar * filename)
|
2002-01-04 21:39:32 +00:00
|
|
|
{
|
2004-03-14 22:34:33 +00:00
|
|
|
src = gst_element_factory_make ("filesrc", "source");
|
|
|
|
dec = gst_element_factory_make ("vorbisfile", "decoder");
|
|
|
|
pod = gst_element_factory_make ("playondemand", "sequencer");
|
configure.ac: Put DEFAULT_AUDIOSINK in config.h and use whereever possible. (Fixes #165997)
Original commit message from CVS:
* configure.ac: Put DEFAULT_AUDIOSINK in config.h and use
whereever possible. (Fixes #165997)
* examples/capsfilter/capsfilter1.c: (main):
* examples/dynparams/filter.c: (create_ui):
* examples/seeking/cdparanoia.c: (get_track_info), (main):
* examples/seeking/chained.c: (main):
* examples/seeking/seek.c: (make_mod_pipeline), (make_dv_pipeline),
(make_wav_pipeline), (make_flac_pipeline), (make_sid_pipeline),
(make_vorbis_pipeline), (make_mp3_pipeline), (make_avi_pipeline),
(make_mpeg_pipeline), (make_mpegnt_pipeline):
* examples/seeking/spider_seek.c: (make_spider_pipeline):
* examples/switch/switcher.c: (main):
* ext/dv/demo-play.c: (main):
* ext/faad/gstfaad.c: (gst_faad_change_state):
* ext/mad/gstmad.c: (gst_mad_chain):
* ext/smoothwave/demo-osssrc.c: (main):
* gst-libs/gst/gconf/gconf.c: (gst_gconf_set_string),
(gst_gconf_render_bin_from_description),
(gst_gconf_get_default_audio_sink),
(gst_gconf_get_default_video_sink),
(gst_gconf_get_default_audio_src),
(gst_gconf_get_default_video_src),
(gst_gconf_get_default_visualization_element):
* gst/level/demo.c: (main):
* gst/level/plot.c: (main):
* gst/playback/gstplaybin.c: (gen_video_element),
(gen_audio_element):
* gst/playback/test.c: (gen_video_element), (gen_audio_element):
* gst/playondemand/demo-mp3.c: (setup_pipeline):
* gst/sine/demo-dparams.c: (main):
* gst/spectrum/demo-osssrc.c: (main):
* gst/speed/demo-mp3.c: (main):
* gst/volume/demo.c: (main):
* testsuite/embed/embed.c: (main):
2005-02-02 08:14:01 +00:00
|
|
|
sink = gst_element_factory_make (DEFAULT_AUDIOSINK, "sink");
|
2002-01-04 21:39:32 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
g_object_set (G_OBJECT (src), "location", filename, NULL);
|
|
|
|
g_object_set (G_OBJECT (sink), "period-count", 64, "period-size", 512, NULL);
|
|
|
|
g_object_set (G_OBJECT (pod), "total-ticks", NUM_BEATS,
|
|
|
|
"tick-rate", 1.0e-6, "max-plays", NUM_BEATS * 2, NULL);
|
2003-06-16 22:20:52 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
g_object_get (G_OBJECT (pod), "ticks", &beats, NULL);
|
2002-01-04 21:39:32 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
pipeline = gst_pipeline_new ("app");
|
2002-01-04 21:39:32 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
gst_bin_add_many (GST_BIN (pipeline), src, dec, pod, sink, NULL);
|
|
|
|
gst_element_link_many (src, dec, pod, sink, NULL);
|
2002-01-04 21:39:32 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
element_clock = gst_element_get_clock (GST_ELEMENT (sink));
|
|
|
|
gst_element_set_clock (GST_ELEMENT (pod), element_clock);
|
2002-10-17 20:05:58 +00:00
|
|
|
}
|
2002-01-04 21:39:32 +00:00
|
|
|
|
2002-10-17 20:05:58 +00:00
|
|
|
void
|
|
|
|
setup_gui (void)
|
|
|
|
{
|
2003-01-17 14:04:39 +00:00
|
|
|
guint i;
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
beat_button = g_new (GtkWidget *, NUM_BEATS);
|
2003-01-17 14:04:39 +00:00
|
|
|
|
2002-01-04 21:39:32 +00:00
|
|
|
/* initialize gui elements ... */
|
2004-03-14 22:34:33 +00:00
|
|
|
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
|
|
|
|
gtk_container_set_border_width (GTK_CONTAINER (window), 12);
|
2003-01-17 14:04:39 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
vbox = gtk_vbox_new (TRUE, 0);
|
|
|
|
gtk_box_set_spacing (GTK_BOX (vbox), 12);
|
2003-01-17 14:04:39 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
beat_box = gtk_hbox_new (TRUE, 0);
|
|
|
|
button_box = gtk_hbox_new (TRUE, 0);
|
2003-01-17 14:04:39 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
play_button = gtk_button_new_with_label ("Play");
|
|
|
|
clear_button = gtk_button_new_with_label ("Reset Sound");
|
|
|
|
reset_button = gtk_button_new_with_label ("Reset All");
|
|
|
|
quit_button = gtk_button_new_with_label ("Quit");
|
2003-01-17 14:04:39 +00:00
|
|
|
|
|
|
|
for (i = 0; i < NUM_BEATS; i++)
|
2004-03-14 22:34:33 +00:00
|
|
|
beat_button[i] =
|
2004-03-15 19:32:27 +00:00
|
|
|
gtk_toggle_button_new_with_label (g_strdup_printf ("%2d", i + 1));
|
2003-01-17 14:04:39 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
speed_adj = gtk_adjustment_new (1, 0.0, 10.0, 0.1, 1.0, 0.0);
|
|
|
|
speed_scale = gtk_hscale_new (GTK_ADJUSTMENT (speed_adj));
|
|
|
|
gtk_scale_set_digits (GTK_SCALE (speed_scale), 4);
|
|
|
|
gtk_range_set_update_policy (GTK_RANGE (speed_scale),
|
|
|
|
GTK_UPDATE_DISCONTINUOUS);
|
2002-01-04 21:39:32 +00:00
|
|
|
|
|
|
|
/* do the packing stuff ... */
|
2004-03-14 22:34:33 +00:00
|
|
|
gtk_window_set_default_size (GTK_WINDOW (window), 96, 96);
|
|
|
|
gtk_container_add (GTK_CONTAINER (window), vbox);
|
2003-01-17 14:04:39 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (button_box), play_button, TRUE, TRUE, 2);
|
|
|
|
gtk_box_pack_start (GTK_BOX (button_box), clear_button, TRUE, TRUE, 2);
|
|
|
|
gtk_box_pack_start (GTK_BOX (button_box), reset_button, TRUE, TRUE, 2);
|
|
|
|
gtk_box_pack_start (GTK_BOX (button_box), quit_button, TRUE, TRUE, 2);
|
2003-01-17 14:04:39 +00:00
|
|
|
|
|
|
|
for (i = 0; i < NUM_BEATS; i++)
|
2004-03-14 22:34:33 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (beat_box), beat_button[i], TRUE, TRUE, 2);
|
2003-01-17 14:04:39 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), button_box, TRUE, FALSE, 2);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), beat_box, TRUE, FALSE, 2);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), speed_scale, TRUE, FALSE, 2);
|
2002-01-04 21:39:32 +00:00
|
|
|
|
|
|
|
/* connect things ... */
|
2004-03-14 22:34:33 +00:00
|
|
|
g_signal_connect (G_OBJECT (play_button), "clicked", G_CALLBACK (play), NULL);
|
|
|
|
g_signal_connect (G_OBJECT (clear_button), "clicked", G_CALLBACK (clear),
|
|
|
|
NULL);
|
|
|
|
g_signal_connect (G_OBJECT (reset_button), "clicked", G_CALLBACK (reset),
|
|
|
|
NULL);
|
|
|
|
g_signal_connect (G_OBJECT (quit_button), "clicked", gtk_main_quit, NULL);
|
|
|
|
g_signal_connect (G_OBJECT (pod), "played", G_CALLBACK (played), NULL);
|
|
|
|
g_signal_connect (G_OBJECT (speed_adj), "value_changed", G_CALLBACK (speed),
|
|
|
|
NULL);
|
2003-01-17 14:04:39 +00:00
|
|
|
for (i = 0; i < NUM_BEATS; i++)
|
2004-03-14 22:34:33 +00:00
|
|
|
g_signal_connect (G_OBJECT (beat_button[i]), "toggled", G_CALLBACK (beat),
|
2004-03-15 19:32:27 +00:00
|
|
|
GUINT_TO_POINTER (i));
|
2002-01-04 21:39:32 +00:00
|
|
|
|
|
|
|
/* show the gui. */
|
2004-03-14 22:34:33 +00:00
|
|
|
gtk_widget_show_all (window);
|
2003-01-17 14:04:39 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
gtk_idle_add ((GtkFunction) gst_bin_iterate, pipeline);
|
2002-10-17 20:05:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int
|
2004-03-14 22:34:33 +00:00
|
|
|
main (int argc, char **argv)
|
2002-10-17 20:05:58 +00:00
|
|
|
{
|
|
|
|
gst_init (&argc, &argv);
|
|
|
|
gtk_init (&argc, &argv);
|
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
if (argc != 2) {
|
|
|
|
g_print ("usage: %s <mp3-filename>\n", argv[0]);
|
|
|
|
exit (-1);
|
2002-10-17 20:05:58 +00:00
|
|
|
}
|
2002-02-02 13:59:13 +00:00
|
|
|
|
2004-03-14 22:34:33 +00:00
|
|
|
setup_pipeline (argv[1]);
|
|
|
|
gst_element_set_state (pipeline, GST_STATE_PLAYING);
|
|
|
|
setup_gui ();
|
|
|
|
gtk_main ();
|
|
|
|
g_free (beat_button);
|
2002-02-02 13:59:13 +00:00
|
|
|
return 0;
|
2002-01-04 21:39:32 +00:00
|
|
|
}
|