Revision: 1646
http://gtkpod.svn.sourceforge.net/gtkpod/?rev=1646&view=rev
Author: jcsjcs
Date: 2007-07-13 23:58:44 -0700 (Fri, 13 Jul 2007)
Log Message:
-----------
* src/mp3file.[ch]: moved reading of default tags to
id3_read_tags()
* src/flacfile.c: fallback on ID3 tags if no vorbis comments
are available.
Modified Paths:
--------------
gtkpod/trunk/ChangeLog_detailed
gtkpod/trunk/src/flacfile.c
gtkpod/trunk/src/mp3file.c
gtkpod/trunk/src/mp3file.h
Modified: gtkpod/trunk/ChangeLog_detailed
===================================================================
--- gtkpod/trunk/ChangeLog_detailed 2007-07-14 06:09:22 UTC (rev 1645)
+++ gtkpod/trunk/ChangeLog_detailed 2007-07-14 06:58:44 UTC (rev 1646)
@@ -6,6 +6,12 @@
* src/display_tracks.c (tm_cell_toggled): removed "default"
case to make sure newly added fields are not forgotten.
+ * src/mp3file.[ch]: moved reading of default tags to
+ id3_read_tags()
+
+ * src/flacfile.c: fallback on ID3 tags if no vorbis comments
+ are available.
+
2007-07-13 P.G. Richardson <phantom_sf at users.sourceforge.net>
* src/display_coverart.c
Modified: gtkpod/trunk/src/flacfile.c
===================================================================
--- gtkpod/trunk/src/flacfile.c 2007-07-14 06:09:22 UTC (rev 1645)
+++ gtkpod/trunk/src/flacfile.c 2007-07-14 06:58:44 UTC (rev 1646)
@@ -64,13 +64,10 @@
}
else
{
+ gboolean flac_metadata_ok = FALSE;
+
track = gp_track_new ();
- track->description = g_strdup ("FLAC audio file");
- track->bitrate = stream_data.data.stream_info.bits_per_sample/1000;
- track->samplerate = stream_data.data.stream_info.sample_rate;
- track->tracklen = stream_data.data.stream_info.total_samples /
(stream_data.data.stream_info.sample_rate / 1000);
-
if (prefs_get_int("readtags"))
{
if (!FLAC__metadata_get_tags (flacFileName, &tags))
@@ -85,6 +82,11 @@
else {
gint i;
+ if (tags->data.vorbis_comment.num_comments > 0)
+ {
+ flac_metadata_ok = TRUE;
+ }
+
for (i = 0 ; i < tags->data.vorbis_comment.num_comments ; i++)
{
gchar *tag =
(gchar*)tags->data.vorbis_comment.comments[i].entry;
@@ -130,7 +132,19 @@
}
FLAC__metadata_object_delete (tags);
+
+ if (!flac_metadata_ok)
+ { /* fall back on ID3 */
+ id3_read_tags (flacFileName, track);
+ }
}
+
+ g_free (track->description);
+ track->description = g_strdup ("FLAC audio file");
+
+ track->bitrate = stream_data.data.stream_info.bits_per_sample/1000;
+ track->samplerate = stream_data.data.stream_info.sample_rate;
+ track->tracklen = stream_data.data.stream_info.total_samples /
(stream_data.data.stream_info.sample_rate / 1000);
}
return track;
Modified: gtkpod/trunk/src/mp3file.c
===================================================================
--- gtkpod/trunk/src/mp3file.c 2007-07-14 06:09:22 UTC (rev 1645)
+++ gtkpod/trunk/src/mp3file.c 2007-07-14 06:58:44 UTC (rev 1646)
@@ -1,4 +1,4 @@
-/* Time-stamp: <2007-06-26 00:39:11 jcs>
+/* Time-stamp: <2007-07-14 15:47:57 jcs>
|
| Copyright (C) 2002-2005 Jorg Schuler <jcsjcs at users sourceforge net>
| Part of the gtkpod project.
@@ -1300,7 +1300,7 @@
* Reads id3v1.x / id3v2 apic data
* @returns: TRUE on success, else FALSE.
*/
-static gboolean id3_apic_read (gchar *filename,
+static gboolean id3_apic_read (const gchar *filename,
guchar **image_data, gsize *image_data_len)
{
struct id3_file *id3file;
@@ -1394,7 +1394,7 @@
* stays to NULL
* @returns: TRUE on success, else FALSE.
*/
-gboolean id3_tag_read (gchar *filename, File_Tag *tag)
+gboolean id3_tag_read (const gchar *filename, File_Tag *tag)
{
struct id3_file *id3file;
struct id3_tag *id3tag;
@@ -2365,7 +2365,6 @@
}
-
/**
* mp3_read_gapless:
*
@@ -2422,52 +2421,20 @@
}
-
-/* ----------------------------------------------------------------------
-
- From here starts original gtkpod code
-
----------------------------------------------------------------------- */
-
-/* Return a Track structure with all information read from the mp3
- file filled in */
-Track *mp3_get_file_info (gchar *name)
+/* Read ID3 tags of filename @name into track structure @track */
+/* Return value: TRUE if tags could be read, FALSE if an error
+ occured */
+gboolean id3_read_tags (const gchar *name, Track *track)
{
- Track *track = NULL;
File_Tag filetag;
- MP3Info *mp3i=NULL;
- FILE *file;
- guchar *image_data = NULL;
- gsize image_data_len = 0;
- g_return_val_if_fail (name, NULL);
+ g_return_val_if_fail (name && track, FALSE);
- /* Attempt to open the file */
- file = fopen (name, "r");
- if (file)
+ if (id3_tag_read (name, &filetag))
{
- mp3i = g_malloc0 (sizeof (MP3Info));
- mp3i->filename = name;
- mp3i->file = file;
- get_mp3_info (mp3i);
- mp3i->file = NULL;
- fclose (file);
- }
- else
- {
- gchar *fbuf = charset_to_utf8 (name);
- gtkpod_warning(_("ERROR while opening file: '%s' (%s).\n"),
- fbuf, g_strerror(errno));
- g_free (fbuf);
- return NULL;
- }
+ guchar *image_data = NULL;
+ gsize image_data_len = 0;
- track = gp_track_new ();
- track->filetype = g_strdup ("MPEG audio file");
-
- if (prefs_get_int("readtags") && (id3_tag_read (name, &filetag) == TRUE))
- {
-
if (filetag.album)
{
track->album = filetag.album;
@@ -2622,20 +2589,68 @@
{
track->lyrics_flag = 0x00;
}
- }
- if (prefs_get_int("coverart_apic") &&
- (id3_apic_read (name, &image_data, &image_data_len) == TRUE))
- {
- if (image_data)
+ if (prefs_get_int("coverart_apic") &&
+ (id3_apic_read (name, &image_data, &image_data_len) == TRUE))
{
- gp_track_set_thumbnails_from_data (track,
- image_data,
- image_data_len);
- g_free (image_data);
+ if (image_data)
+ {
+ gp_track_set_thumbnails_from_data (track,
+ image_data,
+ image_data_len);
+ g_free (image_data);
+ }
}
+ return TRUE;
}
+ return FALSE;
+}
+
+/* ----------------------------------------------------------------------
+
+ From here starts original gtkpod code
+
+---------------------------------------------------------------------- */
+
+/* Return a Track structure with all information read from the mp3
+ file filled in */
+Track *mp3_get_file_info (gchar *name)
+{
+ Track *track = NULL;
+ MP3Info *mp3i=NULL;
+ FILE *file;
+
+ g_return_val_if_fail (name, NULL);
+
+ /* Attempt to open the file */
+ file = fopen (name, "r");
+ if (file)
+ {
+ mp3i = g_malloc0 (sizeof (MP3Info));
+ mp3i->filename = name;
+ mp3i->file = file;
+ get_mp3_info (mp3i);
+ mp3i->file = NULL;
+ fclose (file);
+ }
+ else
+ {
+ gchar *fbuf = charset_to_utf8 (name);
+ gtkpod_warning(_("ERROR while opening file: '%s' (%s).\n"),
+ fbuf, g_strerror(errno));
+ g_free (fbuf);
+ return NULL;
+ }
+
+ track = gp_track_new ();
+ track->filetype = g_strdup ("MPEG audio file");
+
+ if (prefs_get_int("readtags"))
+ {
+ id3_read_tags (name, track);
+ }
+
mp3_read_soundcheck (name, track);
mp3_read_gapless (name, track);
Modified: gtkpod/trunk/src/mp3file.h
===================================================================
--- gtkpod/trunk/src/mp3file.h 2007-07-14 06:09:22 UTC (rev 1645)
+++ gtkpod/trunk/src/mp3file.h 2007-07-14 06:58:44 UTC (rev 1646)
@@ -1,4 +1,4 @@
-/* Time-stamp: <2006-06-11 13:57:01 jcs>
+/* Time-stamp: <2007-07-14 15:55:29 jcs>
|
| Copyright (C) 2002-2005 Jorg Schuler <jcsjcs at users sourceforge net>
| Part of the gtkpod project.
@@ -37,4 +37,5 @@
gboolean mp3_read_soundcheck (gchar *path, Track *track);
gboolean mp3_read_gapless (gchar *path, Track *track);
+gboolean id3_read_tags (const gchar *name, Track *track);
#endif
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
gtkpod-cvs2 mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gtkpod-cvs2