Send commitlog mailing list submissions to
        [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
        http://lists.openmoko.org/mailman/listinfo/commitlog
or, via email, send a message with subject or body 'help' to
        [EMAIL PROTECTED]

You can reach the person managing the list at
        [EMAIL PROTECTED]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of commitlog digest..."
Today's Topics:

   1. r2882 -
      trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src
      ([EMAIL PROTECTED])
--- Begin Message ---
Author: abraxa
Date: 2007-09-01 13:12:10 +0200 (Sat, 01 Sep 2007)
New Revision: 2882

Modified:
   
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/editor_page.c
   
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/files_page.c
   
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/files_page.h
   trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/guitools.c
   trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/main.c
   trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/main.h
   trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/main_page.c
   
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/omp_spiff_c.cpp
   
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/omp_spiff_c.h
   
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/persistent.c
   
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/persistent.h
   trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/playback.c
   trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/playlist.c
   trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/playlist.h
   
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/playlist_page.c
Log:
Proper XSPF artist/title handling (simple libSpiff C binding didn't permit this)
Bugfixes: Prev track treshold (prevented skipping backwards), track duration no 
longer buggy, error dialogs no longer block the message loop 
Enhancements: Titles for files without metadata, prev track treshold now 
configurable, better meta data handling by the UI



Modified: 
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/editor_page.c
===================================================================
--- 
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/editor_page.c 
    2007-09-01 09:37:39 UTC (rev 2881)
+++ 
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/editor_page.c 
    2007-09-01 11:12:10 UTC (rev 2882)
@@ -27,6 +27,7 @@
 #include <gtk/gtk.h>
 #include <glib/gi18n.h>
 #include <libmokoui2/moko-finger-scroll.h>
+#include <string.h>
 
 #include "editor_page.h"
 #include "playlist.h"
@@ -72,32 +73,52 @@
  * Updates a track's title and duration upon arrival of metadata
  */
 void
-omp_editor_page_update_track_info(gpointer instance, gpointer track_infos, 
gpointer user_data)
+omp_editor_page_update_track_info(gpointer instance, guint track_id, gpointer 
user_data)
 {
-/*     omp_track_infos *infos;
-       gchar *track_title, *track_duration, *path;
+       gchar *artist, *title, *caption, *duration, *path;
+       gulong int_duration = 0;
        GtkTreeIter tree_iter;
 
-       infos = (omp_track_infos*)track_infos;
+       omp_playlist_get_track_info(track_id, &artist, &title, &int_duration);
 
-       if (infos->duration > 0)
+       // Prepare values for display
+       if (int_duration > 0)
        {
-               track_duration = 
g_strdup_printf(OMP_WIDGET_CAPTION_EDITOR_TRACK_TIME,
-                       infos->duration / 60000, (infos->duration/1000) % 60);
+               duration = g_strdup_printf(OMP_WIDGET_CAPTION_EDITOR_TRACK_TIME,
+                       (gint)(int_duration / 60000), (gint)(int_duration/1000) 
% 60);
        } else {
-               track_duration = NULL;
+               duration = NULL;
        }
 
-       path = g_strdup_printf("%d", infos->id);
+       if (artist)
+       {
+               if (strcmp(artist, "") != 0)
+               {
+                       caption = g_strdup_printf(_("%1$s - %2$s"), artist, 
title);
+               } else {
+                       caption = g_strdup(title);
+               }
+
+       } else {
+               caption = g_strdup(title);
+       }
+
+       // Find column to edit
+       path = g_strdup_printf("%d", track_id);
        
gtk_tree_model_get_iter_from_string(GTK_TREE_MODEL(omp_editor_page_list_store),
                &tree_iter, path);
-       
+
+       // Update values
        gtk_list_store_set(omp_editor_page_list_store, &tree_iter,
-               TITLE_COLUMN, infos->title,
-               DURATION_COLUMN, track_duration, -1);
+               TITLE_COLUMN, caption,
+               DURATION_COLUMN, duration, -1);
 
+       // Clean up
        g_free(path);
-       g_free(track_duration); */
+       g_free(caption);
+       g_free(duration);
+       g_free(title);
+       g_free(artist);
 }
 
 /**
@@ -106,7 +127,8 @@
 void
 omp_editor_page_add_clicked(gpointer instance, gpointer user_data)
 {
-       
+       // Show file chooser
+       omp_show_tab(OMP_TAB_FILE_CHOOSER);
 }
 
 /**

Modified: 
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/files_page.c
===================================================================
--- 
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/files_page.c  
    2007-09-01 09:37:39 UTC (rev 2881)
+++ 
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/files_page.c  
    2007-09-01 11:12:10 UTC (rev 2882)
@@ -26,3 +26,16 @@
 
 #include "files_page.h"
 
+/**
+ * Creates the file chooser UI page and all its elements
+ */
+GtkWidget *
+omp_files_page_create()
+{
+       GtkWidget *main_vbox;
+
+       // Create main container
+       main_vbox = gtk_vbox_new(FALSE, 0);
+
+       return main_vbox;
+}

Modified: 
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/files_page.h
===================================================================
--- 
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/files_page.h  
    2007-09-01 09:37:39 UTC (rev 2881)
+++ 
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/files_page.h  
    2007-09-01 11:12:10 UTC (rev 2882)
@@ -27,7 +27,10 @@
 #ifndef FILES_PAGE_H
 #define FILES_PAGE_H
 
+#include <gtk/gtk.h>
 
+GtkWidget *omp_files_page_create();
+
 #endif
 
 

Modified: 
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/guitools.c
===================================================================
--- 
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/guitools.c    
    2007-09-01 09:37:39 UTC (rev 2881)
+++ 
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/guitools.c    
    2007-09-01 11:12:10 UTC (rev 2882)
@@ -145,8 +145,8 @@
        // We don't want a title of "<unnamed>"
        gtk_window_set_title(GTK_WINDOW(dialog), " ");
 
-       gtk_dialog_run(GTK_DIALOG(dialog));
-       gtk_widget_destroy(dialog);
+       g_signal_connect_swapped(dialog, "response", G_CALLBACK 
(gtk_widget_destroy), dialog);
+       gtk_widget_show_all(dialog);
 }
 
 /**

Modified: 
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/main.c
===================================================================
--- trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/main.c    
2007-09-01 09:37:39 UTC (rev 2881)
+++ trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/main.c    
2007-09-01 11:12:10 UTC (rev 2882)
@@ -33,11 +33,9 @@
 #include <glib/gprintf.h>
 #include <gdk/gdk.h>
 
-#include <stdlib.h>
-#include <errno.h>
+#include <signal.h>
+#include <unistd.h>
 #include <fcntl.h>
-#include <unistd.h>
-#include <signal.h>
 
 #define DBUS_API_SUBJECT_TO_CHANGE
 #include <dbus/dbus.h>
@@ -47,13 +45,14 @@
 #include "libmokoui2/moko-stock.h"
 
 #include "main.h"
+#include "editor_page.h"
+#include "files_page.h"
+#include "guitools.h"
 #include "main_page.h"
+#include "persistent.h"
 #include "playlist_page.h"
-#include "editor_page.h"
-#include "guitools.h"
 #include "playlist.h"
 #include "playback.h"
-#include "persistent.h"
 
 // Determines how the segfault handler terminates the program
 //define HANDLE_SIGSEGV
@@ -194,8 +193,14 @@
        if (pid > 0)
        {
                g_printf(_("Already running an instance of the Media Player, 
bringing that to the front instead.\n"));
-               kill(pid, SIGUSR1);
-               return TRUE;
+
+               // Was signaling the other process successful?
+               if (kill(pid, SIGUSR1) == 0)
+               {
+                       return TRUE;
+               } else {
+                       g_printf(_("Previous instance invalid, proceeding with 
regular startup.\n"));
+               }
        }
 
        set_lock(lock_file);
@@ -260,6 +265,12 @@
        notebook_add_page_with_icon(omp_notebook, page, "gtk-index", 0);
        omp_notebook_tabs[OMP_TAB_PLAYLIST_EDITOR] = page;
        gtk_widget_hide(page);  // We show the page once a playlist was loaded
+
+       // Add file chooser page
+       page = omp_files_page_create();
+       notebook_add_page_with_icon(omp_notebook, page, "gtk-index", 0);
+       omp_notebook_tabs[OMP_TAB_FILE_CHOOSER] = page;
+       gtk_widget_hide(page);  // We show the page once user wants to add files
 }
 
 /**

Modified: 
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/main.h
===================================================================
--- trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/main.h    
2007-09-01 09:37:39 UTC (rev 2881)
+++ trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/main.h    
2007-09-01 11:12:10 UTC (rev 2882)
@@ -43,6 +43,7 @@
        OMP_TAB_MAIN = 0,
        OMP_TAB_PLAYLISTS,
        OMP_TAB_PLAYLIST_EDITOR,
+       OMP_TAB_FILE_CHOOSER,
        OMP_TABS
 };
 

Modified: 
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/main_page.c
===================================================================
--- 
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/main_page.c   
    2007-09-01 09:37:39 UTC (rev 2881)
+++ 
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/main_page.c   
    2007-09-01 11:12:10 UTC (rev 2882)
@@ -65,13 +65,12 @@
 
 // Forward declarations for internal use
 void omp_main_update_track_change(gpointer instance, gpointer user_data);
+void omp_main_update_track_info_changed(gpointer instance, guint track_id, 
gpointer user_data);
 void omp_main_update_shuffle_state(gpointer instance, gboolean state, gpointer 
user_data);
 void omp_main_update_repeat_mode(gpointer instance, guint mode, gpointer 
user_data);
 void omp_main_update_status_change(gpointer instance, gpointer user_data);
 void omp_main_update_track_position(gpointer instance, gpointer user_data);
 void omp_main_update_volume(gpointer instance, gpointer user_data);
-void omp_main_update_tag_artist(gpointer instance, const gchar *artist, 
gpointer user_data);
-void omp_main_update_tag_title(gpointer instance, const gchar *title, gpointer 
user_data);
 
 
 
@@ -185,7 +184,7 @@
        // Prevent UI callbacks from messing with the slider position
        omp_main_time_slider_can_update = FALSE;
 
-       return TRUE;
+       return FALSE;
 }
 
 /**
@@ -202,7 +201,7 @@
        // Notify the slider change callback that this time we indeed want to 
change position
        omp_main_time_slider_was_dragged = TRUE;
 
-       return TRUE;
+       return FALSE;
 }
 
 /**
@@ -553,7 +552,7 @@
        gtk_scale_set_draw_value(GTK_SCALE(vol_scale), FALSE);
        GTK_WIDGET_UNSET_FLAGS(GTK_WIDGET(vol_scale), GTK_CAN_FOCUS);
        gtk_widget_set_size_request(GTK_WIDGET(vol_scale), 338, 35);
-       gtk_range_set_update_policy(GTK_RANGE(vol_scale), 
GTK_UPDATE_DISCONTINUOUS);
+       gtk_range_set_update_policy(GTK_RANGE(vol_scale), 
GTK_UPDATE_CONTINUOUS);
        g_signal_connect(G_OBJECT(vol_scale), "value_changed", 
G_CALLBACK(omp_main_volume_slider_changed), NULL);
        gtk_container_add(GTK_CONTAINER(alignment), GTK_WIDGET(vol_scale));
        main_widgets.volume_hscale = vol_scale;
@@ -590,6 +589,9 @@
        g_signal_connect(G_OBJECT(omp_window), OMP_EVENT_PLAYLIST_TRACK_CHANGED,
                G_CALLBACK(omp_main_update_track_change), NULL);
 
+       g_signal_connect(G_OBJECT(omp_window), 
OMP_EVENT_PLAYLIST_TRACK_INFO_CHANGED,
+               G_CALLBACK(omp_main_update_track_info_changed), NULL);
+
        g_signal_connect(G_OBJECT(omp_window), 
OMP_EVENT_PLAYLIST_TRACK_COUNT_CHANGED,
                G_CALLBACK(omp_main_update_track_change), NULL);
 
@@ -613,12 +615,6 @@
        g_signal_connect(G_OBJECT(omp_window), 
OMP_EVENT_PLAYBACK_VOLUME_CHANGED,
                G_CALLBACK(omp_main_update_volume), NULL);
 
-       g_signal_connect(G_OBJECT(omp_window), 
OMP_EVENT_PLAYBACK_META_ARTIST_CHANGED,
-               G_CALLBACK(omp_main_update_tag_artist), NULL);
-
-       g_signal_connect(G_OBJECT(omp_window), 
OMP_EVENT_PLAYBACK_META_TITLE_CHANGED,
-               G_CALLBACK(omp_main_update_tag_title), NULL);
-
        // Make all widgets visible
        gtk_widget_show_all(bg_muxer);
 
@@ -638,9 +634,18 @@
        static gulong old_track_length = 0;
 
        gulong track_length, track_position;
+       gchar *artist = NULL;
+       gchar *title = NULL;
        gchar *text;
        gint track_id;
 
+       // Set preliminary artist/title strings (updated on incoming metadata)
+       omp_playlist_get_track_info(omp_playlist_current_track_id, &artist, 
&title, &track_length);
+       gtk_label_set_text(GTK_LABEL(main_widgets.artist_label), artist);
+       gtk_label_set_text(GTK_LABEL(main_widgets.title_label), title);
+       if (artist) g_free(artist);
+       if (title) g_free(title);
+
        // Track id/track count changed?
        if (
                        (omp_playlist_track_count != old_track_count) ||
@@ -658,16 +663,11 @@
        }
 
        // Got a track length change?
-       track_length = omp_playback_get_track_length();
-
-       if (track_length != old_track_length)
+       if ( (track_length) && (track_length != old_track_length) )
        {
                old_track_length = track_length;
                track_position = omp_playback_get_track_position();
 
-               // Set new time slider increments: one tap is 10% of the 
track's playing time
-               gtk_range_set_increments(GTK_RANGE(main_widgets.time_hscale), 
track_length/10, track_length/10);
-
                // Update label and slider
                text = g_strdup_printf(OMP_WIDGET_CAPTION_TRACK_TIME,
                        (guint)(track_position / 60000), 
(guint)(track_position/1000) % 60,
@@ -681,11 +681,23 @@
                        // critial GTK warning, so we set 0/1 instead in that 
case
                        
gtk_range_set_range(GTK_RANGE(main_widgets.time_hscale), 0, track_length ? 
track_length : 1);
                        
gtk_range_set_value(GTK_RANGE(main_widgets.time_hscale), track_position);
+
+                       // Set new time slider increments: one tap is 10% of 
the track's playing time
+                       
gtk_range_set_increments(GTK_RANGE(main_widgets.time_hscale), track_length/10, 
track_length/10);
                }
        }
 }
 
 /**
+ * Updates the UI when the track's meta data changed
+ */
+void
+omp_main_update_track_info_changed(gpointer instance, guint track_id, gpointer 
user_data)
+{
+       omp_main_update_track_change(NULL, NULL);
+}
+
+/**
  * Updates the UI after a change to the shuffle flag
  */
 void
@@ -775,7 +787,7 @@
                // Update UI
                text = g_strdup_printf(OMP_WIDGET_CAPTION_TRACK_TIME,
                        (guint)(track_position / 60000), 
(guint)(track_position/1000) % 60,
-                       (guint)track_length / 60000, (guint)(track_length/1000) 
% 60);
+                       (guint)(track_length / 60000), 
(guint)(track_length/1000) % 60);
                gtk_label_set_text(GTK_LABEL(main_widgets.time_label), text);
                g_free(text);
 
