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()
|
FLACTranscode::FLACTranscode()
|
||||||
: m_FLACInit( false )
|
: m_FLACRunning( false )
|
||||||
, m_FLACRunning( false )
|
|
||||||
, m_finished( false )
|
, m_finished( false )
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
qDebug() << Q_FUNC_INFO;
|
||||||
|
|
||||||
init();
|
init();
|
||||||
|
set_metadata_respond_all();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -33,7 +33,6 @@ FLACTranscode::clearBuffers()
|
|||||||
{
|
{
|
||||||
QMutexLocker locker( &m_mutex );
|
QMutexLocker locker( &m_mutex );
|
||||||
|
|
||||||
m_FLACInit = false;
|
|
||||||
m_FLACRunning = false;
|
m_FLACRunning = false;
|
||||||
m_finished = false;
|
m_finished = false;
|
||||||
|
|
||||||
@ -52,14 +51,7 @@ FLACTranscode::processData( const QByteArray& data, bool finish )
|
|||||||
m_buffer.append( data );
|
m_buffer.append( data );
|
||||||
m_mutex.unlock();
|
m_mutex.unlock();
|
||||||
|
|
||||||
if ( !m_FLACInit && m_buffer.size() > FLAC_BUFFER )
|
while ( m_buffer.size() >= FLAC_BUFFER )
|
||||||
{
|
|
||||||
m_FLACInit = true;
|
|
||||||
set_metadata_respond_all();
|
|
||||||
process_single();
|
|
||||||
}
|
|
||||||
|
|
||||||
while ( m_buffer.size() > FLAC_BUFFER / 2 )
|
|
||||||
{
|
{
|
||||||
process_single();
|
process_single();
|
||||||
}
|
}
|
||||||
@ -79,10 +71,7 @@ FLACTranscode::read_callback( FLAC__byte buffer[], size_t *bytes )
|
|||||||
memcpy( buffer, (char*)m_buffer.data(), *bytes );
|
memcpy( buffer, (char*)m_buffer.data(), *bytes );
|
||||||
m_buffer.remove( 0, *bytes );
|
m_buffer.remove( 0, *bytes );
|
||||||
|
|
||||||
// if ( !*bytes )
|
return FLAC__STREAM_DECODER_READ_STATUS_CONTINUE;
|
||||||
// return FLAC__STREAM_DECODER_READ_STATUS_ABORT;
|
|
||||||
// else
|
|
||||||
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
|
void
|
||||||
FLACTranscode::metadata_callback( const ::FLAC__StreamMetadata *metadata )
|
FLACTranscode::metadata_callback( const ::FLAC__StreamMetadata *metadata )
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO;
|
qDebug() << Q_FUNC_INFO << metadata->is_last;
|
||||||
|
|
||||||
switch ( metadata->type )
|
switch ( metadata->type )
|
||||||
{
|
{
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
#include <QMutex>
|
#include <QMutex>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
#define FLAC_BUFFER 32768
|
#define FLAC_BUFFER 32768 * 36
|
||||||
#define FLAC_BUFFER_PREFERRED 32768
|
#define FLAC_BUFFER_PREFERRED 32768
|
||||||
|
|
||||||
class FLACTranscode : public TranscodeInterface , protected FLAC::Decoder::Stream
|
class FLACTranscode : public TranscodeInterface , protected FLAC::Decoder::Stream
|
||||||
@ -49,21 +49,17 @@ class FLACTranscode : public TranscodeInterface , protected FLAC::Decoder::Strea
|
|||||||
protected:
|
protected:
|
||||||
virtual ::FLAC__StreamDecoderReadStatus read_callback( FLAC__byte buffer[], size_t *bytes );
|
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__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();
|
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 );
|
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:
|
private:
|
||||||
QByteArray m_outBuffer;
|
QByteArray m_outBuffer;
|
||||||
|
|
||||||
QMutex m_mutex;
|
QMutex m_mutex;
|
||||||
QByteArray m_buffer;
|
QByteArray m_buffer;
|
||||||
|
|
||||||
bool m_FLACInit;
|
|
||||||
bool m_FLACRunning;
|
bool m_FLACRunning;
|
||||||
bool m_finished;
|
bool m_finished;
|
||||||
};
|
};
|
||||||
|
@ -14,33 +14,25 @@ DatabaseCommand_CollectionStats::DatabaseCommand_CollectionStats( const source_p
|
|||||||
void
|
void
|
||||||
DatabaseCommand_CollectionStats::exec( DatabaseImpl* dbi )
|
DatabaseCommand_CollectionStats::exec( DatabaseImpl* dbi )
|
||||||
{
|
{
|
||||||
//qDebug() << Q_FUNC_INFO;
|
|
||||||
Q_ASSERT( !source().isNull() );
|
|
||||||
TomahawkSqlQuery query = dbi->newquery();
|
|
||||||
|
|
||||||
Q_ASSERT( source()->isLocal() || source()->id() >= 1 );
|
Q_ASSERT( source()->isLocal() || source()->id() >= 1 );
|
||||||
|
TomahawkSqlQuery query = dbi->newquery();
|
||||||
|
|
||||||
if( source()->isLocal() )
|
if( source()->isLocal() )
|
||||||
{
|
{
|
||||||
query.exec("SELECT count(*), max(mtime), (SELECT guid FROM oplog WHERE source IS NULL ORDER BY id DESC LIMIT 1) "
|
query.exec( "SELECT count(*), max(mtime), (SELECT guid FROM oplog WHERE source IS NULL ORDER BY id DESC LIMIT 1) "
|
||||||
"FROM file "
|
"FROM file "
|
||||||
"WHERE source IS NULL");
|
"WHERE source IS NULL" );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
query.prepare("SELECT count(*), max(mtime), "
|
query.prepare( "SELECT count(*), max(mtime), (SELECT lastop FROM source WHERE id = ?) "
|
||||||
" (SELECT lastop FROM source WHERE id = ?) "
|
"FROM file "
|
||||||
"FROM file "
|
"WHERE source = ?" );
|
||||||
"WHERE source = ?"
|
|
||||||
);
|
|
||||||
query.addBindValue( source()->id() );
|
query.addBindValue( source()->id() );
|
||||||
query.addBindValue( source()->id() );
|
query.addBindValue( source()->id() );
|
||||||
}
|
}
|
||||||
if( !query.exec() )
|
|
||||||
{
|
query.exec();
|
||||||
qDebug() << "Failed to get collection stats:" << query.boundValues();
|
|
||||||
throw "failed to get collection stats";
|
|
||||||
}
|
|
||||||
|
|
||||||
QVariantMap m;
|
QVariantMap m;
|
||||||
if( query.next() )
|
if( query.next() )
|
||||||
@ -50,8 +42,5 @@ DatabaseCommand_CollectionStats::exec( DatabaseImpl* dbi )
|
|||||||
m.insert( "lastop", query.value( 2 ).toString() );
|
m.insert( "lastop", query.value( 2 ).toString() );
|
||||||
}
|
}
|
||||||
|
|
||||||
//qDebug() << "Loaded collection stats for"
|
|
||||||
// << (source()->isLocal() ? "LOCAL" : source()->username())
|
|
||||||
// << m;
|
|
||||||
emit done( m );
|
emit done( m );
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user