1
1
/* metaflac - Command-line FLAC metadata editor
2
* Copyright (C) 2001,2002,2003,2004,2005,2006,2007 Josh Coalson
2
* Copyright (C) 2001-2009 Josh Coalson
3
* Copyright (C) 2011-2013 Xiph.Org Foundation
4
5
* This program is free software; you can redistribute it and/or
5
6
* modify it under the terms of the GNU General Public License
11
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
13
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
15
* You should have received a copy of the GNU General Public License along
16
* with this program; if not, write to the Free Software Foundation, Inc.,
17
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
53
54
} while(!found_seektable_block && FLAC__metadata_iterator_next(iterator));
55
56
if(total_samples == 0) {
56
fprintf(stderr, "%s: ERROR: cannot add seekpoints because STREAMINFO block does not specify total_samples\n", filename);
57
flac_fprintf(stderr, "%s: ERROR: cannot add seekpoints because STREAMINFO block does not specify total_samples\n", filename);
79
80
FLAC__ASSERT(block->type == FLAC__METADATA_TYPE_SEEKTABLE);
81
82
if(!grabbag__seektable_convert_specification_to_template(specification, /*only_explicit_placeholders=*/false, total_samples, sample_rate, block, /*spec_has_real_points=*/0)) {
82
fprintf(stderr, "%s: ERROR (internal) preparing seektable with seekpoints\n", filename);
83
flac_fprintf(stderr, "%s: ERROR (internal) preparing seektable with seekpoints\n", filename);
178
179
decoder = FLAC__stream_decoder_new();
180
181
if(0 == decoder) {
181
fprintf(stderr, "%s: ERROR (--add-seekpoint) creating the decoder instance\n", filename);
182
flac_fprintf(stderr, "%s: ERROR (--add-seekpoint) creating the decoder instance\n", filename);
186
187
FLAC__stream_decoder_set_metadata_ignore_all(decoder);
188
189
if(FLAC__stream_decoder_init_file(decoder, filename, write_callback_, /*metadata_callback=*/0, error_callback_, &client_data) != FLAC__STREAM_DECODER_INIT_STATUS_OK) {
189
fprintf(stderr, "%s: ERROR (--add-seekpoint) initializing the decoder instance (%s)\n", filename, FLAC__stream_decoder_get_resolved_state_string(decoder));
190
flac_fprintf(stderr, "%s: ERROR (--add-seekpoint) initializing the decoder instance (%s)\n", filename, FLAC__stream_decoder_get_resolved_state_string(decoder));
193
194
if(ok && !FLAC__stream_decoder_process_until_end_of_metadata(decoder)) {
194
fprintf(stderr, "%s: ERROR (--add-seekpoint) decoding file (%s)\n", filename, FLAC__stream_decoder_get_resolved_state_string(decoder));
195
flac_fprintf(stderr, "%s: ERROR (--add-seekpoint) decoding file (%s)\n", filename, FLAC__stream_decoder_get_resolved_state_string(decoder));
198
199
if(ok && !FLAC__stream_decoder_get_decode_position(decoder, &client_data.audio_offset)) {
199
fprintf(stderr, "%s: ERROR (--add-seekpoint) decoding file\n", filename);
200
flac_fprintf(stderr, "%s: ERROR (--add-seekpoint) decoding file\n", filename);
202
203
client_data.last_offset = client_data.audio_offset;
204
205
if(ok && !FLAC__stream_decoder_process_until_end_of_stream(decoder)) {
205
fprintf(stderr, "%s: ERROR (--add-seekpoint) decoding file (%s)\n", filename, FLAC__stream_decoder_get_resolved_state_string(decoder));
206
flac_fprintf(stderr, "%s: ERROR (--add-seekpoint) decoding file (%s)\n", filename, FLAC__stream_decoder_get_resolved_state_string(decoder));
209
210
if(ok && client_data.error_occurred) {
210
fprintf(stderr, "%s: ERROR (--add-seekpoint) decoding file (%u:%s)\n", filename, (unsigned)client_data.error_status, FLAC__StreamDecoderErrorStatusString[client_data.error_status]);
211
flac_fprintf(stderr, "%s: ERROR (--add-seekpoint) decoding file (%u:%s)\n", filename, (unsigned)client_data.error_status, FLAC__StreamDecoderErrorStatusString[client_data.error_status]);