diff --git a/src/audio/flactranscode.cpp b/src/audio/flactranscode.cpp index e21171e13..bb5e889f4 100644 --- a/src/audio/flactranscode.cpp +++ b/src/audio/flactranscode.cpp @@ -2,13 +2,13 @@ FLACTranscode::FLACTranscode() - : m_FLACInit( false ) - , m_FLACRunning( false ) + : m_FLACRunning( false ) , m_finished( false ) { qDebug() << Q_FUNC_INFO; init(); + set_metadata_respond_all(); } @@ -33,7 +33,6 @@ FLACTranscode::clearBuffers() { QMutexLocker locker( &m_mutex ); - m_FLACInit = false; m_FLACRunning = false; m_finished = false; @@ -52,14 +51,7 @@ FLACTranscode::processData( const QByteArray& data, bool finish ) m_buffer.append( data ); m_mutex.unlock(); - if ( !m_FLACInit && m_buffer.size() > FLAC_BUFFER ) - { - m_FLACInit = true; - set_metadata_respond_all(); - process_single(); - } - - while ( m_buffer.size() > FLAC_BUFFER / 2 ) + while ( m_buffer.size() >= FLAC_BUFFER ) { process_single(); } @@ -79,10 +71,7 @@ FLACTranscode::read_callback( FLAC__byte buffer[], size_t *bytes ) memcpy( buffer, (char*)m_buffer.data(), *bytes ); m_buffer.remove( 0, *bytes ); -// if ( !*bytes ) -// return FLAC__STREAM_DECODER_READ_STATUS_ABORT; -// else - return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE; + return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE; } @@ -110,10 +99,17 @@ FLACTranscode::write_callback( const ::FLAC__Frame *frame, const FLAC__int32 *co } +::FLAC__StreamDecoderSeekStatus +FLACTranscode::seek_callback(FLAC__uint64 absolute_byte_offset) +{ + return FLAC__STREAM_DECODER_SEEK_STATUS_UNSUPPORTED; +} + + void FLACTranscode::metadata_callback( const ::FLAC__StreamMetadata *metadata ) { - qDebug() << Q_FUNC_INFO; + qDebug() << Q_FUNC_INFO << metadata->is_last; switch ( metadata->type ) { diff --git a/src/audio/flactranscode.h b/src/audio/flactranscode.h index f668fbb30..ba65a0185 100644 --- a/src/audio/flactranscode.h +++ b/src/audio/flactranscode.h @@ -15,7 +15,7 @@ #include #include -#define FLAC_BUFFER 32768 +#define FLAC_BUFFER 32768 * 36 #define FLAC_BUFFER_PREFERRED 32768 class FLACTranscode : public TranscodeInterface , protected FLAC::Decoder::Stream @@ -49,21 +49,17 @@ class FLACTranscode : public TranscodeInterface , protected FLAC::Decoder::Strea protected: virtual ::FLAC__StreamDecoderReadStatus read_callback( FLAC__byte buffer[], size_t *bytes ); virtual ::FLAC__StreamDecoderWriteStatus write_callback( const ::FLAC__Frame *frame, const FLAC__int32 *const buffer[] ); + virtual ::FLAC__StreamDecoderSeekStatus seek_callback( FLAC__uint64 absolute_byte_offset ); virtual bool eof_callback(); - void metadata_callback( const ::FLAC__StreamMetadata *metadata ); + virtual void metadata_callback( const ::FLAC__StreamMetadata *metadata ); void error_callback( ::FLAC__StreamDecoderErrorStatus status ); -/* ::FLAC__StreamDecoderSeekStatus seek_callback( FLAC__uint64 absolute_byte_offset ); - ::FLAC__StreamDecoderTellStatus tell_callback( FLAC__uint64 *absolute_byte_offset ); - ::FLAC__StreamDecoderLengthStatus length_callback( FLAC__uint64 *stream_length );*/ - private: QByteArray m_outBuffer; QMutex m_mutex; QByteArray m_buffer; - bool m_FLACInit; bool m_FLACRunning; bool m_finished; }; diff --git a/src/libtomahawk/database/databasecommand_collectionstats.cpp b/src/libtomahawk/database/databasecommand_collectionstats.cpp index 4d2ce5ccf..587c7d1b3 100644 --- a/src/libtomahawk/database/databasecommand_collectionstats.cpp +++ b/src/libtomahawk/database/databasecommand_collectionstats.cpp @@ -14,33 +14,25 @@ DatabaseCommand_CollectionStats::DatabaseCommand_CollectionStats( const source_p void DatabaseCommand_CollectionStats::exec( DatabaseImpl* dbi ) { - //qDebug() << Q_FUNC_INFO; - Q_ASSERT( !source().isNull() ); - TomahawkSqlQuery query = dbi->newquery(); - Q_ASSERT( source()->isLocal() || source()->id() >= 1 ); + TomahawkSqlQuery query = dbi->newquery(); if( source()->isLocal() ) { - query.exec("SELECT count(*), max(mtime), (SELECT guid FROM oplog WHERE source IS NULL ORDER BY id DESC LIMIT 1) " - "FROM file " - "WHERE source IS NULL"); + query.exec( "SELECT count(*), max(mtime), (SELECT guid FROM oplog WHERE source IS NULL ORDER BY id DESC LIMIT 1) " + "FROM file " + "WHERE source IS NULL" ); } else { - query.prepare("SELECT count(*), max(mtime), " - " (SELECT lastop FROM source WHERE id = ?) " - "FROM file " - "WHERE source = ?" - ); + query.prepare( "SELECT count(*), max(mtime), (SELECT lastop FROM source WHERE id = ?) " + "FROM file " + "WHERE source = ?" ); query.addBindValue( source()->id() ); query.addBindValue( source()->id() ); } - if( !query.exec() ) - { - qDebug() << "Failed to get collection stats:" << query.boundValues(); - throw "failed to get collection stats"; - } + + query.exec(); QVariantMap m; if( query.next() ) @@ -50,8 +42,5 @@ DatabaseCommand_CollectionStats::exec( DatabaseImpl* dbi ) m.insert( "lastop", query.value( 2 ).toString() ); } - //qDebug() << "Loaded collection stats for" - // << (source()->isLocal() ? "LOCAL" : source()->username()) - // << m; emit done( m ); }