mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-01-19 07:27:59 +01:00
* Temporary fix for infinite loop inside FLAC transcoder.
This commit is contained in:
parent
3eeec206f1
commit
18d5d43695
@ -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 )
|
||||
{
|
||||
|
@ -15,7 +15,7 @@
|
||||
#include <QMutex>
|
||||
#include <QDebug>
|
||||
|
||||
#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;
|
||||
};
|
||||
|
@ -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 );
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user