r2651 - in trunk/src/target/OM-2007.2/applications/openmoko-dialer2: . src
njp at sita.openmoko.org
njp at sita.openmoko.org
Mon Aug 6 18:03:47 CEST 2007
Author: njp
Date: 2007-08-06 18:03:45 +0200 (Mon, 06 Aug 2007)
New Revision: 2651
Modified:
trunk/src/target/OM-2007.2/applications/openmoko-dialer2/ChangeLog
trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/moko-notify.c
Log:
2007-08-06 Neil J. Patel <njp at o-hand.com>
* src/moko-notify.c: (on_bin_eos), (moko_notify_start_ringtone):
Added intial support for looping the ringtone.
Modified: trunk/src/target/OM-2007.2/applications/openmoko-dialer2/ChangeLog
===================================================================
--- trunk/src/target/OM-2007.2/applications/openmoko-dialer2/ChangeLog 2007-08-06 15:02:56 UTC (rev 2650)
+++ trunk/src/target/OM-2007.2/applications/openmoko-dialer2/ChangeLog 2007-08-06 16:03:45 UTC (rev 2651)
@@ -1,5 +1,10 @@
2007-08-06 Neil J. Patel <njp at o-hand.com>
+ * src/moko-notify.c: (on_bin_eos), (moko_notify_start_ringtone):
+ Added intial support for looping the ringtone.
+
+2007-08-06 Neil J. Patel <njp at o-hand.com>
+
* src/moko-notify.c: (moko_notify_start_ringtone):
Try and use the simple commandline gst parser.
Modified: trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/moko-notify.c
===================================================================
--- trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/moko-notify.c 2007-08-06 15:02:56 UTC (rev 2650)
+++ trunk/src/target/OM-2007.2/applications/openmoko-dialer2/src/moko-notify.c 2007-08-06 16:03:45 UTC (rev 2651)
@@ -59,9 +59,24 @@
static void
-on_filesrc_eos (GstElement *element, MokoNotify *notify)
+on_bin_eos (GstElement *element, MokoNotify *notify)
{
+ MokoNotifyPrivate *priv;
+
+ g_return_if_fail (MOKO_IS_NOTIFY (notify));
+ g_return_if_fail (GST_IS_ELEMENT (notify->priv->bin));
+ priv = notify->priv;
+
/* Rewind and play again */
+ gst_element_set_state (priv->bin, GST_STATE_PAUSED);
+
+ /* Seek to 0 */
+ if (!gst_element_seek_simple (priv->bin, GST_FORMAT_TIME, 0, 0))
+ g_error ("Seek error\n");
+ return;
+
+ gst_element_set_state (priv->bin, GST_STATE_PLAYING);
+
g_print ("Audio finished\n");
}
@@ -69,15 +84,20 @@
moko_notify_start_ringtone (MokoNotify *notify)
{
MokoNotifyPrivate *priv;
- GstElement *bin, *filesrc, *decoder, *aconvert, *aresample, *asink;
+ GstElement *bin;
gchar *pipeline;
GError *err = NULL;
g_return_if_fail (MOKO_IS_NOTIFY (notify));
priv = notify->priv;
-
- pipeline = g_strdup_printf ("filesrc location=%s ! decodebin ! audioconvert !audioresample ! alsasink", PKGDATADIR DEFAULT_RINGTONE);
+
+ /* Create the pipeline */
+ pipeline = g_strdup_printf (
+ "filesrc location=%s ! decodebin ! audioconvert !audioresample ! alsasink",
+ PKGDATADIR DEFAULT_RINGTONE);
g_print ("%s\n", PKGDATADIR DEFAULT_RINGTONE);
+
+ /* Try and gstreamer to parse it */
bin = gst_parse_launch (pipeline, &err);
if (err)
{
@@ -89,66 +109,11 @@
priv->bin = bin;
/* Start playing */
- gst_element_set_state (bin, GST_STATE_PLAYING);
- g_free (pipeline);
- return;
-
- /* Create a bin to hold elements */
- bin = gst_pipeline_new ("pipeline");
- g_assert (bin);
-
- /* Disk reader */
- filesrc = gst_element_factory_make ("filesrc", "source");
- g_assert (filesrc);
- g_object_set (G_OBJECT (filesrc),
- "location", PKGDATADIR DEFAULT_RINGTONE,
- NULL);
g_signal_connect (G_OBJECT (bin), "eos",
- G_CALLBACK (on_filesrc_eos), (gpointer)notify);
-
- /* Decoder */
- decoder = gst_element_factory_make ("decodebin", "decode");
- if (!decoder)
- {
- g_warning ("Could not load 'decodebin'");
- return;
- }
-
- /* Audio convert */
- aconvert = gst_element_factory_make ("audioconvert", NULL);
- if (!aconvert)
- {
- g_warning ("Could not load 'audioconvert'");
- return;
- }
-
- /* Audio resample */
- aresample = gst_element_factory_make ("audioresample", NULL);
- if (!aresample)
- {
- g_warning ("Could not load 'audioresample'");
- return;
- }
-
- /* Audio sink */
- asink = gst_element_factory_make ("alsasink", "play_audio");
- if (!asink)
- {
- g_warning ("Could not load 'alsasink'");
- return;
- }
-
- /* Add objects to the bin */
- gst_bin_add_many (GST_BIN (bin), filesrc, decoder,
- aconvert, aresample, asink, NULL);
-
- /* Link the elements */
- gst_element_link_many (filesrc, decoder, aconvert, aresample, asink, NULL);
-
- priv->bin = bin;
-
- /* Start playing */
+ G_CALLBACK (on_bin_eos), (gpointer)notify);
gst_element_set_state (bin, GST_STATE_PLAYING);
+
+ g_free (pipeline);
}
static void
More information about the commitlog
mailing list