~mixxxdevelopers/mixxx/features_flac

« back to all changes in this revision

Viewing changes to mixxx/src/soundsourceflac.cpp

  • Committer: Bill Good
  • Date: 2010-07-02 15:18:22 UTC
  • Revision ID: bkgood@gmail.com-20100702151822-l99f91y2t707ok0p
Consolidated a bunch of heavily-duplicated error handling code in
    SSFLAC::open and removed some qDebugs()

Show diffs side-by-side

added added

removed removed

Lines of Context:
56
56
    }
57
57
    if (!FLAC__stream_decoder_set_metadata_respond(m_decoder,
58
58
                FLAC__METADATA_TYPE_VORBIS_COMMENT)) {
59
 
        qDebug() << "SSFLAC: set metadata responde to vorbis comments failed";
60
 
        return ERR;
 
59
        qDebug() << "SSFLAC: set metadata respond to vorbis comments failed";
 
60
        goto decoderError;
61
61
    }
62
62
    FLAC__StreamDecoderInitStatus initStatus;
63
63
    initStatus = FLAC__stream_decoder_init_stream(
66
66
        (void*) this);
67
67
    if (initStatus != FLAC__STREAM_DECODER_INIT_STATUS_OK) {
68
68
        qDebug() << "SSFLAC: decoder init failed!";
69
 
        FLAC__stream_decoder_finish(m_decoder);
70
 
        FLAC__stream_decoder_delete(m_decoder);
71
 
        m_decoder = NULL;
72
 
        return ERR;
 
69
        goto decoderError;
73
70
    }
74
71
    if (!FLAC__stream_decoder_process_until_end_of_metadata(m_decoder)) {
75
72
        qDebug() << "SSFLAC: process to end of meta failed!";
76
73
        qDebug() << "SSFLAC: decoder state: " << FLAC__stream_decoder_get_state(m_decoder);
77
 
        FLAC__stream_decoder_finish(m_decoder);
78
 
        FLAC__stream_decoder_delete(m_decoder);
79
 
        m_decoder = NULL;
80
 
        return ERR;
 
74
        goto decoderError;
81
75
    } // now number of samples etc. should be populated
82
76
    if (m_bps != 16) {
83
77
        qDebug() << "SoundSourceFLAC only supports FLAC files encoded at 16 bits per sample.";
84
 
        FLAC__stream_decoder_finish(m_decoder);
85
 
        FLAC__stream_decoder_delete(m_decoder);
86
 
        m_decoder = NULL;
87
 
        return ERR;
 
78
        goto decoderError;
88
79
    }
89
80
    if (m_flacBuffer == NULL) {
90
81
        m_flacBuffer = new FLAC__int16[m_maxBlocksize * m_iChannels];
97
88
    qDebug() << "SSFLAC: Channels: " << m_iChannels;
98
89
    qDebug() << "SSFLAC: BPS: " << m_bps;
99
90
    return OK;
 
91
decoderError:
 
92
    FLAC__stream_decoder_finish(m_decoder);
 
93
    FLAC__stream_decoder_delete(m_decoder);
 
94
    m_decoder = NULL;
 
95
    return ERR;
100
96
}
101
97
 
102
98
long SoundSourceFLAC::seek(long filepos) {
267
263
        m_maxBlocksize = metadata->data.stream_info.max_blocksize;
268
264
        m_minFramesize = metadata->data.stream_info.min_framesize;
269
265
        m_maxFramesize = metadata->data.stream_info.max_framesize;
270
 
        qDebug() << "FLAC file " << m_qFilename;
271
 
        qDebug() << m_iChannels << " @ " << m_iSampleRate << " Hz, " << m_samples
272
 
            << " total, " << m_bps << " bps";
273
 
        qDebug() << "Blocksize in [" << m_minBlocksize << ", " << m_maxBlocksize
274
 
            << "], Framesize in [" << m_minFramesize << ", " << m_maxFramesize << "]";
 
266
//        qDebug() << "FLAC file " << m_qFilename;
 
267
//        qDebug() << m_iChannels << " @ " << m_iSampleRate << " Hz, " << m_samples
 
268
//            << " total, " << m_bps << " bps";
 
269
//        qDebug() << "Blocksize in [" << m_minBlocksize << ", " << m_maxBlocksize
 
270
//            << "], Framesize in [" << m_minFramesize << ", " << m_maxFramesize << "]";
275
271
        break;
276
272
    case FLAC__METADATA_TYPE_VORBIS_COMMENT:
277
273
        for (unsigned int i = 0; i < metadata->data.vorbis_comment.num_comments; ++i) {