Mercurial > audlegacy-plugins
annotate src/madplug/input.c @ 1465:db616ccdd40c
use tuple_free(x) in place of mowgli_object_unref(x)
| author | Giacomo Lozito <james@develia.org> |
|---|---|
| date | Sat, 11 Aug 2007 12:21:30 +0200 |
| parents | 4993976d7ed0 |
| children | eb0913bf54c3 |
| rev | line source |
|---|---|
|
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
1 /* |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
2 * mad plugin for audacious |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
3 * Copyright (C) 2005-2007 William Pitcock, Yoshiki Yazawa |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
4 * |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
5 * Portions derived from xmms-mad: |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
6 * Copyright (C) 2001-2002 Sam Clegg - See COPYING |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
7 * |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
8 * This program is free software; you can redistribute it and/or modify |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
9 * it under the terms of the GNU General Public License as published by |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
10 * the Free Software Foundation; under version 2 of the License. |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
11 * |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
12 * This program is distributed in the hope that it will be useful, |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
15 * GNU General Public License for more details. |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
16 * |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
17 * You should have received a copy of the GNU General Public License |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
18 * along with this program; if not, write to the Free Software |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
20 */ |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
21 |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
22 #include "config.h" |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
23 |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
24 #ifdef HAVE_ASSERT_H |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
25 #include <assert.h> |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
26 #endif /* HAVE_ASSERT_H */ |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
27 |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
28 #ifdef HAVE_SYS_TYPES_H |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
29 #include <sys/types.h> |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
30 #endif /* HAVE_SYS_TYPES_H */ |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
31 |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
32 #ifdef HAVE_SYS_SOCKET_H |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
33 #include <sys/socket.h> |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
34 #endif /* HAVE_SYS_SOCKET_H */ |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
35 |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
36 #ifdef HAVE_NETINET_IN_H |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
37 #include <netinet/in.h> |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
38 #endif /* HAVE_NETINET_IN_H */ |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
39 |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
40 #ifdef HAVE_ARPA_INET_H |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
41 #include <arpa/inet.h> |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
42 #endif /* HAVE_ARPA_INET_H */ |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
43 |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
44 #ifdef HAVE_NETDB_H |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
45 #include <netdb.h> |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
46 #endif /* HAVE_NETDB_H */ |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
47 |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
48 #ifdef HAVE_SYS_STAT_H |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
49 #include <sys/stat.h> |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
50 #endif /* HAVE_SYS_STAT_H */ |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
51 |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
52 #ifdef HAVE_SYS_TIME_H |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
53 #include <sys/time.h> |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
54 #endif /* HAVE_SYS_TIME_H */ |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
55 |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
56 #include <fcntl.h> |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
57 #include <errno.h> |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
58 #include <audacious/util.h> |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
59 |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
60 #include "input.h" |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
61 #include "replaygain.h" |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
62 |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
63 #define DIR_SEPARATOR '/' |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
64 #define HEADER_SIZE 256 |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
65 #define LINE_LENGTH 256 |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
66 |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
67 extern gboolean scan_file(struct mad_info_t *info, gboolean fast); |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
68 |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
69 /** |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
70 * init the mad_info_t struct. |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
71 */ |
|
1328
38fb3bb3e21e
- make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1277
diff
changeset
|
72 gboolean input_init(struct mad_info_t * info, const char *url, VFSFile *fd) |
|
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
73 { |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
74 #ifdef DEBUG |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
75 g_message("f: input_init"); |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
76 #endif |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
77 memset(info, 0, sizeof(struct mad_info_t)); |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
78 |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
79 info->fmt = FMT_S16_LE; |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
80 info->channels = -1; |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
81 info->mpeg_layer = -1; |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
82 info->size = -1; |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
83 info->freq = -1; |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
84 info->seek = -1; |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
85 info->duration = mad_timer_zero; |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
86 info->pos = mad_timer_zero; |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
87 info->url = g_strdup(url); |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
88 info->current_frame = 0; |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
89 info->frames = 0; |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
90 info->bitrate = 0; |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
91 info->vbr = 0; |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
92 info->mode = 0; |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
93 info->title = 0; |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
94 info->offset = 0; |
|
797
19e08e104ba6
[svn] - madplug: do not call set_info repeatedly in input_process_remote_metadata, only call it when the built title string actually differs from the previous one
giacomo
parents:
791
diff
changeset
|
95 info->prev_title = NULL; |
|
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
96 |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
97 info->replaygain_album_str = 0; |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
98 info->replaygain_track_str = 0; |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
99 info->replaygain_album_peak_str = 0; |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
100 info->replaygain_track_peak_str = 0; |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
101 info->mp3gain_undo_str = 0; |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
102 info->mp3gain_minmax_str = 0; |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
103 |
| 773 | 104 // from input_read_replaygain() |
| 105 info->has_replaygain = FALSE; | |
| 106 info->replaygain_album_scale = -1; | |
| 107 info->replaygain_track_scale = -1; | |
| 108 info->mp3gain_undo = -77; | |
| 109 info->mp3gain_minmax = -77; | |
| 110 | |
|
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
111 info->tuple = NULL; |
| 611 | 112 |
| 773 | 113 info->filename = g_strdup(url); |
|
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
114 |
|
1328
38fb3bb3e21e
- make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1277
diff
changeset
|
115 if(!fd){ |
|
38fb3bb3e21e
- make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1277
diff
changeset
|
116 info->infile = vfs_fopen(info->filename, "rb"); |
|
38fb3bb3e21e
- make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1277
diff
changeset
|
117 if (info->infile == NULL) { |
|
38fb3bb3e21e
- make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1277
diff
changeset
|
118 return FALSE; |
|
38fb3bb3e21e
- make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1277
diff
changeset
|
119 } |
| 611 | 120 } |
|
1328
38fb3bb3e21e
- make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1277
diff
changeset
|
121 else{ |
|
38fb3bb3e21e
- make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1277
diff
changeset
|
122 #ifdef DEBUG |
|
38fb3bb3e21e
- make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1277
diff
changeset
|
123 printf("input_init: vfs_dup\n"); |
|
38fb3bb3e21e
- make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1277
diff
changeset
|
124 #endif |
|
38fb3bb3e21e
- make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1277
diff
changeset
|
125 info->infile = vfs_dup(fd); |
|
38fb3bb3e21e
- make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1277
diff
changeset
|
126 } |
|
38fb3bb3e21e
- make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1277
diff
changeset
|
127 |
|
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
128 // obtain file size |
| 974 | 129 info->size = vfs_fsize(info->infile); |
|
727
b938fe96b20e
[svn] - ensure that info->remote is set if url begins with http:// so that metadata can be displayed.
yaz
parents:
706
diff
changeset
|
130 info->remote = info->size == 0 ? TRUE : FALSE; //proxy connection may result in non-zero size. |
|
768
1d3f70ac6b31
[svn] - remote metadata handling is moved into input_process_remote_metadata(). this function converts string into utf-8 if necessary (mainly for zina).
yaz
parents:
765
diff
changeset
|
131 if(audmad_is_remote((gchar *)url)) |
|
727
b938fe96b20e
[svn] - ensure that info->remote is set if url begins with http:// so that metadata can be displayed.
yaz
parents:
706
diff
changeset
|
132 info->remote = TRUE; |
|
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
133 |
|
997
e46b98155d5d
[svn] - fix a bug which counts number of frames twice in handling xing header.
yaz
parents:
974
diff
changeset
|
134 info->fileinfo_request = FALSE; |
|
e46b98155d5d
[svn] - fix a bug which counts number of frames twice in handling xing header.
yaz
parents:
974
diff
changeset
|
135 |
|
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
136 #ifdef DEBUG |
| 674 | 137 g_message("i: info->size = %lu", (long unsigned int)info->size); |
|
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
138 g_message("e: input_init"); |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
139 #endif |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
140 return TRUE; |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
141 } |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
142 |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
143 /* return length in letters */ |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
144 size_t mad_ucs4len(id3_ucs4_t *ucs) |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
145 { |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
146 id3_ucs4_t *ptr = ucs; |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
147 size_t len = 0; |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
148 |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
149 while(*ptr++ != 0) |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
150 len++; |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
151 |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
152 return len; |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
153 } |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
154 |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
155 /* duplicate id3_ucs4_t string. new string will be terminated with 0. */ |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
156 id3_ucs4_t *mad_ucs4dup(id3_ucs4_t *org) |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
157 { |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
158 id3_ucs4_t *new = NULL; |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
159 size_t len = mad_ucs4len(org); |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
160 |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
161 new = g_malloc0((len + 1) * sizeof(id3_ucs4_t)); |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
162 memcpy(new, org, len * sizeof(id3_ucs4_t)); |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
163 *(new + len) = 0; //terminate |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
164 |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
165 return new; |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
166 } |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
167 |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
168 #define BYTES(x) ((x) * sizeof(id3_ucs4_t)) |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
169 |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
170 id3_ucs4_t *mad_parse_genre(const id3_ucs4_t *string) |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
171 { |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
172 id3_ucs4_t *ret = NULL; |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
173 id3_ucs4_t *tmp = NULL; |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
174 id3_ucs4_t *genre = NULL; |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
175 id3_ucs4_t *ptr, *end, *tail, *tp; |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
176 size_t ret_len = 0; //num of ucs4 char! |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
177 size_t tmp_len = 0; |
| 674 | 178 size_t string_len = 0; |
|
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
179 gboolean is_num = TRUE; |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
180 |
|
699
14f80d61e855
[svn] - TCON frame without string crashes mad_parse_genre().
yaz
parents:
696
diff
changeset
|
181 if(!string) |
|
14f80d61e855
[svn] - TCON frame without string crashes mad_parse_genre().
yaz
parents:
696
diff
changeset
|
182 return NULL; |
|
14f80d61e855
[svn] - TCON frame without string crashes mad_parse_genre().
yaz
parents:
696
diff
changeset
|
183 |
| 674 | 184 string_len = mad_ucs4len((id3_ucs4_t *)string); |
| 185 tail = (id3_ucs4_t *)string + string_len; | |
|
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
186 |
|
675
1ea4cfb007e0
[svn] - if genre name is generated from number, it may exceed allocated memory block.
yaz
parents:
674
diff
changeset
|
187 if(BYTES(string_len + 1) > 1024) { |
|
1ea4cfb007e0
[svn] - if genre name is generated from number, it may exceed allocated memory block.
yaz
parents:
674
diff
changeset
|
188 ret = g_malloc0(BYTES(string_len + 1)); |
|
1ea4cfb007e0
[svn] - if genre name is generated from number, it may exceed allocated memory block.
yaz
parents:
674
diff
changeset
|
189 } |
|
1ea4cfb007e0
[svn] - if genre name is generated from number, it may exceed allocated memory block.
yaz
parents:
674
diff
changeset
|
190 else { |
|
1ea4cfb007e0
[svn] - if genre name is generated from number, it may exceed allocated memory block.
yaz
parents:
674
diff
changeset
|
191 ret = g_malloc0(1024); |
|
1ea4cfb007e0
[svn] - if genre name is generated from number, it may exceed allocated memory block.
yaz
parents:
674
diff
changeset
|
192 } |
|
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
193 |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
194 for(ptr = (id3_ucs4_t *)string; *ptr != 0 && ptr <= tail; ptr++) { |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
195 if(*ptr == '(') { |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
196 if(*(++ptr) == '(') { // escaped text like: ((something) |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
197 for(end = ptr; *end != ')' && *end != 0;) { // copy "(something)" |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
198 end++; |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
199 } |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
200 end++; //include trailing ')' |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
201 memcpy(ret, ptr, BYTES(end - ptr)); |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
202 ret_len += (end - ptr); |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
203 *(ret + ret_len) = 0; //terminate |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
204 ptr = end + 1; |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
205 } |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
206 else { |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
207 // reference to an id3v1 genre code |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
208 for(end = ptr; *end != ')' && *end != 0;) { |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
209 end++; |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
210 } |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
211 |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
212 tmp = g_malloc0(BYTES(end - ptr + 1)); |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
213 memcpy(tmp, ptr, BYTES(end - ptr)); |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
214 *(tmp + (end - ptr)) = 0; //terminate |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
215 ptr += end - ptr; |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
216 |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
217 genre = (id3_ucs4_t *)id3_genre_name((const id3_ucs4_t *)tmp); |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
218 |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
219 g_free(tmp); |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
220 tmp = NULL; |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
221 |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
222 tmp_len = mad_ucs4len(genre); |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
223 |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
224 memcpy(ret + BYTES(ret_len), genre, BYTES(tmp_len)); |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
225 |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
226 ret_len += tmp_len; |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
227 *(ret + ret_len) = 0; //terminate |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
228 } |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
229 } |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
230 else { |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
231 for(end = ptr; *end != '(' && *end != 0; ) { |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
232 end++; |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
233 } |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
234 // scan string to determine whether a genre code number or not |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
235 tp = ptr; |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
236 is_num = TRUE; |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
237 while(tp < end) { |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
238 if(*tp < '0' || *tp > '9') { // anything else than number appears. |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
239 is_num = FALSE; |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
240 break; |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
241 } |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
242 tp++; |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
243 } |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
244 if(is_num) { |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
245 #ifdef DEBUG |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
246 printf("is_num!\n"); |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
247 #endif |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
248 tmp = g_malloc0(BYTES(end - ptr + 1)); |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
249 memcpy(tmp, ptr, BYTES(end - ptr)); |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
250 *(tmp + (end - ptr)) = 0; //terminate |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
251 ptr += end - ptr; |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
252 |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
253 genre = (id3_ucs4_t *)id3_genre_name((const id3_ucs4_t *)tmp); |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
254 #ifdef DEBUG |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
255 printf("genre length = %d\n", mad_ucs4len(genre)); |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
256 #endif |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
257 g_free(tmp); |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
258 tmp = NULL; |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
259 |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
260 tmp_len = mad_ucs4len(genre); |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
261 |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
262 memcpy(ret + BYTES(ret_len), genre, BYTES(tmp_len)); |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
263 |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
264 ret_len += tmp_len; |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
265 *(ret + ret_len) = 0; //terminate |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
266 } |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
267 else { // plain text |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
268 #ifdef DEBUG |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
269 printf("plain!\n"); |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
270 printf("ret_len = %d\n", ret_len); |
| 674 | 271 printf("end - ptr = %d\n", BYTES(end - ptr)); |
|
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
272 #endif |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
273 memcpy(ret + BYTES(ret_len), ptr, BYTES(end - ptr)); |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
274 ret_len = ret_len + (end - ptr); |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
275 *(ret + ret_len) = 0; //terminate |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
276 ptr += (end - ptr); |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
277 } |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
278 } |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
279 } |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
280 return ret; |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
281 } |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
282 |
|
1428
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1328
diff
changeset
|
283 gchar *input_id3_get_string(struct id3_tag * tag, const gchar *frame_name) |
|
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
284 { |
|
618
a7a28782c1b0
[svn] - revise input_id3_get_string() to take encoding of field into account.
yaz
parents:
613
diff
changeset
|
285 gchar *rtn0 = NULL, *rtn = NULL; |
|
675
1ea4cfb007e0
[svn] - if genre name is generated from number, it may exceed allocated memory block.
yaz
parents:
674
diff
changeset
|
286 const id3_ucs4_t *string_const = NULL; |
|
1ea4cfb007e0
[svn] - if genre name is generated from number, it may exceed allocated memory block.
yaz
parents:
674
diff
changeset
|
287 id3_ucs4_t *string = NULL; |
|
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
288 struct id3_frame *frame; |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
289 union id3_field *field; |
|
618
a7a28782c1b0
[svn] - revise input_id3_get_string() to take encoding of field into account.
yaz
parents:
613
diff
changeset
|
290 int encoding = -1; |
|
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
291 |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
292 frame = id3_tag_findframe(tag, frame_name, 0); |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
293 if (!frame) |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
294 return NULL; |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
295 |
|
618
a7a28782c1b0
[svn] - revise input_id3_get_string() to take encoding of field into account.
yaz
parents:
613
diff
changeset
|
296 field = id3_frame_field(frame, 0); |
|
a7a28782c1b0
[svn] - revise input_id3_get_string() to take encoding of field into account.
yaz
parents:
613
diff
changeset
|
297 encoding = id3_field_gettextencoding(field); |
|
a7a28782c1b0
[svn] - revise input_id3_get_string() to take encoding of field into account.
yaz
parents:
613
diff
changeset
|
298 |
| 620 | 299 if (!strcmp(frame_name, ID3_FRAME_COMMENT)) |
|
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
300 field = id3_frame_field(frame, 3); |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
301 else |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
302 field = id3_frame_field(frame, 1); |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
303 |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
304 if (!field) |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
305 return NULL; |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
306 |
| 620 | 307 if (!strcmp(frame_name, ID3_FRAME_COMMENT)) |
|
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
308 string_const = id3_field_getfullstring(field); |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
309 else |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
310 string_const = id3_field_getstrings(field, 0); |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
311 |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
312 if (!string_const) |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
313 return NULL; |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
314 |
| 620 | 315 if (!strcmp(frame_name, ID3_FRAME_GENRE)) { |
| 645 | 316 string = mad_parse_genre(string_const); |
| 317 } | |
| 318 else { | |
| 319 string = mad_ucs4dup((id3_ucs4_t *)string_const); | |
|
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
320 } |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
321 |
| 674 | 322 if (!string) |
| 323 return NULL; | |
| 324 | |
|
618
a7a28782c1b0
[svn] - revise input_id3_get_string() to take encoding of field into account.
yaz
parents:
613
diff
changeset
|
325 switch (encoding) { |
|
a7a28782c1b0
[svn] - revise input_id3_get_string() to take encoding of field into account.
yaz
parents:
613
diff
changeset
|
326 case ID3_FIELD_TEXTENCODING_ISO_8859_1: |
| 645 | 327 rtn0 = (gchar *)id3_ucs4_latin1duplicate(string); |
|
687
6dd733e046fa
[svn] Revert r1456, this gives problems with some files with broken ID3-Tags.
js
parents:
685
diff
changeset
|
328 rtn = str_to_utf8(rtn0); |
| 645 | 329 g_free(rtn0); |
|
618
a7a28782c1b0
[svn] - revise input_id3_get_string() to take encoding of field into account.
yaz
parents:
613
diff
changeset
|
330 break; |
|
a7a28782c1b0
[svn] - revise input_id3_get_string() to take encoding of field into account.
yaz
parents:
613
diff
changeset
|
331 case ID3_FIELD_TEXTENCODING_UTF_8: |
|
a7a28782c1b0
[svn] - revise input_id3_get_string() to take encoding of field into account.
yaz
parents:
613
diff
changeset
|
332 default: |
| 645 | 333 rtn = (gchar *)id3_ucs4_utf8duplicate(string); |
|
618
a7a28782c1b0
[svn] - revise input_id3_get_string() to take encoding of field into account.
yaz
parents:
613
diff
changeset
|
334 break; |
|
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
335 } |
| 645 | 336 g_free((void *)string); |
|
618
a7a28782c1b0
[svn] - revise input_id3_get_string() to take encoding of field into account.
yaz
parents:
613
diff
changeset
|
337 |
|
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
338 #ifdef DEBUG |
|
618
a7a28782c1b0
[svn] - revise input_id3_get_string() to take encoding of field into account.
yaz
parents:
613
diff
changeset
|
339 g_print("i: string = %s\n", rtn); |
|
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
340 #endif |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
341 return rtn; |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
342 } |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
343 |
|
1428
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1328
diff
changeset
|
344 static void input_set_and_free_tag(struct id3_tag *tag, Tuple *tuple, const gchar *frame, const gchar *tuple_name) |
|
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1328
diff
changeset
|
345 { |
|
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1328
diff
changeset
|
346 gchar *scratch = input_id3_get_string(tag, frame); |
|
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1328
diff
changeset
|
347 |
|
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1328
diff
changeset
|
348 tuple_associate_string(tuple, tuple_name, scratch); |
|
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1328
diff
changeset
|
349 tuple_associate_string(tuple, frame, scratch); |
|
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1328
diff
changeset
|
350 |
|
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1328
diff
changeset
|
351 g_free(scratch); |
|
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1328
diff
changeset
|
352 } |
| 773 | 353 |
| 354 static void input_alloc_tag(struct mad_info_t *info) | |
| 355 { | |
|
1428
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1328
diff
changeset
|
356 Tuple *title_input; |
| 773 | 357 |
| 358 if (info->tuple == NULL) { | |
|
1428
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1328
diff
changeset
|
359 title_input = tuple_new(); |
| 773 | 360 info->tuple = title_input; |
|
1428
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1328
diff
changeset
|
361 tuple_associate_int(info->tuple, "length", -1); |
| 773 | 362 } |
| 363 else | |
| 364 title_input = info->tuple; | |
| 365 } | |
| 366 | |
|
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
367 /** |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
368 * read the ID3 tag |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
369 */ |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
370 static void input_read_tag(struct mad_info_t *info) |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
371 { |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
372 gchar *string = NULL; |
|
1277
e7cd962732cb
file_name and file_path in a tuple should be unescaped.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
997
diff
changeset
|
373 gchar *realfn = NULL; |
|
1428
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1328
diff
changeset
|
374 Tuple *title_input; |
|
791
91d2b302f479
[svn] - only perform vfs fseek against info::infile if it is available.
nenolod
parents:
789
diff
changeset
|
375 glong curpos = 0; |
|
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
376 |
|
765
2430c9773fa7
[svn] - determine whether stream is seekable or not by checking duration. it is safe to use with proxy.
yaz
parents:
755
diff
changeset
|
377 #ifdef DEBUG |
|
768
1d3f70ac6b31
[svn] - remote metadata handling is moved into input_process_remote_metadata(). this function converts string into utf-8 if necessary (mainly for zina).
yaz
parents:
765
diff
changeset
|
378 g_message("f: input_read_tag"); |
|
765
2430c9773fa7
[svn] - determine whether stream is seekable or not by checking duration. it is safe to use with proxy.
yaz
parents:
755
diff
changeset
|
379 #endif |
|
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
380 if (info->tuple == NULL) { |
|
1428
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1328
diff
changeset
|
381 title_input = tuple_new(); |
|
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
382 info->tuple = title_input; |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
383 } |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
384 else |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
385 title_input = info->tuple; |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
386 |
|
776
8366ad444313
[svn] - by unknown reason, http connection via proxy server needs a transfer stop after tag retrieving.
yaz
parents:
775
diff
changeset
|
387 if(info->infile) { |
|
8366ad444313
[svn] - by unknown reason, http connection via proxy server needs a transfer stop after tag retrieving.
yaz
parents:
775
diff
changeset
|
388 curpos = vfs_ftell(info->infile); |
| 773 | 389 info->id3file = id3_file_vfsopen(info->infile, ID3_FILE_MODE_READONLY); |
|
776
8366ad444313
[svn] - by unknown reason, http connection via proxy server needs a transfer stop after tag retrieving.
yaz
parents:
775
diff
changeset
|
390 } |
|
1328
38fb3bb3e21e
- make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1277
diff
changeset
|
391 else { |
|
775
a24cc8848b9a
[svn] - with fixed curl, read id3 tag over network works now.
yaz
parents:
773
diff
changeset
|
392 info->id3file = id3_file_open(info->filename, ID3_FILE_MODE_READONLY); |
|
1328
38fb3bb3e21e
- make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1277
diff
changeset
|
393 } |
| 773 | 394 |
|
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
395 if (!info->id3file) { |
| 773 | 396 #ifdef DEBUG |
| 397 g_message("read_tag: no id3file"); | |
| 398 #endif | |
|
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
399 return; |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
400 } |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
401 |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
402 info->tag = id3_file_tag(info->id3file); |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
403 if (!info->tag) { |
| 773 | 404 #ifdef DEBUG |
| 405 g_message("read_tag: no tag"); | |
| 406 #endif | |
|
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
407 return; |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
408 } |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
409 |
|
1428
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1328
diff
changeset
|
410 input_set_and_free_tag(info->tag, title_input, ID3_FRAME_ARTIST, "artist"); |
|
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1328
diff
changeset
|
411 input_set_and_free_tag(info->tag, title_input, ID3_FRAME_TITLE, "title"); |
|
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1328
diff
changeset
|
412 input_set_and_free_tag(info->tag, title_input, ID3_FRAME_ALBUM, "album"); |
|
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1328
diff
changeset
|
413 input_set_and_free_tag(info->tag, title_input, ID3_FRAME_GENRE, "genre"); |
|
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1328
diff
changeset
|
414 input_set_and_free_tag(info->tag, title_input, ID3_FRAME_COMMENT, "comment"); |
|
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1328
diff
changeset
|
415 |
|
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
416 string = input_id3_get_string(info->tag, ID3_FRAME_TRACK); |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
417 if (string) { |
|
1428
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1328
diff
changeset
|
418 tuple_associate_int(title_input, "track-number", atoi(string)); |
|
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
419 g_free(string); |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
420 string = NULL; |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
421 } |
|
1428
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1328
diff
changeset
|
422 |
|
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
423 // year |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
424 string = NULL; |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
425 string = input_id3_get_string(info->tag, ID3_FRAME_YEAR); //TDRC |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
426 if (!string) |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
427 string = input_id3_get_string(info->tag, "TYER"); |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
428 |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
429 if (string) { |
|
1428
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1328
diff
changeset
|
430 tuple_associate_int(title_input, "year", atoi(string)); |
|
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
431 g_free(string); |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
432 string = NULL; |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
433 } |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
434 |
| 738 | 435 // length |
| 436 string = input_id3_get_string(info->tag, "TLEN"); | |
| 437 if (string) { | |
|
1428
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1328
diff
changeset
|
438 tuple_associate_int(title_input, "length", atoi(string)); |
| 738 | 439 #ifdef DEBUG |
|
1428
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1328
diff
changeset
|
440 g_message("input_read_tag: TLEN = %d", atoi(string)); |
| 738 | 441 #endif |
| 442 g_free(string); | |
| 443 string = NULL; | |
| 444 } | |
|
1277
e7cd962732cb
file_name and file_path in a tuple should be unescaped.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
997
diff
changeset
|
445 |
|
e7cd962732cb
file_name and file_path in a tuple should be unescaped.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
997
diff
changeset
|
446 realfn = g_filename_from_uri(info->filename, NULL, NULL); |
|
1428
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1328
diff
changeset
|
447 |
|
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1328
diff
changeset
|
448 string = g_strdup(g_basename(realfn ? realfn : info->filename)); |
|
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1328
diff
changeset
|
449 tuple_associate_string(title_input, "file-name", string); |
|
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1328
diff
changeset
|
450 g_free(string); |
|
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1328
diff
changeset
|
451 |
|
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1328
diff
changeset
|
452 string = g_path_get_dirname(realfn ? realfn : info->filename); |
|
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1328
diff
changeset
|
453 tuple_associate_string(title_input, "file-path", string); |
|
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1328
diff
changeset
|
454 g_free(string); |
|
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1328
diff
changeset
|
455 |
|
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1328
diff
changeset
|
456 if ((string = strrchr(realfn ? realfn : info->filename, '.'))) { |
|
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
457 *string = '\0'; // make filename end at dot. |
|
1428
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1328
diff
changeset
|
458 tuple_associate_string(title_input, "file-ext", string + 1); |
|
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
459 } |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
460 |
|
1428
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1328
diff
changeset
|
461 g_free(realfn); realfn = NULL; |
|
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1328
diff
changeset
|
462 |
|
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1328
diff
changeset
|
463 tuple_associate_string(title_input, "codec", "MPEG Audio (MP3)"); |
|
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1328
diff
changeset
|
464 tuple_associate_string(title_input, "quality", "lossy"); |
|
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1328
diff
changeset
|
465 |
|
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1328
diff
changeset
|
466 info->title = tuple_formatter_process_string(title_input, audmad_config.title_override == TRUE ? |
|
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1328
diff
changeset
|
467 audmad_config.id3_format : cfg.gentitle_format); |
|
765
2430c9773fa7
[svn] - determine whether stream is seekable or not by checking duration. it is safe to use with proxy.
yaz
parents:
755
diff
changeset
|
468 |
|
776
8366ad444313
[svn] - by unknown reason, http connection via proxy server needs a transfer stop after tag retrieving.
yaz
parents:
775
diff
changeset
|
469 // for connection via proxy, we have to stop transfer once. I can't explain the reason. |
|
791
91d2b302f479
[svn] - only perform vfs fseek against info::infile if it is available.
nenolod
parents:
789
diff
changeset
|
470 if (info->infile != NULL) { |
|
91d2b302f479
[svn] - only perform vfs fseek against info::infile if it is available.
nenolod
parents:
789
diff
changeset
|
471 vfs_fseek(info->infile, -1, SEEK_SET); // an impossible request |
|
91d2b302f479
[svn] - only perform vfs fseek against info::infile if it is available.
nenolod
parents:
789
diff
changeset
|
472 vfs_fseek(info->infile, curpos, SEEK_SET); |
|
91d2b302f479
[svn] - only perform vfs fseek against info::infile if it is available.
nenolod
parents:
789
diff
changeset
|
473 } |
|
776
8366ad444313
[svn] - by unknown reason, http connection via proxy server needs a transfer stop after tag retrieving.
yaz
parents:
775
diff
changeset
|
474 |
|
765
2430c9773fa7
[svn] - determine whether stream is seekable or not by checking duration. it is safe to use with proxy.
yaz
parents:
755
diff
changeset
|
475 #ifdef DEBUG |
|
768
1d3f70ac6b31
[svn] - remote metadata handling is moved into input_process_remote_metadata(). this function converts string into utf-8 if necessary (mainly for zina).
yaz
parents:
765
diff
changeset
|
476 g_message("e: input_read_tag"); |
|
765
2430c9773fa7
[svn] - determine whether stream is seekable or not by checking duration. it is safe to use with proxy.
yaz
parents:
755
diff
changeset
|
477 #endif |
|
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
478 } |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
479 |
| 773 | 480 void input_process_remote_metadata(struct mad_info_t *info) |
|
768
1d3f70ac6b31
[svn] - remote metadata handling is moved into input_process_remote_metadata(). this function converts string into utf-8 if necessary (mainly for zina).
yaz
parents:
765
diff
changeset
|
481 { |
|
1428
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1328
diff
changeset
|
482 gboolean metadata = FALSE; |
|
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1328
diff
changeset
|
483 |
|
768
1d3f70ac6b31
[svn] - remote metadata handling is moved into input_process_remote_metadata(). this function converts string into utf-8 if necessary (mainly for zina).
yaz
parents:
765
diff
changeset
|
484 if(info->remote && mad_timer_count(info->duration, MAD_UNITS_SECONDS) <= 0){ |
|
1d3f70ac6b31
[svn] - remote metadata handling is moved into input_process_remote_metadata(). this function converts string into utf-8 if necessary (mainly for zina).
yaz
parents:
765
diff
changeset
|
485 gchar *tmp = NULL; |
| 773 | 486 #ifdef DEBUG |
| 487 #ifdef DEBUG_INTENSIVELY | |
| 488 g_message("process_remote_meta"); | |
| 489 #endif | |
| 490 #endif | |
|
1428
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1328
diff
changeset
|
491 |
|
768
1d3f70ac6b31
[svn] - remote metadata handling is moved into input_process_remote_metadata(). this function converts string into utf-8 if necessary (mainly for zina).
yaz
parents:
765
diff
changeset
|
492 g_free(info->title); |
|
1d3f70ac6b31
[svn] - remote metadata handling is moved into input_process_remote_metadata(). this function converts string into utf-8 if necessary (mainly for zina).
yaz
parents:
765
diff
changeset
|
493 info->title = NULL; |
|
1428
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1328
diff
changeset
|
494 tuple_disassociate(info->tuple, "title"); |
|
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1328
diff
changeset
|
495 tuple_disassociate(info->tuple, "album"); |
|
768
1d3f70ac6b31
[svn] - remote metadata handling is moved into input_process_remote_metadata(). this function converts string into utf-8 if necessary (mainly for zina).
yaz
parents:
765
diff
changeset
|
496 |
|
1d3f70ac6b31
[svn] - remote metadata handling is moved into input_process_remote_metadata(). this function converts string into utf-8 if necessary (mainly for zina).
yaz
parents:
765
diff
changeset
|
497 tmp = vfs_get_metadata(info->infile, "track-name"); |
|
1d3f70ac6b31
[svn] - remote metadata handling is moved into input_process_remote_metadata(). this function converts string into utf-8 if necessary (mainly for zina).
yaz
parents:
765
diff
changeset
|
498 if(tmp){ |
|
1428
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1328
diff
changeset
|
499 metadata = TRUE; |
|
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1328
diff
changeset
|
500 gchar *scratch; |
|
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1328
diff
changeset
|
501 |
|
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1328
diff
changeset
|
502 scratch = str_to_utf8(tmp); |
|
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1328
diff
changeset
|
503 tuple_associate_string(info->tuple, "title", scratch); |
|
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1328
diff
changeset
|
504 g_free(scratch); |
|
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1328
diff
changeset
|
505 |
|
768
1d3f70ac6b31
[svn] - remote metadata handling is moved into input_process_remote_metadata(). this function converts string into utf-8 if necessary (mainly for zina).
yaz
parents:
765
diff
changeset
|
506 g_free(tmp); |
|
1d3f70ac6b31
[svn] - remote metadata handling is moved into input_process_remote_metadata(). this function converts string into utf-8 if necessary (mainly for zina).
yaz
parents:
765
diff
changeset
|
507 tmp = NULL; |
|
1d3f70ac6b31
[svn] - remote metadata handling is moved into input_process_remote_metadata(). this function converts string into utf-8 if necessary (mainly for zina).
yaz
parents:
765
diff
changeset
|
508 } |
|
1d3f70ac6b31
[svn] - remote metadata handling is moved into input_process_remote_metadata(). this function converts string into utf-8 if necessary (mainly for zina).
yaz
parents:
765
diff
changeset
|
509 |
|
1d3f70ac6b31
[svn] - remote metadata handling is moved into input_process_remote_metadata(). this function converts string into utf-8 if necessary (mainly for zina).
yaz
parents:
765
diff
changeset
|
510 tmp = vfs_get_metadata(info->infile, "stream-name"); |
|
1d3f70ac6b31
[svn] - remote metadata handling is moved into input_process_remote_metadata(). this function converts string into utf-8 if necessary (mainly for zina).
yaz
parents:
765
diff
changeset
|
511 if(tmp){ |
|
1428
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1328
diff
changeset
|
512 metadata = TRUE; |
|
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1328
diff
changeset
|
513 gchar *scratch; |
|
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1328
diff
changeset
|
514 |
|
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1328
diff
changeset
|
515 scratch = str_to_utf8(tmp); |
|
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1328
diff
changeset
|
516 tuple_associate_string(info->tuple, "album", scratch); |
|
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1328
diff
changeset
|
517 tuple_associate_string(info->tuple, "stream", scratch); |
|
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1328
diff
changeset
|
518 g_free(scratch); |
|
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1328
diff
changeset
|
519 |
|
768
1d3f70ac6b31
[svn] - remote metadata handling is moved into input_process_remote_metadata(). this function converts string into utf-8 if necessary (mainly for zina).
yaz
parents:
765
diff
changeset
|
520 g_free(tmp); |
|
1d3f70ac6b31
[svn] - remote metadata handling is moved into input_process_remote_metadata(). this function converts string into utf-8 if necessary (mainly for zina).
yaz
parents:
765
diff
changeset
|
521 tmp = NULL; |
|
1d3f70ac6b31
[svn] - remote metadata handling is moved into input_process_remote_metadata(). this function converts string into utf-8 if necessary (mainly for zina).
yaz
parents:
765
diff
changeset
|
522 } |
|
1d3f70ac6b31
[svn] - remote metadata handling is moved into input_process_remote_metadata(). this function converts string into utf-8 if necessary (mainly for zina).
yaz
parents:
765
diff
changeset
|
523 |
|
1428
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1328
diff
changeset
|
524 if (metadata) |
|
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1328
diff
changeset
|
525 tmp = tuple_formatter_process_string(info->tuple, "${?title:${title}}${?stream: (${stream})"); |
|
1328
38fb3bb3e21e
- make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1277
diff
changeset
|
526 else { |
|
38fb3bb3e21e
- make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1277
diff
changeset
|
527 gchar *realfn = g_filename_from_uri(info->filename, NULL, NULL); |
|
38fb3bb3e21e
- make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1277
diff
changeset
|
528 gchar *tmp2 = g_path_get_basename(realfn ? realfn : info->filename); // info->filename is uri. --yaz |
|
38fb3bb3e21e
- make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1277
diff
changeset
|
529 tmp = str_to_utf8(tmp2); |
|
38fb3bb3e21e
- make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1277
diff
changeset
|
530 g_free(tmp2); tmp2 = NULL; |
|
38fb3bb3e21e
- make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1277
diff
changeset
|
531 g_free(realfn); realfn = NULL; |
|
38fb3bb3e21e
- make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1277
diff
changeset
|
532 // tmp = g_strdup(g_basename(info->filename)); //XXX maybe ok. --yaz |
|
38fb3bb3e21e
- make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1277
diff
changeset
|
533 } |
|
768
1d3f70ac6b31
[svn] - remote metadata handling is moved into input_process_remote_metadata(). this function converts string into utf-8 if necessary (mainly for zina).
yaz
parents:
765
diff
changeset
|
534 |
|
797
19e08e104ba6
[svn] - madplug: do not call set_info repeatedly in input_process_remote_metadata, only call it when the built title string actually differs from the previous one
giacomo
parents:
791
diff
changeset
|
535 /* call set_info only if tmp is different from prev_tmp */ |
|
19e08e104ba6
[svn] - madplug: do not call set_info repeatedly in input_process_remote_metadata, only call it when the built title string actually differs from the previous one
giacomo
parents:
791
diff
changeset
|
536 if ( ( ( info->prev_title != NULL ) && ( strcmp(info->prev_title,tmp) ) ) || |
|
19e08e104ba6
[svn] - madplug: do not call set_info repeatedly in input_process_remote_metadata, only call it when the built title string actually differs from the previous one
giacomo
parents:
791
diff
changeset
|
537 ( info->prev_title == NULL ) ) |
|
19e08e104ba6
[svn] - madplug: do not call set_info repeatedly in input_process_remote_metadata, only call it when the built title string actually differs from the previous one
giacomo
parents:
791
diff
changeset
|
538 { |
|
19e08e104ba6
[svn] - madplug: do not call set_info repeatedly in input_process_remote_metadata, only call it when the built title string actually differs from the previous one
giacomo
parents:
791
diff
changeset
|
539 mad_plugin->set_info(tmp, |
|
19e08e104ba6
[svn] - madplug: do not call set_info repeatedly in input_process_remote_metadata, only call it when the built title string actually differs from the previous one
giacomo
parents:
791
diff
changeset
|
540 -1, // indicate the stream is unseekable |
|
19e08e104ba6
[svn] - madplug: do not call set_info repeatedly in input_process_remote_metadata, only call it when the built title string actually differs from the previous one
giacomo
parents:
791
diff
changeset
|
541 info->bitrate, info->freq, info->channels); |
|
19e08e104ba6
[svn] - madplug: do not call set_info repeatedly in input_process_remote_metadata, only call it when the built title string actually differs from the previous one
giacomo
parents:
791
diff
changeset
|
542 if (info->prev_title) |
|
19e08e104ba6
[svn] - madplug: do not call set_info repeatedly in input_process_remote_metadata, only call it when the built title string actually differs from the previous one
giacomo
parents:
791
diff
changeset
|
543 g_free(info->prev_title); |
|
19e08e104ba6
[svn] - madplug: do not call set_info repeatedly in input_process_remote_metadata, only call it when the built title string actually differs from the previous one
giacomo
parents:
791
diff
changeset
|
544 info->prev_title = g_strdup(tmp); |
|
19e08e104ba6
[svn] - madplug: do not call set_info repeatedly in input_process_remote_metadata, only call it when the built title string actually differs from the previous one
giacomo
parents:
791
diff
changeset
|
545 } |
|
19e08e104ba6
[svn] - madplug: do not call set_info repeatedly in input_process_remote_metadata, only call it when the built title string actually differs from the previous one
giacomo
parents:
791
diff
changeset
|
546 |
|
768
1d3f70ac6b31
[svn] - remote metadata handling is moved into input_process_remote_metadata(). this function converts string into utf-8 if necessary (mainly for zina).
yaz
parents:
765
diff
changeset
|
547 g_free(tmp); |
|
1d3f70ac6b31
[svn] - remote metadata handling is moved into input_process_remote_metadata(). this function converts string into utf-8 if necessary (mainly for zina).
yaz
parents:
765
diff
changeset
|
548 } |
|
1d3f70ac6b31
[svn] - remote metadata handling is moved into input_process_remote_metadata(). this function converts string into utf-8 if necessary (mainly for zina).
yaz
parents:
765
diff
changeset
|
549 } |
|
1d3f70ac6b31
[svn] - remote metadata handling is moved into input_process_remote_metadata(). this function converts string into utf-8 if necessary (mainly for zina).
yaz
parents:
765
diff
changeset
|
550 |
|
1d3f70ac6b31
[svn] - remote metadata handling is moved into input_process_remote_metadata(). this function converts string into utf-8 if necessary (mainly for zina).
yaz
parents:
765
diff
changeset
|
551 |
|
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
552 /** |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
553 * Retrieve meta-information about URL. |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
554 * For local files this means ID3 tag etc. |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
555 */ |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
556 gboolean input_get_info(struct mad_info_t *info, gboolean fast_scan) |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
557 { |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
558 #ifdef DEBUG |
| 799 | 559 gchar *tmp = g_filename_to_utf8(info->filename, -1, NULL, NULL, NULL); |
| 560 g_message("f: input_get_info: %s, fast_scan = %s", tmp, fast_scan ? "TRUE" : "FALSE"); | |
| 561 g_free(tmp); | |
|
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
562 #endif /* DEBUG */ |
| 738 | 563 |
| 773 | 564 input_alloc_tag(info); |
|
775
a24cc8848b9a
[svn] - with fixed curl, read id3 tag over network works now.
yaz
parents:
773
diff
changeset
|
565 input_read_tag(info); |
| 773 | 566 |
| 567 if(!info->remote) { // reduce startup delay | |
| 568 read_replaygain(info); | |
| 569 } | |
|
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
570 |
| 738 | 571 /* scan mp3 file, decoding headers */ |
| 611 | 572 if (scan_file(info, fast_scan) == FALSE) { |
| 773 | 573 #ifdef DEBUG |
| 574 g_message("input_get_info: scan_file failed"); | |
| 575 #endif | |
|
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
576 return FALSE; |
| 611 | 577 } |
| 738 | 578 |
|
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
579 /* reset the input file to the start */ |
| 611 | 580 vfs_fseek(info->infile, 0, SEEK_SET); |
|
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
581 info->offset = 0; |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
582 |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
583 /* use the filename for the title as a last resort */ |
| 611 | 584 if (!info->title) { |
|
1328
38fb3bb3e21e
- make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1277
diff
changeset
|
585 char *pos = strrchr(info->filename, DIR_SEPARATOR); //XXX info->filename is uri. --yaz |
|
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
586 if (pos) |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
587 info->title = g_strdup(pos + 1); |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
588 else |
|
1328
38fb3bb3e21e
- make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1277
diff
changeset
|
589 info->title = g_strdup(info->filename); //XXX info->filename is uri. --yaz |
|
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
590 } |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
591 |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
592 #ifdef DEBUG |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
593 g_message("e: input_get_info"); |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
594 #endif /* DEBUG */ |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
595 return TRUE; |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
596 } |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
597 |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
598 |
| 611 | 599 |
|
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
600 /** |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
601 * Read data from the source given my madinfo into the buffer |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
602 * provided. Return the number of bytes read. |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
603 * @return 0 on EOF |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
604 * @return -1 on error |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
605 */ |
| 611 | 606 // this function may be called before info->playback initialized. |
|
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
607 int |
|
768
1d3f70ac6b31
[svn] - remote metadata handling is moved into input_process_remote_metadata(). this function converts string into utf-8 if necessary (mainly for zina).
yaz
parents:
765
diff
changeset
|
608 input_get_data(struct mad_info_t *info, guchar * buffer, |
|
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
609 int buffer_size) |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
610 { |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
611 int len = 0; |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
612 #ifdef DEBUG |
| 611 | 613 #ifdef DEBUG_INTENSIVELY |
| 614 g_message ("f: input_get_data: %d", buffer_size); | |
|
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
615 #endif |
| 611 | 616 #endif |
|
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
617 /* simply read to data from the file */ |
|
768
1d3f70ac6b31
[svn] - remote metadata handling is moved into input_process_remote_metadata(). this function converts string into utf-8 if necessary (mainly for zina).
yaz
parents:
765
diff
changeset
|
618 len = vfs_fread(buffer, 1, buffer_size, info->infile); //vfs_fread returns num of elements. |
|
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
619 |
| 789 | 620 if(len == 0 && info->playback){ |
| 621 info->playback->eof = TRUE; | |
| 611 | 622 } |
|
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
623 |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
624 #ifdef DEBUG |
| 611 | 625 #ifdef DEBUG_INTENSIVELY |
|
768
1d3f70ac6b31
[svn] - remote metadata handling is moved into input_process_remote_metadata(). this function converts string into utf-8 if necessary (mainly for zina).
yaz
parents:
765
diff
changeset
|
626 g_message ("e: input_get_data: size=%d offset=%d", len, info->offset); |
| 611 | 627 #endif |
|
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
628 #endif |
|
768
1d3f70ac6b31
[svn] - remote metadata handling is moved into input_process_remote_metadata(). this function converts string into utf-8 if necessary (mainly for zina).
yaz
parents:
765
diff
changeset
|
629 info->offset += len; |
|
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
630 return len; |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
631 } |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
632 |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
633 /** |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
634 * Free up all mad_info_t related resourses. |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
635 */ |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
636 gboolean input_term(struct mad_info_t * info) |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
637 { |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
638 #ifdef DEBUG |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
639 g_message("f: input_term"); |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
640 #endif |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
641 |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
642 if (info->title) |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
643 g_free(info->title); |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
644 if (info->url) |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
645 g_free(info->url); |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
646 if (info->filename) |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
647 g_free(info->filename); |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
648 if (info->infile) |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
649 vfs_fclose(info->infile); |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
650 if (info->id3file) |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
651 id3_file_close(info->id3file); |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
652 |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
653 if (info->replaygain_album_str) |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
654 g_free(info->replaygain_album_str); |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
655 if (info->replaygain_track_str) |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
656 g_free(info->replaygain_track_str); |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
657 if (info->replaygain_album_peak_str) |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
658 g_free(info->replaygain_album_peak_str); |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
659 if (info->replaygain_track_peak_str) |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
660 g_free(info->replaygain_track_peak_str); |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
661 if (info->mp3gain_undo_str) |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
662 g_free(info->mp3gain_undo_str); |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
663 if (info->mp3gain_minmax_str) |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
664 g_free(info->mp3gain_minmax_str); |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
665 |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
666 if (info->tuple) { |
|
1465
db616ccdd40c
use tuple_free(x) in place of mowgli_object_unref(x)
Giacomo Lozito <james@develia.org>
parents:
1428
diff
changeset
|
667 tuple_free(info->tuple); |
|
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
668 info->tuple = NULL; |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
669 } |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
670 |
|
797
19e08e104ba6
[svn] - madplug: do not call set_info repeatedly in input_process_remote_metadata, only call it when the built title string actually differs from the previous one
giacomo
parents:
791
diff
changeset
|
671 if (info->prev_title) |
|
19e08e104ba6
[svn] - madplug: do not call set_info repeatedly in input_process_remote_metadata, only call it when the built title string actually differs from the previous one
giacomo
parents:
791
diff
changeset
|
672 g_free(info->prev_title); |
|
19e08e104ba6
[svn] - madplug: do not call set_info repeatedly in input_process_remote_metadata, only call it when the built title string actually differs from the previous one
giacomo
parents:
791
diff
changeset
|
673 |
|
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
674 /* set everything to zero in case it gets used again. */ |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
675 memset(info, 0, sizeof(struct mad_info_t)); |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
676 #ifdef DEBUG |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
677 g_message("e: input_term"); |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
678 #endif |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
679 return TRUE; |
|
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
680 } |
