]> err.no Git - mapper/commitdiff
Set caps so we don't record @ 32-bit stereo 44100. Skip on tablets as they default...
authorKaj-Michael Lang <milang@onion.tal.org>
Thu, 28 Feb 2008 16:59:17 +0000 (18:59 +0200)
committerKaj-Michael Lang <milang@onion.tal.org>
Thu, 28 Feb 2008 16:59:17 +0000 (18:59 +0200)
src/audio-note.c
src/audio-note.h

index b0c1830041dd4fd56f77bc11ca96eca227b6bf5a..46370529cce284a00868755d6ee3319fe89d8fbb 100644 (file)
  */
 
 #include "config.h"
+#include <glib.h>
 #include <gst/gst.h>
 #include <gtk/gtk.h>
 
+#include "ui-common.h"
 #include "audio.h"
 #include "audio-note.h"
 
 static note_pipeline note_play;
 static note_pipeline note_record;
 static GstBus *bus;
+static gchar *cfile=NULL;
 
 static gboolean
 audio_note_record_cb(GtkWidget *widget, gpointer data)
 {
-audio_note_record("/tmp/testing.wav");
+const gchar *basedir;
+gchar buffer[128];
+audio_note_ui *ui=(audio_note_ui *)data;
+GDate *gd;
+time_t t;
+struct tm *tmp;
+
+/* XXX: Make this a configuration option */
+#ifdef WITH_DEVICE_770
+basedir="/media/mmc1/MapperAudioNotes";
+if (g_mkdir_with_parents(basedir, 0775)==-1) {
+       MACRO_BANNER_SHOW_INFO(_window, _("Failed to create directory for sound files!"));
+       return TRUE;
+}
+#else
+basedir=g_get_home_dir();
+#endif
+
+t=time(NULL);
+tmp=localtime(&t);
+if (tmp == NULL) {
+       MACRO_BANNER_SHOW_INFO(_window, _("Failed to get timestamp for file!"));
+       return TRUE;
+}
+strftime(buffer, sizeof(buffer), "%Y-%m-%d-%H:%M:%S", tmp);
+
+if (cfile)
+       g_free(cfile);
+
+cfile=g_strdup_printf("%s/an-%s.wav", basedir, buffer);
+
+audio_note_record(cfile);
+
+MACRO_BANNER_SHOW_INFO(_window, _("Recording..."));
+
 return TRUE;
 }
 
 static gboolean
 audio_note_play_cb(GtkWidget *widget, gpointer data)
 {
-audio_note_play("/tmp/testing.wav");
+audio_note_ui *ui=(audio_note_ui *)data;
+
+audio_note_play(cfile);
+MACRO_BANNER_SHOW_INFO(_window, _("Playing..."));
 return TRUE;
 }
 
 static gboolean
 audio_note_stop_cb(GtkWidget *widget, gpointer data)
 {
-audio_note_stop();
+if (audio_note_stop()==TRUE)
+       MACRO_BANNER_SHOW_INFO(_window, _("Stopped..."));
 return TRUE;
 }
 
@@ -121,20 +162,28 @@ if (rec==TRUE) {
        np->src=gst_element_factory_make(AUDIO_SRC, "source");
        np->filter=gst_element_factory_make("wavenc", "filter");
        np->sink=gst_element_factory_make("filesink", "sink");
-#if 0
-       /* No idea wasting space with some hifi format */
-       np->caps=gst_element_factory_make("capsfilter", "caps");
+
+       gst_bin_add_many(GST_BIN(np->pipeline), np->src, np->filter, np->sink, NULL);
+
+#ifndef WITH_DEVICE_770
+       /* Don't waste space with some hifi format */
        np->srccaps=gst_caps_new_simple ("audio/x-raw-int",
                        "depth", G_TYPE_INT, 16,
                        "signed", G_TYPE_BOOLEAN, TRUE, 
-                       "width", G_TYPE_INT,  16,
-                       "rate", G_TYPE_INT, 8000,
+                       "width", G_TYPE_INT, 16,
+                       "rate", G_TYPE_INT, 11025,
                        "channels", G_TYPE_INT, 1,
                        NULL);
+       if (!gst_element_link_filtered(np->src, np->filter, np->srccaps))
+               g_printerr("Failed to set caps for source\n");
+       else
+               gst_element_link(np->src, np->filter);
+       gst_caps_unref(np->srccaps);
+#else
+       gst_element_link(np->src, np->filter);  
 #endif
-       gst_bin_add_many(GST_BIN(np->pipeline), np->src, np->filter, np->sink, NULL);
-       if (!gst_element_link_many(np->src, np->filter, np->sink, NULL))
-               g_printerr("Failed to link record pipeline\n");
+       gst_element_link(np->filter, np->sink);
+
 } else {
        g_debug("GST: Creating playback pipeline");
        np->src=gst_element_factory_make("filesrc", "source");
index 0f64ac8c762c7c1f3c468abb413019805ade75fb..250ee0292ef365057cceddbbd61a2948c14ff11b 100644 (file)
@@ -30,6 +30,8 @@ struct _note_pipeline {
        GstElement *src;
        GstElement *sink;
        GstElement *filter;
+       GstElement *caps;
+       GstCaps *srccaps;
        gboolean active;
        gboolean rec;
 };