~ubuntu-branches/ubuntu/lucid/lastfm/lucid

« back to all changes in this revision

Viewing changes to src/libFingerprint/Fingerprinter2.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Devid Filoni
  • Date: 2008-07-14 16:46:20 UTC
  • mfrom: (1.1.7 upstream) (3.1.1 lenny)
  • Revision ID: james.westby@ubuntu.com-20080714164620-67hoz9fs177wpgmr
Tags: 1:1.5.1.31879.dfsg-1ubuntu1
* Merge from Debian unstable (LP: #248100), remaining changes:
  - debian/rules: add dh_icons call
  + debian/control:
    - switch iceweasel to firefox in Recommends field
    - modify debhelper version to >= 5.0.51~
    - modify Maintainer to Ubuntu MOTU Developers

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
 
23
23
#include "interfaces/TranscodeInterface.h"
24
24
 
 
25
#include "logger.h"
25
26
#include "Sha256File.h"
26
27
#include "Sha256.h"
27
28
#include "MP3_Source_Qt.h"
28
29
 
29
 
#include <QDebug>
30
30
#include <QFile>
31
31
#include <QDateTime>
32
32
 
289
289
    
290
290
    ms.skipSilence();
291
291
 
292
 
    QByteArray data;
293
292
    bool fpDone = false;
294
 
    if ( mode() == Full )
295
 
    {
296
 
        qDebug() << "*** Starting full FP for: " << filename;
297
 
        m_extractor.initForFullSubmit( m_sampleRate, m_numChannels );
298
 
    }
299
 
    else
300
 
    {
301
 
        qDebug() << "--- Starting query FP for: " << filename;
302
 
        m_extractor.initForQuery( m_sampleRate, m_numChannels, duration );
303
 
 
304
 
        // Skippety skip for as long as the skipper sez (optimisation)
305
 
        ms.skip( m_extractor.getToSkipMs() );
306
 
        float secsToSkip = m_extractor.getToSkipMs() / 1000.0f;
307
 
        fpDone = m_extractor.process(
308
 
            0,
309
 
            static_cast<size_t>( m_sampleRate * m_numChannels * secsToSkip ),
310
 
            false );
311
 
    }
312
 
 
 
293
    try
 
294
    {
 
295
        if ( mode() == Full )
 
296
        {
 
297
            qDebug() << "*** Starting full FP for: " << filename;
 
298
            m_extractor.initForFullSubmit( m_sampleRate, m_numChannels );
 
299
        }
 
300
        else
 
301
        {
 
302
            qDebug() << "--- Starting query FP for: " << filename;
 
303
            m_extractor.initForQuery( m_sampleRate, m_numChannels, duration );
 
304
 
 
305
            // Skippety skip for as long as the skipper sez (optimisation)
 
306
            ms.skip( m_extractor.getToSkipMs() );
 
307
            float secsToSkip = m_extractor.getToSkipMs() / 1000.0f;
 
308
            fpDone = m_extractor.process(
 
309
                0,
 
310
                static_cast<size_t>( m_sampleRate * m_numChannels * secsToSkip ),
 
311
                false );
 
312
        }
 
313
    }
 
314
    catch ( const std::exception& e )
 
315
    {
 
316
        qDebug() << "Fingerprinter failed during initialisation: " << e.what();
 
317
        return;
 
318
    }
 
319
    
313
320
    const size_t PCMBufSize = 131072; 
314
321
    short* pPCMBuffer = new short[PCMBufSize];
315
322
 
332
339
            break;
333
340
        }
334
341
 
335
 
    } // end outer while
336
 
 
337
 
    if ( fpDone )
 
342
    } // end while
 
343
 
 
344
    delete[] pPCMBuffer;
 
345
 
 
346
    if ( !fpDone )
 
347
    {
 
348
        qDebug() << "FingerprintExtractor::process never returned true, fingerprint not calculated";
 
349
        m_fingerprint.clear();
 
350
        return;
 
351
    }
 
352
    
 
353
    try
338
354
    {
339
355
        // We succeeded
340
356
        std::pair<const char*, size_t> fpData = m_extractor.getFingerprint();
341
357
        m_fingerprint = QByteArray( fpData.first, fpData.second );
342
358
    }
343
 
    else
 
359
    catch ( const std::exception& e )
344
360
    {
345
 
        qDebug() << "FingerprintExtractor::process never returned true, fingerprint not calculated";
 
361
        qDebug() << "Fingerprint failed at getFingerprint: " << e.what();
346
362
        m_fingerprint.clear();
347
363
    }
348
364
 
349
 
    delete[] pPCMBuffer;
350
365
}
351
366
 
352
367