annotate src/vorbis/vcupdate.c @ 3138:8e26022bb814

aac: handle premature EOF on shoutcast streams more gracefully. in combination with the neon work, we no longer have a problem. (closes #57)
author William Pitcock <nenolod@atheme.org>
date Thu, 07 May 2009 11:14:36 -0500
parents 3134a0987162
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2209
190cc25a8510 hmmm... this file doesn't contain BMP code anymore
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2208
diff changeset
1 /* Audacious - Cross-platform multimedia player
190cc25a8510 hmmm... this file doesn't contain BMP code anymore
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2208
diff changeset
2 * Copyright (C) 2005-2007 Audacious development team
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
3 *
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
4 * This program is free software; you can redistribute it and/or
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
5 * modify it under the terms of the GNU General Public License
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
6 * as published by the Free Software Foundation; either version 2
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
7 * of the License, or (at your option) any later version.
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
8 *
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
9 * This program is distributed in the hope that it will be useful,
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
12 * GNU General Public License for more details.
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
13 *
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
14 * You should have received a copy of the GNU General Public License
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
15 * along with this program; if not, write to the Free Software
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
17 * 02110-1301, USA.
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
18 *
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
19 */
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
20
1777
4a200593472d vorbis: Mk2
William Pitcock <nenolod@atheme.org>
parents: 1677
diff changeset
21 #include "config.h"
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
22
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
23 #include <glib.h>
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
24 #include <gtk/gtk.h>
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
25 #include <ogg/ogg.h>
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
26 #include <vorbis/codec.h>
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
27 #include <vorbis/vorbisfile.h>
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
28
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
29 #include <math.h>
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
30 #include <stdlib.h>
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
31 #include <string.h>
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
32
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
33 #include <unistd.h>
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
34
2971
3134a0987162 - changed include path from audacious to audlegacy.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 2576
diff changeset
35 #include <audlegacy/plugin.h>
3134a0987162 - changed include path from audacious to audlegacy.
Yoshiki Yazawa <yaz@honeyplanet.jp>
parents: 2576
diff changeset
36 #include <audlegacy/i18n.h>
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
37
2208
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
38 #include <mowgli.h>
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
39
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
40 #include "vorbis.h"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
41 #include "vcedit.h"
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
42
2208
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
43 static gboolean write_and_pivot_files(vcedit_state * state);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
44
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
45 extern GMutex *vf_mutex;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
46
2208
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
47 static mowgli_dictionary_t *
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
48 dictionary_from_vorbis_comment(vorbis_comment * vc)
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
49 {
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
50 mowgli_dictionary_t *dict;
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
51 gint i;
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
52 gchar *val;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
53
2208
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
54 dict = mowgli_dictionary_create(g_ascii_strcasecmp);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
55
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
56 for (i = 0; i < vc->comments; i++) {
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
57 gchar **frags;
2208
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
58
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
59 AUDDBG("%s\n", vc->user_comments[i]);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
60 frags = g_strsplit(vc->user_comments[i], "=", 2);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
61
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
62 /* FIXME: need more rigorous checks to guard against
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
63 borqued comments */
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
64
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
65 /* No RHS? */
2208
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
66 val = frags[1] ? frags[1] : "";
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
67
2208
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
68 mowgli_dictionary_add(dict, frags[0], g_strdup(val));
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
69
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
70 g_strfreev(frags); /* Don't use g_free() for string lists! --eugene */
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
71 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
72
2208
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
73 return dict;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
74 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
75
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
76 static void
2208
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
77 dictionary_to_vorbis_comment(vorbis_comment * vc, mowgli_dictionary_t * dict)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
78 {
2208
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
79 mowgli_dictionary_iteration_state_t state;
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
80 gchar *field;
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
81
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
82 vorbis_comment_clear(vc);
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
83
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
84 MOWGLI_DICTIONARY_FOREACH(field, &state, dict) {
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
85 vorbis_comment_add_tag(vc, state.cur->key, field);
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
86 }
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
87 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
88
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
89 static void
2208
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
90 insert_str_tuple_field_to_dictionary(Tuple *tuple, int fieldn, mowgli_dictionary_t *dict, char *key)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
91 {
2208
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
92
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
93 if(mowgli_dictionary_find(dict, key) != NULL) g_free(mowgli_dictionary_delete(dict, key));
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
94
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
95 gchar *tmp = (gchar*)aud_tuple_get_string(tuple, fieldn, NULL);
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
96 if(tmp != NULL && strlen(tmp) != 0) mowgli_dictionary_add(dict, key, g_strdup(tmp));
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
97 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
98
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
99 static void
2208
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
100 insert_int_tuple_field_to_dictionary(Tuple *tuple, int fieldn, mowgli_dictionary_t *dict, char *key)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
101 {
2208
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
102 int val;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
103
2208
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
104 if(mowgli_dictionary_find(dict, key) != NULL) g_free(mowgli_dictionary_delete(dict, key));
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
105
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
106 if(aud_tuple_get_value_type(tuple, fieldn, NULL) == TUPLE_INT && (val = aud_tuple_get_int(tuple, fieldn, NULL)) >= 0) {
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
107 gchar *tmp = g_strdup_printf("%d", val);
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
108 mowgli_dictionary_add(dict, key, tmp);
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
109 }
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
110 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
111
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
112 static void
2208
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
113 destroy_cb(mowgli_dictionary_elem_t *delem, void *privdata)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
114 {
2208
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
115 g_free(delem->data);
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
116 }
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
117
2208
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
118 gboolean
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
119 vorbis_update_song_tuple (Tuple *tuple, VFSFile *fd)
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
120 {
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
121
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
122 vcedit_state *state;
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
123 vorbis_comment *comment;
2208
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
124 mowgli_dictionary_t *dict;
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
125 gboolean ret;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
126
2208
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
127 if(!tuple || !fd) return FALSE;
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
128
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
129 g_mutex_lock(vf_mutex);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
130
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
131 state = vcedit_new_state();
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
132
2208
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
133 if(vcedit_open(state, fd) < 0) {
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
134 vcedit_clear(state);
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
135 g_mutex_unlock(vf_mutex);
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
136 return FALSE;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
137 }
2208
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
138
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
139 comment = vcedit_comments(state);
2208
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
140 dict = dictionary_from_vorbis_comment(comment);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
141
2208
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
142 insert_str_tuple_field_to_dictionary(tuple, FIELD_TITLE, dict, "title");
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
143 insert_str_tuple_field_to_dictionary(tuple, FIELD_ARTIST, dict, "artist");
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
144 insert_str_tuple_field_to_dictionary(tuple, FIELD_ALBUM, dict, "album");
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
145 insert_str_tuple_field_to_dictionary(tuple, FIELD_COMMENT, dict, "comment");
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
146 insert_str_tuple_field_to_dictionary(tuple, FIELD_GENRE, dict, "genre");
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
147
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
148 insert_int_tuple_field_to_dictionary(tuple, FIELD_YEAR, dict, "date");
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
149 insert_int_tuple_field_to_dictionary(tuple, FIELD_TRACK_NUMBER, dict, "tracknumber");
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
150
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
151 dictionary_to_vorbis_comment(comment, dict);
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
152 mowgli_dictionary_destroy(dict, destroy_cb, NULL);
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
153
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
154 ret = write_and_pivot_files(state);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
155
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
156 vcedit_clear(state);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
157 g_mutex_unlock(vf_mutex);
2208
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
158
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
159 return ret;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
160 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
161
2208
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
162 /* from stdio VFS plugin */
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
163 static gchar *
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
164 aud_vfs_stdio_urldecode_path(const gchar * encoded_path)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
165 {
2208
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
166 const gchar *cur, *ext;
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
167 gchar *path, *tmp;
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
168 gint realchar;
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
169
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
170 if (!encoded_path)
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
171 return NULL;
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
172
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
173 if (!aud_str_has_prefix_nocase(encoded_path, "file:"))
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
174 return NULL;
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
175
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
176 cur = encoded_path + 5;
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
177
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
178 if (aud_str_has_prefix_nocase(cur, "//localhost"))
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
179 cur += 11;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
180
2208
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
181 if (*cur == '/')
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
182 while (cur[1] == '/')
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
183 cur++;
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
184
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
185 tmp = g_malloc0(strlen(cur) + 1);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
186
2208
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
187 while ((ext = strchr(cur, '%')) != NULL) {
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
188 strncat(tmp, cur, ext - cur);
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
189 ext++;
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
190 cur = ext + 2;
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
191 if (!sscanf(ext, "%2x", &realchar)) {
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
192 /* Assume it is a literal '%'. Several file
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
193 * managers send unencoded file: urls on drag
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
194 * and drop. */
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
195 realchar = '%';
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
196 cur -= 2;
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
197 }
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
198 tmp[strlen(tmp)] = realchar;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
199 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
200
2208
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
201 path = g_strconcat(tmp, cur, NULL);
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
202 g_free(tmp);
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
203 return path;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
204 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
205
2208
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
206 gboolean
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
207 write_and_pivot_files(vcedit_state * state)
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
208 {
2208
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
209 gint retval;
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
210 gchar *tmpfn, *unq_tmpfn, *unq_in;
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
211 VFSFile *out;
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
212
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
213 tmpfn = g_strdup_printf("%s.XXXXXX", ((VFSFile*)state->in)->uri);
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
214 mktemp(tmpfn);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
215
2208
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
216 AUDDBG("creating temp file: %s\n", tmpfn);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
217
1978
fa9f85cebade s/vfs_/aud_vfs_/g
William Pitcock <nenolod@atheme.org>
parents: 1954
diff changeset
218 if ((out = aud_vfs_fopen(tmpfn, "wb")) == NULL) {
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
219 g_free(tmpfn);
2208
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
220 AUDDBG("fileinfo.c: couldn't create temp file, %s\n", tmpfn);
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
221 return FALSE;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
222 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
223
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
224 if (vcedit_write(state, out) < 0) {
2208
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
225 g_free(tmpfn);
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
226 aud_vfs_fclose(out);
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
227 AUDDBG("vcedit_write: %s\n", state->lasterror);
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
228 return FALSE;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
229 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
230
2208
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
231 aud_vfs_fclose(out);
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
232
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
233 unq_tmpfn = aud_vfs_stdio_urldecode_path(tmpfn);
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
234 unq_in = aud_vfs_stdio_urldecode_path(((VFSFile*)state->in)->uri);
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
235
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
236 if((retval = rename(unq_tmpfn, unq_in)) == 0) {
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
237 AUDDBG("fileinfo.c: file %s renamed successfully to %s\n", unq_tmpfn, unq_in);
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
238 } else {
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
239 remove(unq_tmpfn);
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
240 AUDDBG("fileinfo.c: couldn't rename file\n");
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
241 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
242
2208
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
243 g_free(unq_in);
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
244 g_free(unq_tmpfn);
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
245 g_free(tmpfn);
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
246
2208
201a47338baf vorbis: removed fileinfo dialog, switched to mowgli_dictionary, some fixes
Eugene Zagidullin <e.asphyx@gmail.com>
parents: 2050
diff changeset
247 return retval == 0;
0
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
248 }
13389e613d67 [svn] - initial import of audacious-plugins tree (lots to do)
nenolod
parents:
diff changeset
249