@@ -785,6 +797,9 @@
                        // critial GTK warning, so we set 0/1 instead in that 
case
                        
gtk_range_set_range(GTK_RANGE(main_widgets.time_hscale), 0, track_length ? 
track_length : 1);
                        
gtk_range_set_value(GTK_RANGE(main_widgets.time_hscale), track_position);
+
+                       // Set new time slider increments: one tap is 10% of 
the track's playing time
+                       
gtk_range_set_increments(GTK_RANGE(main_widgets.time_hscale), track_length/10, 
track_length/10);
                }
        }
 
@@ -811,21 +826,3 @@
 
        gtk_range_set_value(GTK_RANGE(main_widgets.volume_hscale), volume);
 }
-
-/**
- * Updates the UI's track artist label
- */
-void
-omp_main_update_tag_artist(gpointer instance, const gchar *artist, gpointer 
user_data)
-{
-       gtk_label_set_text(GTK_LABEL(main_widgets.artist_label), artist);
-}
-
-/**
- * Updates the UI's track title label
- */
-void
-omp_main_update_tag_title(gpointer instance, const gchar *title, gpointer 
user_data)
-{
-       gtk_label_set_text(GTK_LABEL(main_widgets.title_label), title);
-}

Modified: 
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/omp_spiff_c.cpp
===================================================================
--- 
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/omp_spiff_c.cpp
   2007-09-01 09:37:39 UTC (rev 2881)
