Mercurial > audlegacy-plugins
annotate src/flacng/tools.c @ 1322:285d54073f12
Fix CFLAGS detection for 1.1.2 stuff.
author | William Pitcock <nenolod@atheme-project.org> |
---|---|
date | Sat, 21 Jul 2007 10:24:13 -0500 |
parents | 47559538ce3d |
children | 263d72004333 |
rev | line source |
---|---|
930
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
1 /* |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
2 * A FLAC decoder plugin for the Audacious Media Player |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
3 * Copyright (C) 2005 Ralf Ertzinger |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
4 * |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
5 * This program is free software; you can redistribute it and/or modify |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
6 * it under the terms of the GNU General Public License as published by |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
7 * the Free Software Foundation; either version 2 of the License, or |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
8 * (at your option) any later version. |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
9 * |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
10 * This program is distributed in the hope that it will be useful, |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
13 * GNU General Public License for more details. |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
14 * |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
16 * along with this program; if not, write to the Free Software |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
18 */ |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
19 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
20 #include <string.h> |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
21 #include <strings.h> |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
22 #include "tools.h" |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
23 #include "debug.h" |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
24 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
25 /* === */ |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
26 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
27 callback_info* init_callback_info(gchar* name) { |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
28 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
29 callback_info* info; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
30 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
31 _ENTER; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
32 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
33 if (NULL == name) { |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
34 _ERROR("Can not allocate callback structure without a name"); |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
35 _LEAVE NULL; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
36 } |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
37 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
38 if (NULL == (info = malloc(sizeof(callback_info)))) { |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
39 _ERROR("Could not allocate memory for callback structure!"); |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
40 _LEAVE NULL; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
41 } |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
42 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
43 if (NULL == (info->output_buffer = malloc(BUFFER_SIZE_BYTE))) { |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
44 _ERROR("Could not allocate memory for output buffer!"); |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
45 _LEAVE NULL; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
46 } |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
47 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
48 /* |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
49 * We need to set this manually to NULL because |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
50 * reset_info will try to close the file pointed to |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
51 * by input_stream if it is non-NULL. |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
52 * Same for info->comment.x |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
53 */ |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
54 info->name = name; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
55 info->input_stream = NULL; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
56 info->comment.artist = NULL; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
57 info->comment.album = NULL; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
58 info->comment.title = NULL; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
59 info->comment.tracknumber = NULL; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
60 info->comment.genre = NULL; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
61 info->comment.date = NULL; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
62 info->replaygain.ref_loud = NULL; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
63 info->replaygain.track_gain = NULL; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
64 info->replaygain.track_peak = NULL; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
65 info->replaygain.album_gain = NULL; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
66 info->replaygain.album_peak = NULL; |
1272
47559538ce3d
- stop read_metadata from stomping on the wrong file descriptors
Ralf Ertzinger <ralf@skytale.net>
parents:
1255
diff
changeset
|
67 reset_info(info, FALSE); |
930
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
68 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
69 _DEBUG("Playback buffer allocated for %d samples, %d bytes", BUFFER_SIZE_SAMP, BUFFER_SIZE_BYTE); |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
70 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
71 _LEAVE info; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
72 } |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
73 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
74 /* --- */ |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
75 |
1272
47559538ce3d
- stop read_metadata from stomping on the wrong file descriptors
Ralf Ertzinger <ralf@skytale.net>
parents:
1255
diff
changeset
|
76 void reset_info(callback_info* info, gboolean close_fd) { |
930
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
77 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
78 _ENTER; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
79 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
80 _DEBUG("Using callback_info %s", info->name); |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
81 |
1272
47559538ce3d
- stop read_metadata from stomping on the wrong file descriptors
Ralf Ertzinger <ralf@skytale.net>
parents:
1255
diff
changeset
|
82 if (close_fd && (NULL != info->input_stream)) { |
47559538ce3d
- stop read_metadata from stomping on the wrong file descriptors
Ralf Ertzinger <ralf@skytale.net>
parents:
1255
diff
changeset
|
83 _DEBUG("Closing fd"); |
930
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
84 vfs_fclose(info->input_stream); |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
85 } |
1272
47559538ce3d
- stop read_metadata from stomping on the wrong file descriptors
Ralf Ertzinger <ralf@skytale.net>
parents:
1255
diff
changeset
|
86 info->input_stream = NULL; |
930
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
87 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
88 // memset(info->output_buffer, 0, BUFFER_SIZE * sizeof(int16_t)); |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
89 info->stream.samplerate = 0; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
90 info->stream.bits_per_sample = 0; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
91 info->stream.channels = 0; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
92 info->stream.samples = 0; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
93 info->stream.has_seektable = FALSE; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
94 info->buffer_free = BUFFER_SIZE_SAMP; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
95 info->buffer_used = 0; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
96 info->write_pointer = info->output_buffer; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
97 info->read_max = -1; |
1041 | 98 info->testing = FALSE; |
930
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
99 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
100 /* |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
101 * Clear the stream and frame information |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
102 */ |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
103 info->stream.bits_per_sample = 0; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
104 info->stream.samplerate = 0; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
105 info->stream.channels = 0; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
106 info->stream.samples = 0; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
107 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
108 if (NULL != info->comment.artist) { |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
109 free(info->comment.artist); |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
110 info->comment.artist = NULL; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
111 } |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
112 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
113 if (NULL != info->comment.album) { |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
114 free(info->comment.album); |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
115 info->comment.album = NULL; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
116 } |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
117 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
118 if (NULL != info->comment.title) { |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
119 free(info->comment.title); |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
120 info->comment.title = NULL; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
121 } |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
122 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
123 if (NULL != info->comment.tracknumber) { |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
124 free(info->comment.tracknumber); |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
125 info->comment.tracknumber = NULL; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
126 } |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
127 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
128 if (NULL != info->comment.genre) { |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
129 free(info->comment.genre); |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
130 info->comment.genre = NULL; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
131 } |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
132 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
133 if (NULL != info->replaygain.ref_loud) { |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
134 free(info->replaygain.ref_loud); |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
135 info->replaygain.ref_loud = NULL; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
136 } |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
137 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
138 if (NULL != info->replaygain.track_gain) { |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
139 free(info->replaygain.track_gain); |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
140 info->replaygain.track_gain = NULL; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
141 } |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
142 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
143 if (NULL != info->replaygain.track_peak) { |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
144 free(info->replaygain.track_peak); |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
145 info->replaygain.track_peak = NULL; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
146 } |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
147 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
148 if (NULL != info->replaygain.album_gain) { |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
149 free(info->replaygain.album_gain); |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
150 info->replaygain.album_gain = NULL; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
151 } |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
152 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
153 if (NULL != info->replaygain.album_peak) { |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
154 free(info->replaygain.album_peak); |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
155 info->replaygain.album_peak = NULL; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
156 } |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
157 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
158 info->replaygain.has_rg = FALSE; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
159 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
160 if (NULL != info->comment.date) { |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
161 free(info->comment.date); |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
162 info->comment.date = NULL; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
163 } |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
164 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
165 info->frame.bits_per_sample = 0; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
166 info->frame.samplerate = 0; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
167 info->frame.channels = 0; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
168 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
169 info->metadata_changed = FALSE; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
170 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
171 _LEAVE; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
172 } |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
173 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
174 /* --- */ |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
175 |
1255 | 176 gboolean read_metadata(VFSFile* fd, FLAC__StreamDecoder* decoder, callback_info* info) { |
930
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
177 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
178 FLAC__StreamDecoderState ret; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
179 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
180 _ENTER; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
181 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
182 _DEBUG("Using callback_info %s", info->name); |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
183 |
1272
47559538ce3d
- stop read_metadata from stomping on the wrong file descriptors
Ralf Ertzinger <ralf@skytale.net>
parents:
1255
diff
changeset
|
184 reset_info(info, FALSE); |
47559538ce3d
- stop read_metadata from stomping on the wrong file descriptors
Ralf Ertzinger <ralf@skytale.net>
parents:
1255
diff
changeset
|
185 |
47559538ce3d
- stop read_metadata from stomping on the wrong file descriptors
Ralf Ertzinger <ralf@skytale.net>
parents:
1255
diff
changeset
|
186 info->input_stream = fd; |
47559538ce3d
- stop read_metadata from stomping on the wrong file descriptors
Ralf Ertzinger <ralf@skytale.net>
parents:
1255
diff
changeset
|
187 |
930
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
188 /* |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
189 * Reset the decoder |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
190 */ |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
191 if (false == FLAC__stream_decoder_reset(decoder)) { |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
192 _ERROR("Could not reset the decoder!"); |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
193 _LEAVE FALSE; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
194 } |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
195 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
196 /* |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
197 * Just scan the first 8k for the start of metadata |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
198 */ |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
199 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
200 info->read_max = 8192; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
201 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
202 /* |
1041 | 203 * We are not sure if this is an actual flac file, so do not |
204 * complain too much about errors in the stream | |
205 */ | |
206 info->testing = TRUE; | |
207 | |
208 /* | |
930
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
209 * Try to decode the metadata |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
210 */ |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
211 if (false == FLAC__stream_decoder_process_until_end_of_metadata(decoder)) { |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
212 ret = FLAC__stream_decoder_get_state(decoder); |
1246 | 213 _DEBUG("Could not read the metadata: %s(%d)!", |
214 FLAC__StreamDecoderStateString[ret], ret); | |
1255 | 215 /* Do not close the filehandle, it was passed to us */ |
1272
47559538ce3d
- stop read_metadata from stomping on the wrong file descriptors
Ralf Ertzinger <ralf@skytale.net>
parents:
1255
diff
changeset
|
216 reset_info(info, FALSE); |
930
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
217 _LEAVE FALSE; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
218 } |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
219 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
220 /* |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
221 * Seems to be a FLAC stream. Allow further reading |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
222 */ |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
223 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
224 info->read_max = -1; |
1041 | 225 info->testing = FALSE; |
930
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
226 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
227 _LEAVE TRUE; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
228 } |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
229 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
230 /* --- */ |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
231 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
232 static const gchar* get_extension(const gchar* filename) { |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
233 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
234 _ENTER; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
235 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
236 const gchar *ext = strrchr(filename, '.'); |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
237 _LEAVE ext ? ext + 1 : NULL; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
238 } |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
239 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
240 /* --- */ |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
241 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
242 TitleInput* get_tuple(const gchar* filename, callback_info* info) { |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
243 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
244 TitleInput *out; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
245 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
246 _ENTER; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
247 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
248 _DEBUG("Using callback_info %s", info->name); |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
249 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
250 out = bmp_title_input_new(); |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
251 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
252 out->file_name = g_path_get_basename(filename); |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
253 out->file_ext = get_extension(filename); |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
254 out->file_path = g_path_get_dirname(filename); |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
255 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
256 out->performer = g_strdup(info->comment.artist); |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
257 out->track_name = g_strdup(info->comment.title); |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
258 out->album_name = g_strdup(info->comment.album); |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
259 out->genre = g_strdup(info->comment.genre); |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
260 if (info->comment.tracknumber != NULL) |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
261 out->track_number = atoi(info->comment.tracknumber); |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
262 if (info->comment.date != NULL) |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
263 out->year = atoi(info->comment.date); |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
264 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
265 /* |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
266 * Calculate the stream length (milliseconds) |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
267 */ |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
268 if (0 == info->stream.samplerate) { |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
269 _ERROR("Invalid sample rate for stream!"); |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
270 out->length = -1; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
271 } else { |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
272 out->length = (info->stream.samples / info->stream.samplerate) * 1000; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
273 _DEBUG("Stream length: %d seconds", out->length / 1000); |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
274 } |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
275 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
276 _DEBUG("Tuple created: [%p]", out); |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
277 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
278 _LEAVE out; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
279 } |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
280 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
281 /* --- */ |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
282 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
283 gchar* get_title(const gchar* filename, callback_info* info) { |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
284 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
285 TitleInput *input; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
286 gchar *title; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
287 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
288 _ENTER; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
289 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
290 _DEBUG("Using callback_info %s", info->name); |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
291 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
292 input = get_tuple(filename, info); |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
293 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
294 if (!(title = xmms_get_titlestring(xmms_get_gentitle_format(), input))) |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
295 title = g_strdup(input->file_name); |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
296 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
297 bmp_title_input_free(input); |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
298 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
299 _DEBUG("Title created: <%s>", title); |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
300 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
301 _LEAVE title; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
302 } |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
303 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
304 /* --- */ |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
305 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
306 void add_comment(callback_info* info, gchar* key, gchar* value) { |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
307 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
308 /* |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
309 * We are currently interested in comments of type |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
310 * - ARTIST |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
311 * - ALBUM |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
312 * - TITLE |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
313 * - TRACKNUMBER |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
314 * |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
315 * We have to create copies of the value string. |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
316 */ |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
317 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
318 gchar** destination = NULL; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
319 gboolean rg = FALSE; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
320 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
321 _ENTER; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
322 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
323 _DEBUG("Using callback_info %s", info->name); |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
324 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
325 if (0 == strcasecmp(key, "ARTIST")) { |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
326 _DEBUG("Found key ARTIST"); |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
327 destination = &(info->comment.artist); |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
328 } |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
329 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
330 if (0 == strcasecmp(key, "ALBUM")) { |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
331 _DEBUG("Found key ALBUM"); |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
332 destination = &(info->comment.album); |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
333 } |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
334 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
335 if (0 == strcasecmp(key, "TITLE")) { |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
336 _DEBUG("Found key TITLE"); |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
337 destination = &(info->comment.title); |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
338 } |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
339 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
340 if (0 == strcasecmp(key, "TRACKNUMBER")) { |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
341 _DEBUG("Found key TRACKNUMBER"); |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
342 destination = &(info->comment.tracknumber); |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
343 } |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
344 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
345 if (0 == strcasecmp(key, "REPLAYGAIN_REFERENCE_LOUDNESS")) { |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
346 _DEBUG("Found key REPLAYGAIN_REFERENCE_LOUDNESS"); |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
347 destination = &(info->replaygain.ref_loud); |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
348 rg = TRUE; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
349 } |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
350 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
351 if (0 == strcasecmp(key, "REPLAYGAIN_TRACK_GAIN")) { |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
352 _DEBUG("Found key REPLAYGAIN_TRACK_GAIN"); |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
353 destination = &(info->replaygain.track_gain); |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
354 rg = TRUE; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
355 } |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
356 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
357 if (0 == strcasecmp(key, "REPLAYGAIN_TRACK_PEAK")) { |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
358 _DEBUG("Found key REPLAYGAIN_TRACK_PEAK"); |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
359 destination = &(info->replaygain.track_peak); |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
360 rg = TRUE; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
361 } |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
362 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
363 if (0 == strcasecmp(key, "REPLAYGAIN_ALBUM_GAIN")) { |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
364 _DEBUG("Found key REPLAYGAIN_ALBUM_GAIN"); |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
365 destination = &(info->replaygain.album_gain); |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
366 rg = TRUE; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
367 } |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
368 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
369 if (0 == strcasecmp(key, "REPLAYGAIN_ALBUM_PEAK")) { |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
370 _DEBUG("Found key REPLAYGAIN_ALBUM_PEAK"); |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
371 destination = &(info->replaygain.album_peak); |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
372 rg = TRUE; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
373 } |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
374 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
375 if (0 == strcasecmp(key, "DATE")) { |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
376 _DEBUG("Found key DATE"); |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
377 destination = &(info->comment.date); |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
378 } |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
379 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
380 if (0 == strcasecmp(key, "GENRE")) { |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
381 _DEBUG("Found key GENRE"); |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
382 destination = &(info->comment.genre); |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
383 } |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
384 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
385 if (NULL != destination) { |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
386 if (NULL != *destination) { |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
387 g_free(*destination); |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
388 } |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
389 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
390 if (NULL == (*destination = g_strdup(value))) { |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
391 _ERROR("Could not allocate memory for comment!"); |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
392 _LEAVE; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
393 } |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
394 } |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
395 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
396 if (rg) { |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
397 info->replaygain.has_rg = TRUE; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
398 } |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
399 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
400 _LEAVE; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
401 } |