Mercurial > audlegacy-plugins
annotate src/flacng/seekable_stream_callbacks.c @ 2196:dfa3c3aa2dc7
switched to mowgli_dictionary from GHashTable
author | Eugene Zagidullin <e.asphyx@gmail.com> |
---|---|
date | Thu, 29 Nov 2007 03:09:13 +0300 |
parents | fa9f85cebade |
children | ead24454f4b7 |
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 <FLAC/all.h> |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
22 #include <glib.h> |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
23 #include <audacious/vfs.h> |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
24 #include "flacng.h" |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
25 #include "tools.h" |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
26 #include "seekable_stream_callbacks.h" |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
27 #include "debug.h" |
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 /* === */ |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
30 |
1187
875baf383f0c
suppress warnings on AMD64.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1041
diff
changeset
|
31 FLAC__StreamDecoderReadStatus read_callback(const FLAC__StreamDecoder *decoder, FLAC__byte buffer[], size_t *bytes, void *client_data) { |
930
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 callback_info* info; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
34 gint to_read; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
35 size_t read; |
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 _ENTER; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
38 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
39 info = (callback_info*) client_data; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
40 _DEBUG("Using callback_info %s", info->name); |
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 if (NULL == info->input_stream) { |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
43 _ERROR("Trying to read data from an uninitialized file!"); |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
44 _LEAVE FLAC__STREAM_DECODER_READ_STATUS_ABORT; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
45 } |
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 if (0 <= info->read_max) { |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
48 to_read = MIN(*bytes, info->read_max); |
1246 | 49 _DEBUG("Reading restricted to %ld bytes", info->read_max); |
930
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
50 } else { |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
51 to_read = *bytes; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
52 } |
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 if (0 == to_read) { |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
55 _LEAVE FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
56 } |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
57 |
1978 | 58 read = aud_vfs_fread(buffer, 1, to_read, info->input_stream); |
930
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
59 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
60 if ((0 < read) && (0 < info->read_max)) { |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
61 info->read_max -= read; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
62 } |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
63 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
64 _DEBUG("Wanted %d bytes, got %d bytes", *bytes, read); |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
65 *bytes = read; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
66 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
67 switch(read) { |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
68 case -1: |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
69 _ERROR("Error while reading from stream!"); |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
70 _LEAVE FLAC__STREAM_DECODER_READ_STATUS_ABORT; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
71 break; |
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 case 0: |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
74 _DEBUG("Stream reached EOF"); |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
75 _LEAVE FLAC__STREAM_DECODER_READ_STATUS_END_OF_STREAM; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
76 break; |
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 default: |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
79 _LEAVE FLAC__STREAM_DECODER_READ_STATUS_CONTINUE; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
80 } |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
81 } |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
82 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
83 /* --- */ |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
84 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
85 FLAC__StreamDecoderSeekStatus seek_callback(const FLAC__StreamDecoder *decoder, FLAC__uint64 absolute_byte_offset, void *client_data) { |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
86 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
87 callback_info* info; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
88 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
89 _ENTER; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
90 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
91 info = (callback_info*) client_data; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
92 _DEBUG("Using callback_info %s", info->name); |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
93 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
94 _DEBUG("Seeking to %lld", absolute_byte_offset); |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
95 |
1978 | 96 if (0 != aud_vfs_fseek(info->input_stream, absolute_byte_offset, SEEK_SET)) { |
1187
875baf383f0c
suppress warnings on AMD64.
Yoshiki Yazawa <yaz@cc.rim.or.jp>
parents:
1041
diff
changeset
|
97 _ERROR("Could not seek to %lld!", (long long)absolute_byte_offset); |
930
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
98 _LEAVE FLAC__STREAM_DECODER_SEEK_STATUS_ERROR; |
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 _LEAVE FLAC__STREAM_DECODER_SEEK_STATUS_OK; |
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 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
104 /* --- */ |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
105 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
106 FLAC__StreamDecoderTellStatus tell_callback(const FLAC__StreamDecoder *decoder, FLAC__uint64 *absolute_byte_offset, void *client_data) { |
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 callback_info* info; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
109 glong position; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
110 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
111 _ENTER; |
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 info = (callback_info*) client_data; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
114 _DEBUG("Using callback_info %s", info->name); |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
115 |
1978 | 116 if (-1 == (position = aud_vfs_ftell(info->input_stream))) { |
931 | 117 _ERROR("Could not tell current position!"); |
1272
47559538ce3d
- stop read_metadata from stomping on the wrong file descriptors
Ralf Ertzinger <ralf@skytale.net>
parents:
1259
diff
changeset
|
118 _LEAVE FLAC__STREAM_DECODER_TELL_STATUS_ERROR; |
930
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
119 } |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
120 |
1246 | 121 _DEBUG("Current position: %ld", position); |
930
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 *absolute_byte_offset = position; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
124 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
125 _LEAVE FLAC__STREAM_DECODER_TELL_STATUS_OK; |
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 /* --- */ |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
129 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
130 FLAC__bool eof_callback(const FLAC__StreamDecoder *decoder, void *client_data) { |
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 callback_info* info; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
133 gboolean eof; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
134 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
135 _ENTER; |
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 info = (callback_info*) client_data; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
138 _DEBUG("Using callback_info %s", info->name); |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
139 |
1259
690659633ec5
- Fix endless looping on certain unparseable streams
Ralf Ertzinger <ralf@skytale.net>
parents:
1246
diff
changeset
|
140 /* |
690659633ec5
- Fix endless looping on certain unparseable streams
Ralf Ertzinger <ralf@skytale.net>
parents:
1246
diff
changeset
|
141 * If we are testing a stream and use restricted reading, |
690659633ec5
- Fix endless looping on certain unparseable streams
Ralf Ertzinger <ralf@skytale.net>
parents:
1246
diff
changeset
|
142 * return EOF if we have exhausted our alotted reading |
690659633ec5
- Fix endless looping on certain unparseable streams
Ralf Ertzinger <ralf@skytale.net>
parents:
1246
diff
changeset
|
143 * quota |
690659633ec5
- Fix endless looping on certain unparseable streams
Ralf Ertzinger <ralf@skytale.net>
parents:
1246
diff
changeset
|
144 */ |
690659633ec5
- Fix endless looping on certain unparseable streams
Ralf Ertzinger <ralf@skytale.net>
parents:
1246
diff
changeset
|
145 if (0 == info->read_max) { |
690659633ec5
- Fix endless looping on certain unparseable streams
Ralf Ertzinger <ralf@skytale.net>
parents:
1246
diff
changeset
|
146 _DEBUG("read_max exhausted, faking EOF"); |
1272
47559538ce3d
- stop read_metadata from stomping on the wrong file descriptors
Ralf Ertzinger <ralf@skytale.net>
parents:
1259
diff
changeset
|
147 _LEAVE TRUE; |
1259
690659633ec5
- Fix endless looping on certain unparseable streams
Ralf Ertzinger <ralf@skytale.net>
parents:
1246
diff
changeset
|
148 } |
690659633ec5
- Fix endless looping on certain unparseable streams
Ralf Ertzinger <ralf@skytale.net>
parents:
1246
diff
changeset
|
149 |
1978 | 150 eof = aud_vfs_feof(info->input_stream); |
930
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 _LEAVE eof; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
153 } |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
154 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
155 /* --- */ |
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 FLAC__StreamDecoderLengthStatus length_callback(const FLAC__StreamDecoder *decoder, FLAC__uint64 *stream_length, void *client_data) { |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
158 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
159 callback_info* info; |
966 | 160 off_t size; |
930
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
161 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
162 _ENTER; |
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 info = (callback_info*) client_data; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
165 _DEBUG("Using callback_info %s", info->name); |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
166 |
1978 | 167 if (-1 == (size = aud_vfs_fsize(info->input_stream))) { |
966 | 168 /* |
169 * Could not get the stream size. This is not necessarily an | |
170 * error, maybe the stream has no fixed size (think streaming | |
171 * audio) | |
172 */ | |
173 _DEBUG("Stream length unknown"); | |
174 *stream_length = 0; | |
175 _LEAVE FLAC__STREAM_DECODER_LENGTH_STATUS_UNSUPPORTED; | |
931 | 176 } |
177 | |
1246 | 178 _DEBUG("Stream length is %ld bytes", size); |
966 | 179 *stream_length = size; |
930
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
180 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
181 _LEAVE FLAC__STREAM_DECODER_LENGTH_STATUS_OK; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
182 } |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
183 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
184 /* --- */ |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
185 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
186 FLAC__StreamDecoderWriteStatus write_callback(const FLAC__StreamDecoder *decoder, const FLAC__Frame *frame, const FLAC__int32 * const buffer[], void *client_data) { |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
187 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
188 glong i; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
189 gshort j; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
190 callback_info* info; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
191 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
192 _ENTER; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
193 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
194 info = (callback_info*) client_data; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
195 _DEBUG("Using callback_info %s", info->name); |
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 _DEBUG("Frame decoded: %d samples per channel, %d channels, %d bps", |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
198 frame->header.blocksize, frame->header.channels, frame->header.bits_per_sample); |
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 /* |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
201 * Check if there is more data decoded than we have space |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
202 * for. This _should_ not happen given how our buffer is sized, |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
203 * but you never know. |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
204 */ |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
205 if (info->buffer_free < (frame->header.blocksize * frame->header.channels)) { |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
206 _ERROR("BUG! Too much data decoded from stream!"); |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
207 _LEAVE FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
208 } |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
209 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
210 if ((frame->header.bits_per_sample != 8) && |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
211 (frame->header.bits_per_sample != 16) && |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
212 (frame->header.bits_per_sample != 24)) { |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
213 _ERROR("Unsupported bitrate found in stream: %d!", frame->header.bits_per_sample); |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
214 _LEAVE FLAC__STREAM_DECODER_WRITE_STATUS_ABORT; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
215 } |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
216 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
217 /* |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
218 * Copy the frame metadata, will be compared to stream |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
219 * metadata later |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
220 * This also describes the format of the current buffer content. |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
221 */ |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
222 info->frame.channels = frame->header.channels; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
223 info->frame.samplerate = frame->header.sample_rate; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
224 info->frame.bits_per_sample = frame->header.bits_per_sample; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
225 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
226 for (i=0; i < frame->header.blocksize; i++) { |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
227 for (j=0; j < frame->header.channels; j++) { |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
228 *(info->write_pointer++) = buffer[j][i]; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
229 info->buffer_free -= 1; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
230 info->buffer_used += 1; |
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 } |
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 _DEBUG("free space in buffer after copying: %d samples", info->buffer_free); |
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 _LEAVE FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
237 } |
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 void error_callback(const FLAC__StreamDecoder *decoder, FLAC__StreamDecoderErrorStatus status, void *client_data) { |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
242 |
1041 | 243 callback_info* info = (callback_info*) client_data; |
244 | |
930
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
245 _ENTER; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
246 |
1041 | 247 _DEBUG("Using callback_info %s", info->name); |
248 | |
249 if (!info->testing) { | |
250 _ERROR("FLAC decoder error callback was called: %d", status); | |
251 } else { | |
252 _DEBUG("FLAC decoder error callback was called: %d", status); | |
253 } | |
930
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
254 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
255 _LEAVE; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
256 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
257 } |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
258 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
259 /* --- */ |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
260 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
261 void metadata_callback(const FLAC__StreamDecoder *decoder, const FLAC__StreamMetadata *metadata, void *client_data) { |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
262 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
263 callback_info* info; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
264 gint i; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
265 FLAC__StreamMetadata_VorbisComment_Entry* entry; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
266 FLAC__StreamMetadata* metadata_copy; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
267 gchar* key; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
268 gchar* value; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
269 int artist_offset; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
270 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
271 _ENTER; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
272 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
273 info = (callback_info*) client_data; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
274 _DEBUG("Using callback_info %s", info->name); |
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 /* |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
277 * We have found a metadata block. Enable unrestricted reading |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
278 */ |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
279 info->read_max = -1; |
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 if (FLAC__METADATA_TYPE_STREAMINFO == metadata->type) { |
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 * Basic stream information. Sample rate, channels and stuff |
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 _DEBUG("FLAC__METADATA_TYPE_STREAMINFO found"); |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
286 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
287 info->stream.samples = metadata->data.stream_info.total_samples; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
288 _DEBUG("total_samples=%lld", metadata->data.stream_info.total_samples); |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
289 info->stream.bits_per_sample = metadata->data.stream_info.bits_per_sample; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
290 _DEBUG("bits_per_sample=%d", metadata->data.stream_info.bits_per_sample); |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
291 info->stream.channels = metadata->data.stream_info.channels; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
292 _DEBUG("channels=%d", metadata->data.stream_info.channels); |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
293 info->stream.samplerate = metadata->data.stream_info.sample_rate; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
294 _DEBUG("sample_rate=%d", metadata->data.stream_info.sample_rate); |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
295 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
296 info->metadata_changed = TRUE; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
297 } |
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 if (FLAC__METADATA_TYPE_VORBIS_COMMENT == metadata->type) { |
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 * We will possibly need to modify some of the entries |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
302 * in the metadata field, so we make a copy of it |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
303 * first. |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
304 * The original structure must not be modified. |
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 metadata_copy = FLAC__metadata_object_clone(metadata); |
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 * A vorbis type comment field. |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
310 */ |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
311 _DEBUG("FLAC__METADATA_TYPE_VORBIS_COMMENT found"); |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
312 _DEBUG("Vorbis comment contains %d fields", metadata_copy->data.vorbis_comment.num_comments); |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
313 _DEBUG("Vendor string: %s", metadata_copy->data.vorbis_comment.vendor_string.entry); |
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 /* |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
316 * Find an ARTIST field |
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 if (0 <= (artist_offset = FLAC__metadata_object_vorbiscomment_find_entry_from(metadata_copy, 0, "ARTIST"))) { |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
319 _DEBUG("ARTIST field found @ %d: %s", artist_offset, |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
320 metadata_copy->data.vorbis_comment.comments[artist_offset].entry); |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
321 } |
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 |
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 * Enumerate the comment entries |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
326 */ |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
327 entry = metadata_copy->data.vorbis_comment.comments; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
328 for (i=0; i < metadata_copy->data.vorbis_comment.num_comments; i++,entry++) { |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
329 _DEBUG("Comment[%d]: %s", i, entry->entry); |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
330 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
331 /* |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
332 * Try and parse the comment. |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
333 * If FLAC__metadata_object_vorbiscomment_entry_to_name_value_pair() succeeds, |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
334 * it allocates memory for the key and value which we have to take |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
335 * care of. |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
336 */ |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
337 if (false == FLAC__metadata_object_vorbiscomment_entry_to_name_value_pair(*entry, &key, &value)) { |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
338 _DEBUG("Could not parse comment"); |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
339 } else { |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
340 _DEBUG("Key: <%s>, Value <%s>", key, value); |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
341 add_comment(info, key, value); |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
342 free(key); |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
343 free(value); |
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 } |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
346 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
347 /* |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
348 * Free our metadata copy |
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 FLAC__metadata_object_delete(metadata_copy); |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
351 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
352 info->metadata_changed = TRUE; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
353 } |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
354 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
355 if (FLAC__METADATA_TYPE_SEEKTABLE == metadata->type) { |
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 * We have found a seektable, which means that we can seek |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
358 * without telling FLAC the length of the file (which we can not |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
359 * do, since Audacious lacks the functions for that) |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
360 */ |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
361 _DEBUG("FLAC__METADATA_TYPE_SEEKTABLE found"); |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
362 info->stream.has_seektable = TRUE; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
363 } |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
364 |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
365 _LEAVE; |
2f742d127b3e
[svn] - initial import of flacng from audacious-flacng-0.012
nenolod
parents:
diff
changeset
|
366 } |