From: Marco Gittler Date: Sat, 23 Feb 2008 23:06:34 +0000 (+0000) Subject: got first audio frames, but X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=6b67d09121d19cd96982defdd11ef35870174453;p=kdenlive got first audio frames, but m_url=url (Kurl) crashes notification of progress is not active svn path=/branches/KDE4/; revision=1915 --- diff --git a/src/docclipbase.cpp b/src/docclipbase.cpp index 38562405..de5cafb1 100644 --- a/src/docclipbase.cpp +++ b/src/docclipbase.cpp @@ -21,7 +21,7 @@ #include "docclipbase.h" DocClipBase::DocClipBase(QDomElement xml, uint id): -m_xml(xml), m_id(id), m_description(""), m_refcount(0), m_projectThumbFrame(0), audioThumbCreated(false), m_duration(GenTime()), m_thumbProd(NULL) +m_xml(xml), m_id(id), m_description(""), m_refcount(0), m_projectThumbFrame(0), audioThumbCreated(false), m_duration(GenTime()), m_thumbProd(NULL), m_audioTimer(NULL) { int type = xml.attribute("type").toInt(); m_clipType = (CLIPTYPE) type; @@ -40,6 +40,8 @@ m_xml(xml), m_id(id), m_description(""), m_refcount(0), m_projectThumbFrame(0), kDebug() << "type is video" << (m_clipType==AV) << " " << m_clipType; if (m_clipType == AV || m_clipType==AUDIO ||m_clipType==UNKNOWN){ + m_audioTimer = new QTimer( this ); + connect(m_audioTimer, SIGNAL(timeout()), this, SLOT(slotGetAudioThumbs())); emit getAudioThumbs(); } } @@ -397,7 +399,15 @@ QString DocClipBase::getTypeName(CLIPTYPE type) void DocClipBase::slotGetAudioThumbs(){ kDebug() << "getting audio data"; - double lengthInFrames=duration().frames(/*framesPerSecond()*/25); - m_thumbProd->getAudioThumbs(fileURL(), 1, 0, lengthInFrames, 20); + if (audioThumbCreated){ + if (m_audioTimer!=NULL) + m_audioTimer->stop(); + }else{ + if (m_audioTimer!=NULL) + m_audioTimer->start(5); + double lengthInFrames=duration().frames(/*framesPerSecond()*/25); + m_thumbProd->getAudioThumbs(fileURL(), 1, 0, 10 /*must be number of frames*/, 20); + + } } diff --git a/src/docclipbase.h b/src/docclipbase.h index b39dc004..e1ec8650 100644 --- a/src/docclipbase.h +++ b/src/docclipbase.h @@ -25,6 +25,7 @@ #include #include #include +#include #include #include @@ -210,7 +211,7 @@ class DocClipBase:public QObject { /** A thumbnail for this clip */ QPixmap m_thumbnail; GenTime m_duration; - + QTimer *m_audioTimer; KThumb *m_thumbProd; /** a unique numeric id */ diff --git a/src/kthumb.cpp b/src/kthumb.cpp index 27cb3639..42313c44 100644 --- a/src/kthumb.cpp +++ b/src/kthumb.cpp @@ -64,6 +64,7 @@ void MyThread::init(KUrl url, QString target, double frame, double frameLength, void MyThread::run() { + if (!f.open( QIODevice::WriteOnly )) { kDebug()<<"++++++++ ERROR WRITING TO FILE: "< 1){ @@ -110,6 +114,7 @@ void MyThread::init(KUrl url, QString target, double frame, double frameLength, m_array[i] = qAbs((*( m_pcm + c + i * m_samples / m_array.size() ))>>8); } f.write(m_array); + } } else{ f.write(QByteArray(m_arrayWidth,'\x00')); @@ -320,12 +325,14 @@ void KThumb::getAudioThumbs(KUrl url, int channel, double frame, double frameLen if ((thumbProducer.isRunning () && thumbProducer.isWorking()) || channel == 0) { return; } - + QMap > storeIn; //FIXME: Hardcoded!!! int m_frequency = 48000; int m_channels = channel; - /*TODO + + m_thumbFile="/tmp/testfile"; + /*FIXME WHY crash here ?????? if (m_url != url) { m_url = url; QCryptographicHash context(QCryptographicHash::Sha1); @@ -334,7 +341,7 @@ void KThumb::getAudioThumbs(KUrl url, int channel, double frame, double frameLen m_thumbFile = KdenliveSettings::currenttmpfolder() + context.result().toHex() + ".thumb"; }*/ - return; + QFile f(m_thumbFile); if (f.open( QIODevice::ReadOnly )) { QByteArray channelarray = f.readAll(); diff --git a/src/renderer.cpp b/src/renderer.cpp index ee7f7b83..a44f0164 100644 --- a/src/renderer.cpp +++ b/src/renderer.cpp @@ -387,6 +387,7 @@ void Render::getFileProperties(const QDomElement &xml, int clipId) // Retrieve audio / video codec name // Fetch the video_context +#if 0 //until the reason for the chrashs is found AVFormatContext *context = (AVFormatContext *) mlt_properties_get_data( properties, "video_context", NULL ); if (context != NULL) { // Get the video_index @@ -401,7 +402,7 @@ void Render::getFileProperties(const QDomElement &xml, int clipId) if (context->streams && context->streams [index] && context->streams[ index ]->codec && context->streams[ index ]->codec->codec->name ) filePropertyMap["audiocodec"] = context->streams[ index ]->codec->codec->name; } - +#endif // metadata