+++ 
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/omp_spiff_c.cpp
   2007-09-01 11:12:10 UTC (rev 2882)
@@ -86,7 +86,7 @@
                /// Creates the callback interface for filling an omp_spiff_list
                SpiffCReaderCallback(omp_spiff_list *list);
 
-               /// Finalize the list
+               /// Finalizes the list
                virtual ~SpiffCReaderCallback();
 };
 
@@ -111,6 +111,7 @@
        // Append new item to the track list
        *newtrack = new omp_spiff_track;
 
+       (*newtrack)->creator = track->stealCreator();
        (*newtrack)->title = track->stealTitle();
        (*newtrack)->album = track->stealAlbum();
        (*newtrack)->duration = track->getDuration();
@@ -133,12 +134,12 @@
                *newmv = new omp_spiff_mvalue;
                (*newmv)->value = str;
 
-               // On to the next location
+               // On to the next identifier
                newmv = &(*newmv)->next;
        }
        *newmv = NULL;
 
-       // Clean up and move to the next track
+       // Clean up and move on to the next track
        delete track;
        newtrack = &(*newtrack)->next;
 }
@@ -238,6 +239,7 @@
                // Back-up pointer
                ntr = tr->next;
 
+               delete tr->creator;
                delete tr->title;
                delete tr->album;
 
