[easytag] Refactor Ogg file ID3v2 skipping logic
- From: David King <davidk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [easytag] Refactor Ogg file ID3v2 skipping logic
- Date: Fri, 7 Nov 2014 08:37:32 +0000 (UTC)
commit c60fd9f91e9e106c20d9d322884861b9bbe19002
Author: David King <amigadave amigadave com>
Date: Fri Nov 7 08:18:14 2014 +0000
Refactor Ogg file ID3v2 skipping logic
Mark the Ogg file as modified while reading, if it has an ID3v2 tag, as
it will be removed while saving. Remove a double unref of the input
stream in an error path. Tidy up several obsolete seeks.
src/tags/ogg_tag.c | 54 +++++++++++++++------------------------------------
1 files changed, 16 insertions(+), 38 deletions(-)
---
diff --git a/src/tags/ogg_tag.c b/src/tags/ogg_tag.c
index 24b6ed0..2143325 100644
--- a/src/tags/ogg_tag.c
+++ b/src/tags/ogg_tag.c
@@ -652,23 +652,17 @@ ogg_tag_read_file_tag (GFile *file,
g_free (filename);
{
- // Skip the id3v2 tag
+ /* Check for an unsupported ID3v2 tag. */
guchar tmp_id3[4];
- gulong id3v2size;
-
- // Check if there is an ID3v2 tag...
- if (!g_seekable_seek (G_SEEKABLE (istream), 0L, G_SEEK_SET, NULL, error))
- {
- goto err;
- }
if (g_input_stream_read (G_INPUT_STREAM (istream), tmp_id3, 4, NULL,
error) == 4)
{
- // Calculate ID3v2 length
- if (tmp_id3[0] == 'I' && tmp_id3[1] == 'D' && tmp_id3[2] == '3' && tmp_id3[3] < 0xFF)
+ /* Calculate ID3v2 length. */
+ if (tmp_id3[0] == 'I' && tmp_id3[1] == 'D' && tmp_id3[2] == '3'
+ && tmp_id3[3] < 0xFF)
{
- // id3v2 tag skipeer $49 44 33 yy yy xx zz zz zz zz [zz size]
+ /* ID3v2 tag skipper $49 44 33 yy yy xx zz zz zz zz [zz size]. */
/* Size is 6-9 position */
if (!g_seekable_seek (G_SEEKABLE (istream), 2, G_SEEK_CUR,
NULL, error))
@@ -679,35 +673,20 @@ ogg_tag_read_file_tag (GFile *file,
if (g_input_stream_read (G_INPUT_STREAM (istream), tmp_id3, 4,
NULL, error) == 4)
{
- id3v2size = 10 + ( (long)(tmp_id3[3]) | ((long)(tmp_id3[2]) << 7)
- | ((long)(tmp_id3[1]) << 14) | ((long)(tmp_id3[0]) << 21) );
+ gchar *path;
- if (!g_seekable_seek (G_SEEKABLE (istream), id3v2size,
- G_SEEK_SET, NULL, error))
- {
- goto err;
- }
+ path = g_file_get_path (file);
+ g_debug ("Ogg file '%s' contains an ID3v2 tag", path);
+ g_free (path);
- Log_Print (LOG_ERROR,
- _("The Ogg Vorbis file ā%sā contains an ID3v2 tag"),
- filename_utf8);
+ /* Mark the file as modified, so that the ID3 tag is removed
+ * upon saving. */
+ FileTag->saved = FALSE;
}
- else if (!g_seekable_seek (G_SEEKABLE (istream), 0L, G_SEEK_SET,
- NULL, error))
- {
- goto err;
- }
-
- }
- else if (!g_seekable_seek (G_SEEKABLE (istream), 0L, G_SEEK_SET,
- NULL, error))
- {
- goto err;
}
-
}
- else if (!g_seekable_seek (G_SEEKABLE (istream), 0L, G_SEEK_SET,
- NULL, error))
+
+ if (error && *error != NULL)
{
goto err;
}
@@ -747,7 +726,6 @@ ogg_tag_read_file_tag (GFile *file,
err:
g_assert (error == NULL || *error != NULL);
g_object_unref (istream);
- g_object_unref (istream);
g_free (filename_utf8);
return FALSE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]