Mercurial > audlegacy-plugins
annotate src/madplug/input.c @ 2499:4d6045c20cc5
Include cleanups, part #4.
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Mon, 31 Mar 2008 15:18:05 +0300 |
parents | 809736eb47d9 |
children | 1f6b5f5768e2 |
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 */ |
2341
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2334
diff
changeset
|
72 gboolean |
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2334
diff
changeset
|
73 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
|
74 { |
2276
d25cd7e7eddb
append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2214
diff
changeset
|
75 AUDDBG("f: input_init\n"); |
2214
9a869d4bb0d3
make use of AUDDBG() for debug print out.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2142
diff
changeset
|
76 |
1485
4e612b01f303
- make use of tuple_formatter_make_title_string(). now madplug can show file name if metadata is not available.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1473
diff
changeset
|
77 memset(info, 0, sizeof(struct mad_info_t)); // all fields are cleared to 0 --yaz |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
78 |
2390
bd9673d8b7d5
converted to new sound engine scheme.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2346
diff
changeset
|
79 info->fmt = FMT_FIXED32; |
610
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); |
1485
4e612b01f303
- make use of tuple_formatter_make_title_string(). now madplug can show file name if metadata is not available.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1473
diff
changeset
|
88 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
|
89 |
773 | 90 // from input_read_replaygain() |
2392
4ad6e7dfb389
imported 5298b10777b3 by Eugene Zagidullin.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2390
diff
changeset
|
91 info->replaygain_track_peak = 0.0; |
4ad6e7dfb389
imported 5298b10777b3 by Eugene Zagidullin.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2390
diff
changeset
|
92 info->replaygain_track_scale = 0.0; |
4ad6e7dfb389
imported 5298b10777b3 by Eugene Zagidullin.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2390
diff
changeset
|
93 info->replaygain_album_peak = 0.0; |
4ad6e7dfb389
imported 5298b10777b3 by Eugene Zagidullin.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2390
diff
changeset
|
94 info->replaygain_album_scale = 0.0; |
773 | 95 info->mp3gain_undo = -77; |
96 info->mp3gain_minmax = -77; | |
97 | |
1328
38fb3bb3e21e
- make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1277
diff
changeset
|
98 if(!fd){ |
1978 | 99 info->infile = aud_vfs_fopen(info->filename, "rb"); |
1328
38fb3bb3e21e
- make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1277
diff
changeset
|
100 if (info->infile == NULL) { |
38fb3bb3e21e
- make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1277
diff
changeset
|
101 return FALSE; |
38fb3bb3e21e
- make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1277
diff
changeset
|
102 } |
611 | 103 } |
1328
38fb3bb3e21e
- make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1277
diff
changeset
|
104 else{ |
2214
9a869d4bb0d3
make use of AUDDBG() for debug print out.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2142
diff
changeset
|
105 AUDDBG("input_init: aud_vfs_dup\n"); |
9a869d4bb0d3
make use of AUDDBG() for debug print out.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2142
diff
changeset
|
106 |
1978 | 107 info->infile = aud_vfs_dup(fd); |
1328
38fb3bb3e21e
- make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1277
diff
changeset
|
108 } |
38fb3bb3e21e
- make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1277
diff
changeset
|
109 |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
110 // obtain file size |
1978 | 111 info->size = aud_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
|
112 info->remote = info->size == 0 ? TRUE : FALSE; //proxy connection may result in non-zero size. |
2291 | 113 if(aud_vfs_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
|
114 info->remote = TRUE; |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
115 |
997
e46b98155d5d
[svn] - fix a bug which counts number of frames twice in handling xing header.
yaz
parents:
974
diff
changeset
|
116 info->fileinfo_request = FALSE; |
e46b98155d5d
[svn] - fix a bug which counts number of frames twice in handling xing header.
yaz
parents:
974
diff
changeset
|
117 |
2276
d25cd7e7eddb
append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2214
diff
changeset
|
118 AUDDBG("i: info->size = %lu\n", (long unsigned int)info->size); |
d25cd7e7eddb
append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2214
diff
changeset
|
119 AUDDBG("e: input_init\n"); |
2214
9a869d4bb0d3
make use of AUDDBG() for debug print out.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2142
diff
changeset
|
120 |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
121 return TRUE; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
122 } |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
123 |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
124 /* return length in letters */ |
2341
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2334
diff
changeset
|
125 size_t |
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2334
diff
changeset
|
126 mad_ucs4len(id3_ucs4_t *ucs) |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
127 { |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
128 id3_ucs4_t *ptr = ucs; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
129 size_t len = 0; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
130 |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
131 while(*ptr++ != 0) |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
132 len++; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
133 |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
134 return len; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
135 } |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
136 |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
137 /* duplicate id3_ucs4_t string. new string will be terminated with 0. */ |
2341
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2334
diff
changeset
|
138 id3_ucs4_t * |
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2334
diff
changeset
|
139 mad_ucs4dup(id3_ucs4_t *org) |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
140 { |
2469
2d7b190acc76
Indeed 'new' might not be a C keyword, but it's a C++ keyword and thus not recommended to be used as a identifier.
Matti Hamalainen <ccr@tnsp.org>
parents:
2468
diff
changeset
|
141 id3_ucs4_t *res = NULL; |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
142 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
|
143 |
2469
2d7b190acc76
Indeed 'new' might not be a C keyword, but it's a C++ keyword and thus not recommended to be used as a identifier.
Matti Hamalainen <ccr@tnsp.org>
parents:
2468
diff
changeset
|
144 res = g_malloc0((len + 1) * sizeof(id3_ucs4_t)); |
2d7b190acc76
Indeed 'new' might not be a C keyword, but it's a C++ keyword and thus not recommended to be used as a identifier.
Matti Hamalainen <ccr@tnsp.org>
parents:
2468
diff
changeset
|
145 memcpy(res, org, len * sizeof(id3_ucs4_t)); |
2d7b190acc76
Indeed 'new' might not be a C keyword, but it's a C++ keyword and thus not recommended to be used as a identifier.
Matti Hamalainen <ccr@tnsp.org>
parents:
2468
diff
changeset
|
146 *(res + len) = 0; //terminate |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
147 |
2469
2d7b190acc76
Indeed 'new' might not be a C keyword, but it's a C++ keyword and thus not recommended to be used as a identifier.
Matti Hamalainen <ccr@tnsp.org>
parents:
2468
diff
changeset
|
148 return res; |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
149 } |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
150 |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
151 #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
|
152 |
2341
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2334
diff
changeset
|
153 id3_ucs4_t * |
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2334
diff
changeset
|
154 mad_parse_genre(const id3_ucs4_t *string) |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
155 { |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
156 id3_ucs4_t *ret = NULL; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
157 id3_ucs4_t *tmp = NULL; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
158 id3_ucs4_t *genre = NULL; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
159 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
|
160 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
|
161 size_t tmp_len = 0; |
674 | 162 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
|
163 gboolean is_num = TRUE; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
164 |
699
14f80d61e855
[svn] - TCON frame without string crashes mad_parse_genre().
yaz
parents:
696
diff
changeset
|
165 if(!string) |
14f80d61e855
[svn] - TCON frame without string crashes mad_parse_genre().
yaz
parents:
696
diff
changeset
|
166 return NULL; |
14f80d61e855
[svn] - TCON frame without string crashes mad_parse_genre().
yaz
parents:
696
diff
changeset
|
167 |
674 | 168 string_len = mad_ucs4len((id3_ucs4_t *)string); |
169 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
|
170 |
675
1ea4cfb007e0
[svn] - if genre name is generated from number, it may exceed allocated memory block.
yaz
parents:
674
diff
changeset
|
171 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
|
172 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
|
173 } |
1ea4cfb007e0
[svn] - if genre name is generated from number, it may exceed allocated memory block.
yaz
parents:
674
diff
changeset
|
174 else { |
1ea4cfb007e0
[svn] - if genre name is generated from number, it may exceed allocated memory block.
yaz
parents:
674
diff
changeset
|
175 ret = g_malloc0(1024); |
1ea4cfb007e0
[svn] - if genre name is generated from number, it may exceed allocated memory block.
yaz
parents:
674
diff
changeset
|
176 } |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
177 |
2334
0dd31200a33a
Fix problems with pointer arithmetic (Bugzilla #72)
Jussi Judin <jjudin+audacious@iki.fi>
parents:
2291
diff
changeset
|
178 for(ptr = (id3_ucs4_t *)string; ptr <= tail && *ptr != 0; ptr++) { |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
179 if(*ptr == '(') { |
2334
0dd31200a33a
Fix problems with pointer arithmetic (Bugzilla #72)
Jussi Judin <jjudin+audacious@iki.fi>
parents:
2291
diff
changeset
|
180 if(ptr < tail && *(++ptr) == '(') { // escaped text like: ((something) |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
181 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
|
182 end++; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
183 } |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
184 end++; //include trailing ')' |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
185 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
|
186 ret_len += (end - ptr); |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
187 *(ret + ret_len) = 0; //terminate |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
188 ptr = end + 1; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
189 } |
2334
0dd31200a33a
Fix problems with pointer arithmetic (Bugzilla #72)
Jussi Judin <jjudin+audacious@iki.fi>
parents:
2291
diff
changeset
|
190 else if (ptr <= tail && *ptr != 0) { |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
191 // reference to an id3v1 genre code |
2468
615b67c4e010
Tiny cleanups of repetitive code syndrome madness; Added some null-pointer checks.
Matti Hamalainen <ccr@tnsp.org>
parents:
2392
diff
changeset
|
192 for(tmp_len = 0, end = ptr; *end != ')' && *end != 0;) { |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
193 end++; |
2468
615b67c4e010
Tiny cleanups of repetitive code syndrome madness; Added some null-pointer checks.
Matti Hamalainen <ccr@tnsp.org>
parents:
2392
diff
changeset
|
194 tmp_len++; |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
195 } |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
196 |
2468
615b67c4e010
Tiny cleanups of repetitive code syndrome madness; Added some null-pointer checks.
Matti Hamalainen <ccr@tnsp.org>
parents:
2392
diff
changeset
|
197 tmp = g_malloc0(BYTES(tmp_len + 1)); |
615b67c4e010
Tiny cleanups of repetitive code syndrome madness; Added some null-pointer checks.
Matti Hamalainen <ccr@tnsp.org>
parents:
2392
diff
changeset
|
198 memcpy(tmp, ptr, BYTES(tmp_len)); |
615b67c4e010
Tiny cleanups of repetitive code syndrome madness; Added some null-pointer checks.
Matti Hamalainen <ccr@tnsp.org>
parents:
2392
diff
changeset
|
199 *(tmp + tmp_len) = 0; //terminate |
615b67c4e010
Tiny cleanups of repetitive code syndrome madness; Added some null-pointer checks.
Matti Hamalainen <ccr@tnsp.org>
parents:
2392
diff
changeset
|
200 ptr += tmp_len; |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
201 |
2471
6039012d8252
Certain piece of allocated memory was free'd before we were done with it,
Matti Hamalainen <ccr@tnsp.org>
parents:
2469
diff
changeset
|
202 /* id3_genre_name may, in some cases, return the given string |
6039012d8252
Certain piece of allocated memory was free'd before we were done with it,
Matti Hamalainen <ccr@tnsp.org>
parents:
2469
diff
changeset
|
203 * so we must free it after we're done, not before. |
6039012d8252
Certain piece of allocated memory was free'd before we were done with it,
Matti Hamalainen <ccr@tnsp.org>
parents:
2469
diff
changeset
|
204 */ |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
205 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
|
206 |
2471
6039012d8252
Certain piece of allocated memory was free'd before we were done with it,
Matti Hamalainen <ccr@tnsp.org>
parents:
2469
diff
changeset
|
207 tmp_len = mad_ucs4len(genre); |
6039012d8252
Certain piece of allocated memory was free'd before we were done with it,
Matti Hamalainen <ccr@tnsp.org>
parents:
2469
diff
changeset
|
208 memcpy(ret + ret_len, genre, BYTES(tmp_len)); |
6039012d8252
Certain piece of allocated memory was free'd before we were done with it,
Matti Hamalainen <ccr@tnsp.org>
parents:
2469
diff
changeset
|
209 ret_len += tmp_len; |
6039012d8252
Certain piece of allocated memory was free'd before we were done with it,
Matti Hamalainen <ccr@tnsp.org>
parents:
2469
diff
changeset
|
210 *(ret + ret_len) = 0; //terminate |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
211 g_free(tmp); |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
212 } |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
213 } |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
214 else { |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
215 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
|
216 end++; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
217 } |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
218 // 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
|
219 tp = ptr; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
220 is_num = TRUE; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
221 while(tp < end) { |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
222 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
|
223 is_num = FALSE; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
224 break; |
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 tp++; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
227 } |
2334
0dd31200a33a
Fix problems with pointer arithmetic (Bugzilla #72)
Jussi Judin <jjudin+audacious@iki.fi>
parents:
2291
diff
changeset
|
228 |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
229 if(is_num) { |
2214
9a869d4bb0d3
make use of AUDDBG() for debug print out.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2142
diff
changeset
|
230 AUDDBG("is_num!\n"); |
2468
615b67c4e010
Tiny cleanups of repetitive code syndrome madness; Added some null-pointer checks.
Matti Hamalainen <ccr@tnsp.org>
parents:
2392
diff
changeset
|
231 tmp_len = end - ptr; |
615b67c4e010
Tiny cleanups of repetitive code syndrome madness; Added some null-pointer checks.
Matti Hamalainen <ccr@tnsp.org>
parents:
2392
diff
changeset
|
232 tmp = g_malloc0(BYTES(tmp_len + 1)); |
615b67c4e010
Tiny cleanups of repetitive code syndrome madness; Added some null-pointer checks.
Matti Hamalainen <ccr@tnsp.org>
parents:
2392
diff
changeset
|
233 memcpy(tmp, ptr, BYTES(tmp_len)); |
615b67c4e010
Tiny cleanups of repetitive code syndrome madness; Added some null-pointer checks.
Matti Hamalainen <ccr@tnsp.org>
parents:
2392
diff
changeset
|
234 *(tmp + tmp_len) = 0; //terminate |
615b67c4e010
Tiny cleanups of repetitive code syndrome madness; Added some null-pointer checks.
Matti Hamalainen <ccr@tnsp.org>
parents:
2392
diff
changeset
|
235 ptr += tmp_len; |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
236 |
2471
6039012d8252
Certain piece of allocated memory was free'd before we were done with it,
Matti Hamalainen <ccr@tnsp.org>
parents:
2469
diff
changeset
|
237 /* id3_genre_name may, in some cases, return the given string |
6039012d8252
Certain piece of allocated memory was free'd before we were done with it,
Matti Hamalainen <ccr@tnsp.org>
parents:
2469
diff
changeset
|
238 * so we must free it after we're done, not before. |
6039012d8252
Certain piece of allocated memory was free'd before we were done with it,
Matti Hamalainen <ccr@tnsp.org>
parents:
2469
diff
changeset
|
239 */ |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
240 genre = (id3_ucs4_t *)id3_genre_name((const id3_ucs4_t *)tmp); |
2214
9a869d4bb0d3
make use of AUDDBG() for debug print out.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2142
diff
changeset
|
241 AUDDBG("genre length = %d\n", mad_ucs4len(genre)); |
2471
6039012d8252
Certain piece of allocated memory was free'd before we were done with it,
Matti Hamalainen <ccr@tnsp.org>
parents:
2469
diff
changeset
|
242 |
6039012d8252
Certain piece of allocated memory was free'd before we were done with it,
Matti Hamalainen <ccr@tnsp.org>
parents:
2469
diff
changeset
|
243 tmp_len = mad_ucs4len(genre); |
6039012d8252
Certain piece of allocated memory was free'd before we were done with it,
Matti Hamalainen <ccr@tnsp.org>
parents:
2469
diff
changeset
|
244 memcpy(ret + ret_len, genre, BYTES(tmp_len)); |
6039012d8252
Certain piece of allocated memory was free'd before we were done with it,
Matti Hamalainen <ccr@tnsp.org>
parents:
2469
diff
changeset
|
245 ret_len += tmp_len; |
6039012d8252
Certain piece of allocated memory was free'd before we were done with it,
Matti Hamalainen <ccr@tnsp.org>
parents:
2469
diff
changeset
|
246 *(ret + ret_len) = 0; //terminate |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
247 g_free(tmp); |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
248 } |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
249 else { // plain text |
2468
615b67c4e010
Tiny cleanups of repetitive code syndrome madness; Added some null-pointer checks.
Matti Hamalainen <ccr@tnsp.org>
parents:
2392
diff
changeset
|
250 tmp_len = end - ptr; |
2214
9a869d4bb0d3
make use of AUDDBG() for debug print out.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2142
diff
changeset
|
251 AUDDBG("plain!\n"); |
9a869d4bb0d3
make use of AUDDBG() for debug print out.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2142
diff
changeset
|
252 AUDDBG("ret_len = %d\n", ret_len); |
2468
615b67c4e010
Tiny cleanups of repetitive code syndrome madness; Added some null-pointer checks.
Matti Hamalainen <ccr@tnsp.org>
parents:
2392
diff
changeset
|
253 AUDDBG("end - ptr = %d\n", BYTES(tmp_len)); |
2214
9a869d4bb0d3
make use of AUDDBG() for debug print out.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2142
diff
changeset
|
254 |
2468
615b67c4e010
Tiny cleanups of repetitive code syndrome madness; Added some null-pointer checks.
Matti Hamalainen <ccr@tnsp.org>
parents:
2392
diff
changeset
|
255 memcpy(ret + ret_len, ptr, BYTES(tmp_len)); |
615b67c4e010
Tiny cleanups of repetitive code syndrome madness; Added some null-pointer checks.
Matti Hamalainen <ccr@tnsp.org>
parents:
2392
diff
changeset
|
256 ret_len = ret_len + tmp_len; |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
257 *(ret + ret_len) = 0; //terminate |
2468
615b67c4e010
Tiny cleanups of repetitive code syndrome madness; Added some null-pointer checks.
Matti Hamalainen <ccr@tnsp.org>
parents:
2392
diff
changeset
|
258 ptr += tmp_len; |
610
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 } |
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 return ret; |
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 |
2341
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2334
diff
changeset
|
265 gchar * |
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2334
diff
changeset
|
266 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
|
267 { |
618
a7a28782c1b0
[svn] - revise input_id3_get_string() to take encoding of field into account.
yaz
parents:
613
diff
changeset
|
268 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
|
269 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
|
270 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
|
271 struct id3_frame *frame; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
272 union id3_field *field; |
618
a7a28782c1b0
[svn] - revise input_id3_get_string() to take encoding of field into account.
yaz
parents:
613
diff
changeset
|
273 int encoding = -1; |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
274 |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
275 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
|
276 if (!frame) |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
277 return NULL; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
278 |
618
a7a28782c1b0
[svn] - revise input_id3_get_string() to take encoding of field into account.
yaz
parents:
613
diff
changeset
|
279 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
|
280 encoding = id3_field_gettextencoding(field); |
a7a28782c1b0
[svn] - revise input_id3_get_string() to take encoding of field into account.
yaz
parents:
613
diff
changeset
|
281 |
620 | 282 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
|
283 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
|
284 else |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
285 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
|
286 |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
287 if (!field) |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
288 return NULL; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
289 |
620 | 290 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
|
291 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
|
292 else |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
293 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
|
294 |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
295 if (!string_const) |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
296 return NULL; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
297 |
620 | 298 if (!strcmp(frame_name, ID3_FRAME_GENRE)) { |
645 | 299 string = mad_parse_genre(string_const); |
300 } | |
301 else { | |
302 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
|
303 } |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
304 |
674 | 305 if (!string) |
306 return NULL; | |
307 | |
618
a7a28782c1b0
[svn] - revise input_id3_get_string() to take encoding of field into account.
yaz
parents:
613
diff
changeset
|
308 switch (encoding) { |
a7a28782c1b0
[svn] - revise input_id3_get_string() to take encoding of field into account.
yaz
parents:
613
diff
changeset
|
309 case ID3_FIELD_TEXTENCODING_ISO_8859_1: |
645 | 310 rtn0 = (gchar *)id3_ucs4_latin1duplicate(string); |
2050
2ffc6a69fcd1
string API calls -> vtable
William Pitcock <nenolod@atheme.org>
parents:
1985
diff
changeset
|
311 rtn = aud_str_to_utf8(rtn0); |
645 | 312 g_free(rtn0); |
618
a7a28782c1b0
[svn] - revise input_id3_get_string() to take encoding of field into account.
yaz
parents:
613
diff
changeset
|
313 break; |
a7a28782c1b0
[svn] - revise input_id3_get_string() to take encoding of field into account.
yaz
parents:
613
diff
changeset
|
314 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
|
315 default: |
645 | 316 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
|
317 break; |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
318 } |
645 | 319 g_free((void *)string); |
618
a7a28782c1b0
[svn] - revise input_id3_get_string() to take encoding of field into account.
yaz
parents:
613
diff
changeset
|
320 |
2214
9a869d4bb0d3
make use of AUDDBG() for debug print out.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2142
diff
changeset
|
321 AUDDBG("i: string = %s\n", rtn); |
9a869d4bb0d3
make use of AUDDBG() for debug print out.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2142
diff
changeset
|
322 |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
323 return rtn; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
324 } |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
325 |
2341
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2334
diff
changeset
|
326 static void |
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2334
diff
changeset
|
327 input_set_and_free_tag(struct id3_tag *tag, Tuple *tuple, const gchar *frame, const gint nfield) |
1428
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1328
diff
changeset
|
328 { |
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1328
diff
changeset
|
329 gchar *scratch = input_id3_get_string(tag, frame); |
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1328
diff
changeset
|
330 |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1709
diff
changeset
|
331 aud_tuple_associate_string(tuple, nfield, NULL, scratch); |
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1709
diff
changeset
|
332 aud_tuple_associate_string(tuple, -1, frame, scratch); |
1428
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1328
diff
changeset
|
333 |
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1328
diff
changeset
|
334 g_free(scratch); |
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1328
diff
changeset
|
335 } |
773 | 336 |
2341
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2334
diff
changeset
|
337 static void |
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2334
diff
changeset
|
338 input_alloc_tag(struct mad_info_t *info) |
773 | 339 { |
1485
4e612b01f303
- make use of tuple_formatter_make_title_string(). now madplug can show file name if metadata is not available.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1473
diff
changeset
|
340 Tuple *tuple; |
773 | 341 |
342 if (info->tuple == NULL) { | |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1709
diff
changeset
|
343 tuple = aud_tuple_new(); |
1485
4e612b01f303
- make use of tuple_formatter_make_title_string(). now madplug can show file name if metadata is not available.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1473
diff
changeset
|
344 info->tuple = tuple; |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1709
diff
changeset
|
345 aud_tuple_associate_int(info->tuple, FIELD_LENGTH, NULL, -1); |
773 | 346 } |
347 } | |
348 | |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
349 /** |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
350 * read the ID3 tag |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
351 */ |
2341
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2334
diff
changeset
|
352 static void |
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2334
diff
changeset
|
353 input_read_tag(struct mad_info_t *info) |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
354 { |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
355 gchar *string = NULL; |
1485
4e612b01f303
- make use of tuple_formatter_make_title_string(). now madplug can show file name if metadata is not available.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1473
diff
changeset
|
356 Tuple *tuple; |
791
91d2b302f479
[svn] - only perform vfs fseek against info::infile if it is available.
nenolod
parents:
789
diff
changeset
|
357 glong curpos = 0; |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
358 |
2276
d25cd7e7eddb
append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2214
diff
changeset
|
359 AUDDBG("f: input_read_tag\n"); |
2214
9a869d4bb0d3
make use of AUDDBG() for debug print out.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2142
diff
changeset
|
360 |
1687
d158ce84fda7
Modified for Tuplez/plugin API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
1485
diff
changeset
|
361 if (info->tuple != NULL) |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1709
diff
changeset
|
362 aud_tuple_free(info->tuple); |
1687
d158ce84fda7
Modified for Tuplez/plugin API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
1485
diff
changeset
|
363 |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1709
diff
changeset
|
364 tuple = aud_tuple_new_from_filename(info->filename); |
1687
d158ce84fda7
Modified for Tuplez/plugin API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
1485
diff
changeset
|
365 info->tuple = tuple; |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
366 |
776
8366ad444313
[svn] - by unknown reason, http connection via proxy server needs a transfer stop after tag retrieving.
yaz
parents:
775
diff
changeset
|
367 if(info->infile) { |
1978 | 368 curpos = aud_vfs_ftell(info->infile); |
773 | 369 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
|
370 } |
1328
38fb3bb3e21e
- make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1277
diff
changeset
|
371 else { |
775
a24cc8848b9a
[svn] - with fixed curl, read id3 tag over network works now.
yaz
parents:
773
diff
changeset
|
372 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
|
373 } |
773 | 374 |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
375 if (!info->id3file) { |
2276
d25cd7e7eddb
append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2214
diff
changeset
|
376 AUDDBG("read_tag: no id3file\n"); |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
377 return; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
378 } |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
379 |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
380 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
|
381 if (!info->tag) { |
2276
d25cd7e7eddb
append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2214
diff
changeset
|
382 AUDDBG("read_tag: no tag\n"); |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
383 return; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
384 } |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
385 |
1687
d158ce84fda7
Modified for Tuplez/plugin API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
1485
diff
changeset
|
386 input_set_and_free_tag(info->tag, tuple, ID3_FRAME_ARTIST, FIELD_ARTIST); |
d158ce84fda7
Modified for Tuplez/plugin API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
1485
diff
changeset
|
387 input_set_and_free_tag(info->tag, tuple, ID3_FRAME_TITLE, FIELD_TITLE); |
d158ce84fda7
Modified for Tuplez/plugin API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
1485
diff
changeset
|
388 input_set_and_free_tag(info->tag, tuple, ID3_FRAME_ALBUM, FIELD_ALBUM); |
d158ce84fda7
Modified for Tuplez/plugin API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
1485
diff
changeset
|
389 input_set_and_free_tag(info->tag, tuple, ID3_FRAME_GENRE, FIELD_GENRE); |
d158ce84fda7
Modified for Tuplez/plugin API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
1485
diff
changeset
|
390 input_set_and_free_tag(info->tag, tuple, ID3_FRAME_COMMENT, FIELD_COMMENT); |
1428
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1328
diff
changeset
|
391 |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
392 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
|
393 if (string) { |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1709
diff
changeset
|
394 aud_tuple_associate_int(tuple, FIELD_TRACK_NUMBER, NULL, atoi(string)); |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
395 g_free(string); |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
396 string = NULL; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
397 } |
1428
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1328
diff
changeset
|
398 |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
399 // year |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
400 string = NULL; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
401 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
|
402 if (!string) |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
403 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
|
404 |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
405 if (string) { |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1709
diff
changeset
|
406 aud_tuple_associate_int(tuple, FIELD_YEAR, NULL, atoi(string)); |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
407 g_free(string); |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
408 string = NULL; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
409 } |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
410 |
738 | 411 // length |
412 string = input_id3_get_string(info->tag, "TLEN"); | |
2346
78a0e19530e2
allow madplug to compute mp3 duration when TLEN field is invalid. patch by Russell Yanofsky.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2341
diff
changeset
|
413 if (string && atoi(string)) { |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1709
diff
changeset
|
414 aud_tuple_associate_int(tuple, FIELD_LENGTH, NULL, atoi(string)); |
2276
d25cd7e7eddb
append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2214
diff
changeset
|
415 AUDDBG("input_read_tag: TLEN = %d\n", atoi(string)); |
738 | 416 g_free(string); |
417 string = NULL; | |
1709
0d5f7629171f
Madplug didn't always calculate song length when needed, fixed.
Matti Hamalainen <ccr@tnsp.org>
parents:
1687
diff
changeset
|
418 } else |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1709
diff
changeset
|
419 aud_tuple_associate_int(tuple, FIELD_LENGTH, NULL, -1); |
1277
e7cd962732cb
file_name and file_path in a tuple should be unescaped.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
997
diff
changeset
|
420 |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1709
diff
changeset
|
421 aud_tuple_associate_string(tuple, FIELD_CODEC, NULL, "MPEG Audio (MP3)"); |
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1709
diff
changeset
|
422 aud_tuple_associate_string(tuple, FIELD_QUALITY, NULL, "lossy"); |
1428
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1328
diff
changeset
|
423 |
2341
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2334
diff
changeset
|
424 info->title = aud_tuple_formatter_make_title_string(tuple, audmad_config->title_override == TRUE ? |
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2334
diff
changeset
|
425 audmad_config->id3_format : aud_get_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
|
426 |
776
8366ad444313
[svn] - by unknown reason, http connection via proxy server needs a transfer stop after tag retrieving.
yaz
parents:
775
diff
changeset
|
427 // 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
|
428 if (info->infile != NULL) { |
1978 | 429 aud_vfs_fseek(info->infile, -1, SEEK_SET); // an impossible request |
430 aud_vfs_fseek(info->infile, curpos, SEEK_SET); | |
791
91d2b302f479
[svn] - only perform vfs fseek against info::infile if it is available.
nenolod
parents:
789
diff
changeset
|
431 } |
776
8366ad444313
[svn] - by unknown reason, http connection via proxy server needs a transfer stop after tag retrieving.
yaz
parents:
775
diff
changeset
|
432 |
2276
d25cd7e7eddb
append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2214
diff
changeset
|
433 AUDDBG("e: input_read_tag\n"); |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
434 } |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
435 |
2341
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2334
diff
changeset
|
436 void |
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2334
diff
changeset
|
437 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
|
438 { |
1428
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1328
diff
changeset
|
439 gboolean metadata = FALSE; |
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1328
diff
changeset
|
440 |
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
|
441 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
|
442 gchar *tmp = NULL; |
2214
9a869d4bb0d3
make use of AUDDBG() for debug print out.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2142
diff
changeset
|
443 |
773 | 444 #ifdef DEBUG_INTENSIVELY |
2276
d25cd7e7eddb
append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2214
diff
changeset
|
445 AUDDBG("process_remote_meta\n"); |
773 | 446 #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
|
447 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
|
448 info->title = NULL; |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1709
diff
changeset
|
449 aud_tuple_disassociate(info->tuple, FIELD_TITLE, NULL); |
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1709
diff
changeset
|
450 aud_tuple_disassociate(info->tuple, FIELD_ALBUM, NULL); |
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
|
451 |
1978 | 452 tmp = aud_vfs_get_metadata(info->infile, "track-name"); |
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
|
453 if(tmp){ |
1428
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1328
diff
changeset
|
454 metadata = TRUE; |
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1328
diff
changeset
|
455 gchar *scratch; |
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1328
diff
changeset
|
456 |
2050
2ffc6a69fcd1
string API calls -> vtable
William Pitcock <nenolod@atheme.org>
parents:
1985
diff
changeset
|
457 scratch = aud_str_to_utf8(tmp); |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1709
diff
changeset
|
458 aud_tuple_associate_string(info->tuple, FIELD_TITLE, NULL, scratch); |
1428
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1328
diff
changeset
|
459 g_free(scratch); |
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1328
diff
changeset
|
460 |
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
|
461 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
|
462 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
|
463 } |
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
|
464 |
1978 | 465 tmp = aud_vfs_get_metadata(info->infile, "stream-name"); |
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
|
466 if(tmp){ |
1428
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1328
diff
changeset
|
467 metadata = TRUE; |
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1328
diff
changeset
|
468 gchar *scratch; |
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1328
diff
changeset
|
469 |
2050
2ffc6a69fcd1
string API calls -> vtable
William Pitcock <nenolod@atheme.org>
parents:
1985
diff
changeset
|
470 scratch = aud_str_to_utf8(tmp); |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1709
diff
changeset
|
471 aud_tuple_associate_string(info->tuple, FIELD_ALBUM, NULL, scratch); |
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1709
diff
changeset
|
472 aud_tuple_associate_string(info->tuple, -1, "stream", scratch); |
1428
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1328
diff
changeset
|
473 g_free(scratch); |
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1328
diff
changeset
|
474 |
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
|
475 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
|
476 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
|
477 } |
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
|
478 |
1428
4993976d7ed0
madplug: tuple API changes
William Pitcock <nenolod@atheme-project.org>
parents:
1328
diff
changeset
|
479 if (metadata) |
2142
76a19617d685
bugfixed the way shoutcast is formatted ;p
William Pitcock <nenolod@atheme.org>
parents:
2055
diff
changeset
|
480 tmp = aud_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
|
481 else { |
38fb3bb3e21e
- make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1277
diff
changeset
|
482 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
|
483 gchar *tmp2 = g_path_get_basename(realfn ? realfn : info->filename); // info->filename is uri. --yaz |
2050
2ffc6a69fcd1
string API calls -> vtable
William Pitcock <nenolod@atheme.org>
parents:
1985
diff
changeset
|
484 tmp = aud_str_to_utf8(tmp2); |
1328
38fb3bb3e21e
- make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1277
diff
changeset
|
485 g_free(tmp2); tmp2 = NULL; |
38fb3bb3e21e
- make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1277
diff
changeset
|
486 g_free(realfn); realfn = NULL; |
38fb3bb3e21e
- make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1277
diff
changeset
|
487 // 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
|
488 } |
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
|
489 |
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
|
490 /* 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
|
491 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
|
492 ( 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
|
493 { |
1985
a260bd1beef0
use set_params() in madplug
William Pitcock <nenolod@atheme.org>
parents:
1978
diff
changeset
|
494 info->playback->set_params(info->playback, tmp, |
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
|
495 -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
|
496 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
|
497 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
|
498 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
|
499 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
|
500 } |
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
|
501 |
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
|
502 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
|
503 } |
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
|
504 } |
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
|
505 |
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 |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
507 /** |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
508 * Retrieve meta-information about URL. |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
509 * 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
|
510 */ |
2341
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2334
diff
changeset
|
511 gboolean |
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2334
diff
changeset
|
512 input_get_info(struct mad_info_t *info, gboolean fast_scan) |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
513 { |
2214
9a869d4bb0d3
make use of AUDDBG() for debug print out.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2142
diff
changeset
|
514 #ifdef AUD_DEBUG |
799 | 515 gchar *tmp = g_filename_to_utf8(info->filename, -1, NULL, NULL, NULL); |
2276
d25cd7e7eddb
append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2214
diff
changeset
|
516 AUDDBG("f: input_get_info: %s, fast_scan = %s\n", tmp, fast_scan ? "TRUE" : "FALSE"); |
799 | 517 g_free(tmp); |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
518 #endif /* DEBUG */ |
738 | 519 |
773 | 520 input_alloc_tag(info); |
775
a24cc8848b9a
[svn] - with fixed curl, read id3 tag over network works now.
yaz
parents:
773
diff
changeset
|
521 input_read_tag(info); |
773 | 522 |
523 if(!info->remote) { // reduce startup delay | |
2476
809736eb47d9
Some code sanitation and cleanups. Fixes some memory-access problems, but certain others still persist
Matti Hamalainen <ccr@tnsp.org>
parents:
2471
diff
changeset
|
524 audmad_read_replaygain(info); |
773 | 525 } |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
526 |
738 | 527 /* scan mp3 file, decoding headers */ |
611 | 528 if (scan_file(info, fast_scan) == FALSE) { |
2276
d25cd7e7eddb
append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2214
diff
changeset
|
529 AUDDBG("input_get_info: scan_file failed\n"); |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
530 return FALSE; |
611 | 531 } |
738 | 532 |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
533 /* reset the input file to the start */ |
1978 | 534 aud_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
|
535 info->offset = 0; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
536 |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
537 /* use the filename for the title as a last resort */ |
611 | 538 if (!info->title) { |
1328
38fb3bb3e21e
- make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1277
diff
changeset
|
539 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
|
540 if (pos) |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
541 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
|
542 else |
1328
38fb3bb3e21e
- make probing for tuple completely reuse fd.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1277
diff
changeset
|
543 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
|
544 } |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
545 |
2276
d25cd7e7eddb
append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2214
diff
changeset
|
546 AUDDBG("e: input_get_info\n"); |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
547 return TRUE; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
548 } |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
549 |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
550 |
611 | 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 * 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
|
554 * 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
|
555 * @return 0 on EOF |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
556 * @return -1 on error |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
557 */ |
611 | 558 // 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
|
559 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
|
560 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
|
561 int buffer_size) |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
562 { |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
563 int len = 0; |
611 | 564 #ifdef DEBUG_INTENSIVELY |
2276
d25cd7e7eddb
append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2214
diff
changeset
|
565 AUDDBG ("f: input_get_data: %d\n", buffer_size); |
611 | 566 #endif |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
567 /* simply read to data from the file */ |
1978 | 568 len = aud_vfs_fread(buffer, 1, buffer_size, info->infile); //aud_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
|
569 |
789 | 570 if(len == 0 && info->playback){ |
571 info->playback->eof = TRUE; | |
611 | 572 } |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
573 |
611 | 574 #ifdef DEBUG_INTENSIVELY |
2276
d25cd7e7eddb
append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2214
diff
changeset
|
575 AUDDBG ("e: input_get_data: size=%d offset=%d\n", len, info->offset); |
611 | 576 #endif |
2214
9a869d4bb0d3
make use of AUDDBG() for debug print out.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2142
diff
changeset
|
577 |
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
|
578 info->offset += len; |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
579 return len; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
580 } |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
581 |
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 * 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
|
584 */ |
2341
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2334
diff
changeset
|
585 gboolean |
59addab003d7
- reworked replaygain to use individual pre-gain for the files with RG info and the rest.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2334
diff
changeset
|
586 input_term(struct mad_info_t * info) |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
587 { |
2276
d25cd7e7eddb
append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2214
diff
changeset
|
588 AUDDBG("f: input_term\n"); |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
589 |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
590 if (info->title) |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
591 g_free(info->title); |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
592 if (info->url) |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
593 g_free(info->url); |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
594 if (info->filename) |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
595 g_free(info->filename); |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
596 if (info->infile) |
1978 | 597 aud_vfs_fclose(info->infile); |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
598 if (info->id3file) |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
599 id3_file_close(info->id3file); |
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 if (info->replaygain_album_str) |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
602 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
|
603 if (info->replaygain_track_str) |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
604 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
|
605 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
|
606 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
|
607 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
|
608 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
|
609 if (info->mp3gain_undo_str) |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
610 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
|
611 if (info->mp3gain_minmax_str) |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
612 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
|
613 |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
614 if (info->tuple) { |
1976
5fa26178eaef
s/tuple_/aud_tuple_/g
William Pitcock <nenolod@atheme.org>
parents:
1709
diff
changeset
|
615 aud_tuple_free(info->tuple); |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
616 info->tuple = NULL; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
617 } |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
618 |
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
|
619 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
|
620 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
|
621 |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
622 /* 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
|
623 memset(info, 0, sizeof(struct mad_info_t)); |
2214
9a869d4bb0d3
make use of AUDDBG() for debug print out.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2142
diff
changeset
|
624 |
2276
d25cd7e7eddb
append '\n' to format string for AUDDBG()
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2214
diff
changeset
|
625 AUDDBG("e: input_term\n"); |
2214
9a869d4bb0d3
make use of AUDDBG() for debug print out.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
2142
diff
changeset
|
626 |
610
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
627 return TRUE; |
862190d39e00
[svn] - add madplug. It is not yet hooked up, I'll do that later.
nenolod
parents:
diff
changeset
|
628 } |