@@ -266,6 +268,7 @@
        props.lendLicense(list->license);
        props.lendLocation(list->location);
        props.lendIdentifier(list->identifier);
+
        SpiffPropsWriter pwriter(&props);
        SpiffTrackWriter twriter;
        SpiffWriter writer(1, formatter, pwriter);
@@ -274,6 +277,8 @@
        {
                // Tracks
                SpiffTrack track;
+
+               track.lendCreator(strack->creator);
                track.lendTitle(strack->title);
                track.lendAlbum(strack->album);
                track.setDuration(strack->duration);
@@ -349,12 +354,14 @@
        omp_spiff_track *ret;
 
        ret = new omp_spiff_track;
+       ret->creator = NULL;
        ret->title = NULL;
        ret->album = NULL;
        ret->duration = -1;
        ret->tracknum = -1;
        ret->locations = NULL;
        ret->identifiers = NULL;
+       ret->title_is_preliminary = 0;
        ret->next = *track;
        *track = ret;
 

Modified: 
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/omp_spiff_c.h
===================================================================
--- 
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/omp_spiff_c.h 
    2007-09-01 09:37:39 UTC (rev 2881)
+++ 
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/omp_spiff_c.h 
    2007-09-01 11:12:10 UTC (rev 2882)
@@ -64,6 +64,9 @@
 /// Single track in an XSPF list
 typedef struct _omp_spiff_track
 {
+       /// Track's creator (= artist)
+       char *creator;
+
        /// Track's display name
        char *title;
 
@@ -82,6 +85,9 @@
        /// Unique track identifiers
        omp_spiff_mvalue *identifiers;
 
+       /// Preliminary title flag, title will be overwritten on incoming tag 
data (non-XSPF feature)
+       int title_is_preliminary;
+
        /// Pointer to next track
        struct _omp_spiff_track *next;
 

Modified: 
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/persistent.c
===================================================================
--- 
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/persistent.c  
    2007-09-01 09:37:39 UTC (rev 2881)
+++ 
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/persistent.c  
    2007-09-01 11:12:10 UTC (rev 2882)
@@ -42,15 +42,15 @@
 /// The default configuration
 struct _omp_config omp_default_config =
 {
-       FALSE,
-       OMP_REPEAT_OFF,
-       TRUE,
-//     FALSE,
-       FALSE,
-       "%f",
-       0.0,
-       {0,0,0,0,0,0,0,0,0,0,0},
-       TRUE
+       FALSE,                                                                  
                // shuffle
+       OMP_REPEAT_OFF,                                                 // 
repeat_mode
+       TRUE,                                                                   
                        // resume_playback
+       10000,                                                                  
                // prev_track_treshold
+//     FALSE,                                                                  
                // auto_scroll
+       0.0,                                                                    
                        // equalizer_gain
+       {0,0,0,0,0,0,0,0,0,0,0},                // EQ bands
+
+TRUE                                                                           
                // show_numbers_in_pl
 };
 
 struct _omp_config *omp_config = NULL;                 ///< Global and 
persistent configuration data
@@ -151,6 +151,15 @@
 }
 
 /**
+ * Returns amount of milliseconds that determine behavior of the "prev track" 
event
+ */
+guint
+omp_config_get_prev_track_treshold()
+{
+       return omp_config->prev_track_treshold;
+}
+
+/**
  * Fills the session data with sane default values
  */
 void

Modified: 
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/persistent.h
===================================================================
--- 
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/persistent.h  
    2007-09-01 09:37:39 UTC (rev 2881)
+++ 
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/persistent.h  
    2007-09-01 11:12:10 UTC (rev 2882)
@@ -41,9 +41,8 @@
        gboolean shuffle;                                                       
                ///< Shuffle on/off
        guint repeat_mode;                                                      
        ///< Repeat mode @see omp_repeat_modes
        gboolean resume_playback;                                       ///< 
Resume playback on startup where it left off?
+       guint prev_track_treshold;                              ///< Amount of 
milliseconds a track must have been playing to jump back to track beginning on 
"prev track" event
 //     gboolean auto_scroll;                                           ///< 
Scroll title if it's too long?
-       gboolean convert_underscore;                    ///< Convert '_' to ' '?
-       gchar title_format[32];                                         ///< 
Format string used for title display
        gdouble equalizer_gain;                                         ///< 
Pre-amplification value before audio stream is fed to equalizer [0.0..1.0]
        gdouble equalizer_bands[11];                    ///< The gains for each 
of the equalizer bands [-1.0..1.0]
        gboolean show_numbers_in_pl;                    ///< Show numbers in 
playlist?
@@ -75,6 +74,8 @@
 void omp_config_set_repeat_mode(guint mode);
 guint omp_config_get_repeat_mode();
 
+guint omp_config_get_prev_track_treshold();
+
 void omp_session_restore_state();
 void omp_session_free();
 void omp_session_save();

Modified: 
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/playback.c
===================================================================
--- 
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/playback.c    
    2007-09-01 09:37:39 UTC (rev 2881)
+++ 
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/playback.c    
    2007-09-01 11:12:10 UTC (rev 2882)
@@ -382,7 +382,7 @@
 omp_playback_get_track_length()
 {
        GstFormat format = GST_FORMAT_TIME;
-       gint64 length;
+       gint64 length = 0;
 
        if (!omp_gst_playbin)
        {
@@ -522,15 +522,10 @@
 omp_gst_message_warning(GstBus *bus, GstMessage *message, gpointer data)
 {
        GError *error;
-       gchar *text;
 
        gst_message_parse_warning(message, &error, NULL);
        g_printerr("gstreamer warning: %s\n", error->message);
 
-       text = g_strdup_printf("gstreamer warning:\n%s", error->message);
-       error_dialog(text);
-       g_free(text);
-
        g_error_free(error);
 
        return TRUE;

Modified: 
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/playlist.c
===================================================================
--- 
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/playlist.c    
    2007-09-01 09:37:39 UTC (rev 2881)
+++ 
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/playlist.c    
    2007-09-01 11:12:10 UTC (rev 2882)
@@ -29,6 +29,7 @@
 #include <glib-object.h>
 #include <glib/gi18n.h>
 #include <glib/gstdio.h>
+#include <uriparser/Uri.h>
 
 #include <string.h>
 
@@ -201,7 +202,7 @@
                #endif
 
                // Notify user
-               text = g_strdup_printf(_("\nCould not load playlist '%s'"), 
playlist_file);
+               text = g_strdup_printf(_("Could not load playlist '%s'"), 
playlist_file);
                error_dialog(text);
                g_free(text);
        }
@@ -314,8 +315,8 @@
                return FALSE;
        }
 
-       // If track playing time is >= 10 seconds we just jump back to the 
beginning of the track
-       if (omp_playback_get_track_position() >= 10)
+       // If track playing time is >= n seconds we just jump back to the 
beginning of the track
+       if (omp_playback_get_track_position() >= 
omp_config_get_prev_track_treshold())
        {
                omp_playback_set_track_position(0);
                return TRUE;
@@ -383,12 +384,12 @@
                // Update session
                omp_session_set_track_id(omp_playlist_current_track_id);
 
-               // Emit signal to update UI and the like
-               g_signal_emit_by_name(G_OBJECT(omp_window), 
OMP_EVENT_PLAYLIST_TRACK_CHANGED);
-
                // Load track and start playing if needed
                if (omp_playlist_load_current_track())
                {
+                       // Emit signal to update UI and the like
+                       g_signal_emit_by_name(G_OBJECT(omp_window), 
OMP_EVENT_PLAYLIST_TRACK_CHANGED);
+
                        if (was_playing) omp_playback_play();
 
                } else {
@@ -405,7 +406,6 @@
 /**
  * Moves one track forward in playlist
  * @return TRUE if a new track is to be played, FALSE if current track didn't 
change
- * @todo Shuffle mode, repeat
  * @todo Will cause an infinite loop if playlist only consists of tracks that 
can't be played and player is in shuffle mode
  */
 gboolean
@@ -492,12 +492,12 @@
                // Update session
                omp_session_set_track_id(omp_playlist_current_track_id);
 
-               // Emit signal to update UI and the like
-               g_signal_emit_by_name(G_OBJECT(omp_window), 
OMP_EVENT_PLAYLIST_TRACK_CHANGED);
-
                // Load track and start playing if needed
                if (omp_playlist_load_current_track())
                {
+                       // Emit signal to update UI and the like
+                       g_signal_emit_by_name(G_OBJECT(omp_window), 
OMP_EVENT_PLAYLIST_TRACK_CHANGED);
+
                        if (was_playing) omp_playback_play();
 
                } else {
@@ -531,7 +531,7 @@
 
 /**
  * Updates the track's artist information in the playlist on incoming tag data
- * @note This is our way of caching metadata information so we can display it 
in the playlist editor
+ * @note This is also our way of caching metadata information so we can 
display it in the playlist editor
  * @param instance Ignored
  * @param title Artist of currently played track
  * @param user_data Ignored
@@ -539,46 +539,27 @@
 void
 omp_playlist_process_tag_artist_change(gpointer instance, gchar *artist, 
gpointer user_data)
 {
-       gchar **tokens;
-
        // Now that we have received metadata information we might also have 
the track duration ready
        omp_playlist_update_track_duration();
 
        if (!omp_playlist_current_track) return;
 
-       // Set preliminary title if nothing was set at all
-       if (!omp_playlist_current_track->title)
+       if (!omp_playlist_current_track->creator)
        {
-               omp_playlist_current_track->title = g_strdup_printf(_("%s - 
[unknown title]"), artist);
-               return;
-       }
+               omp_playlist_current_track->creator = g_strdup(artist);
 
-       // Split title into artist/title to see if we need to replace the 
artist part
-       /// @todo Make unicode safe
-       tokens = g_strsplit(omp_playlist_current_track->title, " - ", 2);
-       if (!tokens) return;
+               // Save changes to disk
+               omp_playlist_save();
 
-       if (strcmp(tokens[0], _("[unknown artist]")) == 0)
-       {
-               // Yep, track artist was our placeholder, so we replace it
-               g_free(omp_playlist_current_track->title);
-               omp_playlist_current_track->title =
-                       g_strdup_printf("%s - %s", artist, tokens[1]);
+               // Notify UI of the change
+               g_signal_emit_by_name(G_OBJECT(omp_window), 
OMP_EVENT_PLAYLIST_TRACK_INFO_CHANGED,
+                       omp_playlist_current_track_id);
        }
-
-       g_strfreev(tokens);
-
-       // Save changes to disk
-       omp_playlist_save();
-
-       // Notify UI of the change
-       g_signal_emit_by_name(G_OBJECT(omp_window), 
OMP_EVENT_PLAYLIST_TRACK_INFO_CHANGED,
-               omp_playlist_current_track_id);
 }
 
 /**
  * Updates the track's artist information in the playlist on incoming tag data
- * @note This is our way of caching metadata information so we can display it 
in the playlist editor
+ * @note This is also our way of caching metadata information so we can 
display it in the playlist editor
  * @param instance Ignored
  * @param title Song title of currently played track
  * @param user_data Ignored
@@ -586,41 +567,30 @@
 void
 omp_playlist_process_tag_title_change(gpointer instance, gchar *title, 
gpointer user_data)
 {
-       gchar **tokens;
-
        // Now that we have received metadata information we might also have 
the track duration ready
        omp_playlist_update_track_duration();
 
        if (!omp_playlist_current_track) return;
 
-       // Set preliminary title if nothing was set at all
-       if (!omp_playlist_current_track->title)
+       if (
+                       (!omp_playlist_current_track->title) ||
+                       (omp_playlist_current_track->title_is_preliminary)
+                )
        {
-               omp_playlist_current_track->title = g_strdup_printf("[unknown 
artist] - %s", title);
-               return;
-       }
+               if (omp_playlist_current_track->title)
+                       g_free(omp_playlist_current_track->title);
 
-       // Split title into artist/title to see if we need to replace the title 
part
-       /// @todo Make unicode safe
-       tokens = g_strsplit(omp_playlist_current_track->title, " - ", 2);
-       if (!tokens) return;
+               omp_playlist_current_track->title_is_preliminary = FALSE;
 
-       if (strcmp(tokens[1], _("[unknown title]")) == 0)
-       {
-               // Yep, track title was our placeholder, so we replace it
-               g_free(omp_playlist_current_track->title);
-               omp_playlist_current_track->title =
-                       g_strdup_printf("%s - %s", tokens[0], title);
-       }
+               omp_playlist_current_track->title = g_strdup(title);
 
-       g_strfreev(tokens);
+               // Save changes to disk
+               omp_playlist_save();
 
-       // Save changes to disk
-       omp_playlist_save();
-
-       // Notify UI of the change
-       g_signal_emit_by_name(G_OBJECT(omp_window), 
OMP_EVENT_PLAYLIST_TRACK_INFO_CHANGED,
-               omp_playlist_current_track_id);
+               // Notify UI of the change
+               g_signal_emit_by_name(G_OBJECT(omp_window), 
OMP_EVENT_PLAYLIST_TRACK_INFO_CHANGED,
+                       omp_playlist_current_track_id);
+       }
 }
 
 /**
@@ -637,9 +607,8 @@
        duration = omp_playback_get_track_length();
        if ( (duration > 0) && (duration != 
omp_playlist_current_track->duration) )
        {
-// @note BUGGY
-//             omp_playlist_current_track->duration = duration;
-//             omp_playlist_save();
+               omp_playlist_current_track->duration = duration;
+               omp_playlist_save();
 
                // Notify UI of the change
                g_signal_emit_by_name(G_OBJECT(omp_window), 
OMP_EVENT_PLAYLIST_TRACK_INFO_CHANGED,
@@ -648,6 +617,52 @@
 }
 
 /**
+ * Sets current track's meta data from the URI unless the playlist already has 
meta data available
+ * @todo Unicode support
+ */
+void
+omp_playlist_set_preliminary_metadata(gchar *track_uri)
+{
+       UriParserStateA state;
+       UriUriA uri;
+       UriPathSegmentA *segment;
+       gchar *title = NULL;
+
+       state.uri = &uri;
+
+       g_return_if_fail(omp_playlist_current_track);
+
+       if (uriParseUriA(&state, track_uri) != 0)
+       {
+               #ifdef DEBUG
+                       g_printerr("UriParser could not parse URI %s\n", 
track_uri);
+               #endif
+               return;
+       }
+
+       // The last part of the URI path is the file name of the request - 
which we want
+       segment = uri.pathTail;
+       title = get_base_file_name((gchar*)segment->text.first);
+       uriUnescapeInPlaceA(title);
+
+       // Set preliminary metadata if necessary
+       if (!omp_playlist_current_track->title)
+       {
+               omp_playlist_current_track->title = g_strdup(title);
+               omp_playlist_current_track->title_is_preliminary = TRUE;
+               omp_playlist_save();
+
+               // Notify UI of the change
+               g_signal_emit_by_name(G_OBJECT(omp_window), 
OMP_EVENT_PLAYLIST_TRACK_INFO_CHANGED,
+                       omp_playlist_current_track_id);
+       }
+
+       g_free(title);
+
+       uriFreeUriMembersA(&uri);
+}
+
+/**
  * Uses the URI(s) and metadata information of a track to locate the resource 
to play, then returns a playable URI
  * @return URI of a playable resource
  * @note If the URI of the found resource is not in the track's locations list 
already it is added and the playlist saved
@@ -702,10 +717,15 @@
        if (track_uri)
        {
                track_loaded = omp_playback_load_track_from_uri(track_uri);
-               g_free(track_uri);
 
+               // Maybe we already know the new track duration
                omp_playlist_update_track_duration();
 
+               // Obtain preliminary track title from URI if needed
+               omp_playlist_set_preliminary_metadata(track_uri);
+
+               g_free(track_uri);
+
                return track_loaded;
        }
 
@@ -715,19 +735,23 @@
 /**
  * Retrieves a track's meta data if possible
  * @param track_id Track ID to get meta data of, starting at 0
+ * @param artist Destination for the artist string, can be NULL; must be freed 
after use
  * @param title Destination for the title string, can be NULL; must be freed 
after use
  * @param duration Destination for the track duration (in milliseconds), can 
be NULL
  * @todo List walking
  */
 void
-omp_playlist_get_track_info(guint track_id, gchar **title, guint *duration)
+omp_playlist_get_track_info(guint track_id, gchar **artist, gchar **title, 
gulong *duration)
 {
        if (track_id == omp_playlist_current_track_id)
        {
+               if (!omp_playlist_current_track) return;
+
+               if (artist) *artist = 
g_strdup(omp_playlist_current_track->creator);
                if (title) *title = g_strdup(omp_playlist_current_track->title);
 
-               // Again, spiff's internal duration is given in milliseconds
-               if (duration) *duration = omp_playlist_current_track->duration;
+               if (duration) *duration =
+                       (omp_playlist_current_track->duration > 0) ? 
omp_playlist_current_track->duration : 0;
 
        } else {
 
@@ -841,36 +865,47 @@
 }
 
 /**
- * Utility function that extracts a playlist's name from its file name
- * @param playlist_file File name to extract title from, can contain a path
+ * Utility function that removes the path and extension of a file name
+ * @param file_name File name to extract title from, can contain a path
  * @return String holding the title, must be freed after use
  * @todo Make unicode safe
  * @note Yes, this is quick'n'dirty. It will be replaced.
  */
 gchar *
-get_playlist_title(gchar *playlist_file)
+get_base_file_name(gchar *file_name)
 {
-       gchar title[256];
+       gchar base[256];
        guint i, j, last_delim, extension_pos;
 
        // Find last directory delimiter
        last_delim = 0;
-       for (i=0; playlist_file[i]; i++)
+       for (i=0; file_name[i]; i++)
        {
-               if (playlist_file[i] == '/') last_delim = i+1;
+               if (file_name[i] == '/') last_delim = i+1;
        }
 
        // Find file extension
-       for(extension_pos = strlen(playlist_file);
-               (extension_pos) && (playlist_file[extension_pos] != '.');
+       for(extension_pos = strlen(file_name);
+               (extension_pos) && (file_name[extension_pos] != '.');
                extension_pos--);
 
        // Extract title
        for (j=0, i=last_delim; i<extension_pos; i++)
        {
-               title[j++] = playlist_file[i];
+               base[j++] = file_name[i];
        }
-       title[j] = 0;
+       base[j] = 0;
        
-       return g_strdup((gchar *)&title);
+       return g_strdup((gchar *)&base);
 }
+
+/**
+ * Utility function that extracts a playlist's name from its file name
+ * @param playlist_file File name to extract title from, can contain a path
+ * @return String holding the title, must be freed after use
+ */
+gchar *
+get_playlist_title(gchar *playlist_file)
+{
+       return get_base_file_name(playlist_file);
+}

Modified: 
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/playlist.h
===================================================================
--- 
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/playlist.h    
    2007-09-01 09:37:39 UTC (rev 2881)
+++ 
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/playlist.h    
    2007-09-01 11:12:10 UTC (rev 2882)
@@ -83,7 +83,7 @@
 
 gchar *omp_playlist_resolve_track(omp_spiff_track *track);
 gboolean omp_playlist_load_current_track();
-void omp_playlist_get_track_info(guint track_id, gchar **title, guint 
*duration);
+void omp_playlist_get_track_info(guint track_id, gchar **artist, gchar 
**title, gulong *duration);
 void omp_playlist_update_track_count();
 
 omp_playlist_iter *omp_playlist_init_iterator();
@@ -92,6 +92,7 @@
 void omp_playlist_advance_iter(omp_playlist_iter *iter);
 gboolean omp_playlist_iter_finished(omp_playlist_iter *iter);
 
+gchar *get_base_file_name(gchar *file_name);
 gchar *get_playlist_title(gchar *playlist_file);
 
 #endif

Modified: 
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/playlist_page.c
===================================================================
--- 
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/playlist_page.c
   2007-09-01 09:37:39 UTC (rev 2881)
+++ 
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/playlist_page.c
   2007-09-01 11:12:10 UTC (rev 2882)
@@ -341,7 +341,7 @@
        input_box = gtk_hbox_new(FALSE, 0);
        omp_playlist_page_entry = gtk_entry_new();
        button = gtk_button_new();
-       image = gtk_image_new_from_icon_name("gtk-add", GTK_ICON_SIZE_BUTTON);
+       image = gtk_image_new_from_icon_name("gtk-add", GTK_ICON_SIZE_MENU);
        gtk_container_add(GTK_CONTAINER(button), GTK_WIDGET(image));
 
        g_signal_connect(G_OBJECT(button), "clicked", 
G_CALLBACK(omp_playlist_page_add_list), NULL);




--- End Message ---
_______________________________________________
commitlog mailing list
[email protected]
http://lists.openmoko.org/mailman/listinfo/commitlog

Reply via email to