+/*
+ * This file is part of mapper
+ *
+ * Copyright (C) 2007 Kaj-Michael Lang
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
/*
* Quick record audio notes on the road.
*/
GstElement *src;
GstElement *sink;
GstElement *filter;
+ gboolean rec;
};
static note_pipeline note_play;
static note_pipeline note_record;
+static GstBus *bus;
+
static gboolean
-audio_bus_cb()
+audio_note_bus_cb(GstBus *bus, GstMessage *msg, gpointer data)
{
+gchar *debug;
+GError *err;
+
+switch (GST_MESSAGE_TYPE (msg)) {
+ case GST_MESSAGE_EOS:
+ g_print ("EOS\n");
+ break;
+ case GST_MESSAGE_ERROR:
+ gst_message_parse_error (msg, &err, &debug);
+ g_free(debug);
+
+ g_printf("Error: %s\n", err->message);
+ g_error_free(err);
+ break;
+ case GST_MESSAGE_STATE_CHANGED:
+ g_printf("State changed\n");
+ break;
+ default:
+ g_printf("GST: %s\n", gst_message_type_get_name(GST_MESSAGE_TYPE(msg)));
+ break;
+ }
+return TRUE;
}
static gboolean
np->filter=gst_element_factory_make("wavenc", "filter");
np->sink=gst_element_factory_make(AUDIO_SINK, "sink");
}
+np->rec=rec;
g_assert(np->src);
g_assert(np->sink);
g_assert(np->filter);
audio_note_play(gchar *file)
{
audio_set_filename(note_play.src, file);
+if (gst_element_set_state (note_play.pipeline, GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE) {
+ g_printf("Failed to play file %s\n", file);
+ return FALSE;
+}
return TRUE;
}
gboolean
audio_note_record(gchar *file)
{
-audio_set_filename(note_play.sink, file);
+audio_set_filename(note_record.sink, file);
+if (gst_element_set_state (note_record.pipeline, GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE) {
+ g_printf("Failed to record to file %s\n", file);
+ return FALSE;
+}
return TRUE;
}
{
audio_create_pipeline(¬e_play, FALSE);
audio_create_pipeline(¬e_record, TRUE);
+
+bus=gst_pipeline_get_bus(GST_PIPELINE(note_play.pipeline));
+g_assert(bus);
+gst_bus_add_watch(bus, audio_note_bus_cb, NULL);
+
+bus=gst_pipeline_get_bus(GST_PIPELINE(note_record.pipeline));
+g_assert(bus);
+gst_bus_add_watch(bus, audio_note_bus_cb, NULL);
+
return TRUE;
}
void
audio_note_deinit(void)
{
+gst_element_set_state(note_play.pipeline, GST_STATE_NULL);
+gst_object_unref(note_play.pipeline);
+gst_element_set_state(note_record.pipeline, GST_STATE_NULL);
+gst_object_unref(note_record.pipeline);
}
+/*
+ * This file is part of mapper
+ *
+ * Copyright (C) 2007 Kaj-Michael Lang
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
#ifndef _AUDIO_NOTE_H
#define _AUDIO_NOTE_H