Commit 6623ab25 authored by Wim Taymans's avatar Wim Taymans

Merge branch 'master' into 0.11

parents 979431c0 c1c858f2
......@@ -250,7 +250,7 @@ gst_v4l2_fill_lists (GstV4l2Object * v4l2object)
control.id = n;
if (v4l2_ioctl (v4l2object->video_fd, VIDIOC_QUERYCTRL, &control) < 0) {
if (errno == EINVAL) {
if (errno == EINVAL || errno == ENOTTY || errno == EIO) {
if (n < V4L2_CID_PRIVATE_BASE) {
GST_DEBUG_OBJECT (e, "skipping control %08x", n);
/* continue so that we also check private controls */
......@@ -260,12 +260,9 @@ gst_v4l2_fill_lists (GstV4l2Object * v4l2object)
break;
}
} else {
GST_ELEMENT_ERROR (e, RESOURCE, SETTINGS,
(_("Failed getting controls attributes on device '%s'."),
v4l2object->videodev),
("Failed querying control %d on device '%s'. (%d - %s)",
n, v4l2object->videodev, errno, strerror (errno)));
return FALSE;
GST_WARNING_OBJECT (e, "Failed querying control %d on device '%s'. "
"(%d - %s)", n, v4l2object->videodev, errno, strerror (errno));
continue;
}
}
if (control.flags & V4L2_CTRL_FLAG_DISABLED) {
......
......@@ -7,8 +7,10 @@ demo_osssrc_CFLAGS = $(GST_BASE_CFLAGS) $(GST_CFLAGS) $(GTK_CFLAGS)
demo_osssrc_LDADD = $(GST_BASE_LIBS) $(GST_LIBS) $(GTK_LIBS)
demo_audiotest_SOURCES = demo-audiotest.c
demo_audiotest_CFLAGS = $(GST_BASE_CFLAGS) $(GST_CFLAGS) $(GTK_CFLAGS)
demo_audiotest_LDADD = $(GST_BASE_LIBS) $(GST_LIBS) $(GTK_LIBS)
demo_audiotest_CFLAGS = $(GST_PLUGINS_BASE_CFLAGS) \
$(GST_BASE_CFLAGS) $(GST_CFLAGS) $(GTK_CFLAGS)
demo_audiotest_LDADD = $(GST_PLUGINS_BASE_LIBS) -lgstfft-$(GST_MAJORMINOR) \
$(GST_BASE_LIBS) $(GST_LIBS) $(GTK_LIBS)
spectrum_example_SOURCES = spectrum-example.c
spectrum_example_CFLAGS = $(GST_BASE_CFLAGS) $(GST_CFLAGS) $(GTK_CFLAGS)
......
......@@ -17,6 +17,19 @@
* Boston, MA 02111-1307, USA.
*/
/* TODO: add wave selection */
/* fast vs. slow mode - see update_spectrum_bands()
* we are still cheating below, we only draw the first spect_bands and ignore a few :/
*
* xtime gst-launch-0.10 -q audiotestsrc num-buffers=10000 ! spectrum bands=1441 ! fakesink
* 2.29u 0.02s 2.14r 25504kB gst-launch-0.10 -q audiotestsrc num-buffers=10000 ! spectrum bands=1441 ! fakesink
* 2.20u 0.05s 2.10r 25664kB gst-launch-0.10 -q audiotestsrc num-buffers=10000 ! spectrum bands=1441 ! fakesink
* 2.23u 0.04s 2.10r 25664kB gst-launch-0.10 -q audiotestsrc num-buffers=10000 ! spectrum bands=1441 ! fakesink
*
* xtime gst-launch-0.10 -q audiotestsrc num-buffers=10000 ! spectrum bands=1440 ! fakesink
* 25.01u 0.08s 25.00r 25552kB gst-launch-0.10 -q audiotestsrc num-buffers=10000 ! spectrum bands=1440 ! fakesink
* 24.96u 0.03s 24.88r 25568kB gst-launch-0.10 -q audiotestsrc num-buffers=10000 ! spectrum bands=1440 ! fakesink
* 25.11u 0.03s 25.03r 25536kB gst-launch-0.10 -q audiotestsrc num-buffers=10000 ! spectrum bands=1440 ! fakesink
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
......@@ -27,6 +40,7 @@
#include <string.h>
#include <math.h>
#include <gst/gst.h>
#include <gst/fft/gstfft.h>
#include <gtk/gtk.h>
#ifndef DEFAULT_AUDIOSINK
......@@ -36,8 +50,10 @@
static guint spect_height = 64;
static guint spect_bands = 256;
static gfloat height_scale = 1.0;
static gboolean fast = FALSE;
static GtkWidget *drawingarea = NULL;
static GtkWidget *bands_used = NULL;
static GstClock *sync_clock = NULL;
static void
......@@ -57,21 +73,41 @@ on_frequency_changed (GtkRange * range, gpointer user_data)
g_object_set (machine, "freq", value, NULL);
}
static void
update_spectrum_bands (GstElement * spectrum)
{
guint bands = spect_bands;
gchar str[50];
if (fast)
bands = ((gst_fft_next_fast_length (2 * bands - 2) + 2) / 2);
sprintf (str, "using %u bands", bands);
g_object_set (bands_used, "label", str, NULL);
g_object_set (G_OBJECT (spectrum), "bands", bands, NULL);
}
static gboolean
on_configure_event (GtkWidget * widget, GdkEventConfigure * event,
gpointer user_data)
{
GstElement *spectrum = GST_ELEMENT (user_data);
/*GST_INFO ("%d x %d", event->width, event->height); */
spect_height = event->height;
height_scale = event->height / 64.0;
spect_bands = event->width;
g_object_set (G_OBJECT (spectrum), "bands", spect_bands, NULL);
update_spectrum_bands (GST_ELEMENT (user_data));
return FALSE;
}
static void
on_fast_slow_mode_changed (GtkToggleButton * togglebutton, gpointer user_data)
{
fast = gtk_toggle_button_get_active (togglebutton);
update_spectrum_bands (GST_ELEMENT (user_data));
}
/* draw frequency spectrum as a bunch of bars */
static void
draw_spectrum (gfloat * data)
......@@ -170,7 +206,7 @@ main (int argc, char *argv[])
GstElement *bin;
GstElement *src, *spectrum, *audioconvert, *sink;
GstBus *bus;
GtkWidget *appwindow, *vbox, *widget;
GtkWidget *appwindow, *vbox, *hbox, *widget;
gst_init (&argc, &argv);
gtk_init (&argc, &argv);
......@@ -205,6 +241,16 @@ main (int argc, char *argv[])
G_CALLBACK (on_window_destroy), NULL);
vbox = gtk_vbox_new (FALSE, 6);
hbox = gtk_hbox_new (FALSE, 6);
widget = gtk_check_button_new_with_label ("Fast");
g_signal_connect (G_OBJECT (widget), "toggled",
G_CALLBACK (on_fast_slow_mode_changed), (gpointer) spectrum);
gtk_box_pack_start (GTK_BOX (hbox), widget, FALSE, FALSE, 0);
bands_used = gtk_label_new ("");
gtk_box_pack_start (GTK_BOX (hbox), bands_used, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
widget = gtk_hscale_new_with_range (50.0, 20000.0, 10);
gtk_scale_set_draw_value (GTK_SCALE (widget), TRUE);
gtk_scale_set_value_pos (GTK_SCALE (widget), GTK_POS_TOP);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment