Commit cb723c52 authored by Leslie Zhai's avatar Leslie Zhai

Add MediaType for GrowisofsHandler

So it is able to calculate Current Write Speed with DVD or BD speed
factor depends on MediaType.

CCBUG: 380064
parent d4b6d1f2
......@@ -16,7 +16,6 @@
#include "k3bjob.h"
#include "k3bcore.h"
#include "k3bglobalsettings.h"
#include "k3bdevice.h"
#include "k3bdevicehandler.h"
#include "k3b_i18n.h"
......@@ -37,7 +36,8 @@ public:
K3b::GrowisofsHandler::GrowisofsHandler( QObject* parent )
: QObject( parent )
: QObject( parent ),
m_mediaType(Device::MEDIA_DVD_ALL)
{
d = new Private;
reset();
......@@ -166,19 +166,16 @@ void K3b::GrowisofsHandler::handleLine( const QString& line )
}
else if( ( pos = line.indexOf( "Current Write Speed" ) ) > 0 ) {
// parse write speed
// /dev/sr0: "Current Write Speed" is 2.4x1385KBps
// /dev/sr0: "Current Write Speed" is 2.4x1385KBps for DVD or 4.1x4496KBps for BD
pos += 24;
int endPos = line.indexOf( 'x', pos+1 );
bool ok = true;
double speed = line.mid( pos, endPos-pos ).toDouble(&ok);
if (ok) {
#ifdef K3B_DEBUG
qDebug() << "DEBUG:" << __PRETTY_FUNCTION__ << speed * double(Device::SPEED_FACTOR_DVD) << speed << double(Device::SPEED_FACTOR_DVD);
#endif
emit infoMessage( i18n("Writing speed: %1 KB/s (%2x)",
int( speed * double( Device::SPEED_FACTOR_DVD ) )
,QLocale::system().toString(speed)), K3b::Job::MessageInfo );
emit infoMessage(i18n("Writing speed: %1 KB/s (%2x)",
int(speed * double(m_mediaType == Device::MEDIA_DVD_ALL ? Device::SPEED_FACTOR_DVD : Device::SPEED_FACTOR_BD)),
QLocale::system().toString(speed)), K3b::Job::MessageInfo);
} else
qDebug() << "(K3b::GrowisofsHandler) parsing error: '" << line.mid( pos, endPos-pos ) << "'";
}
......@@ -315,4 +312,7 @@ void K3b::GrowisofsHandler::slotCheckBufferStatusDone( K3b::Device::DeviceHandle
}
}
void K3b::GrowisofsHandler::setMediaType(Device::MediaType mediaType)
{
m_mediaType = mediaType;
}
......@@ -15,6 +15,8 @@
#ifndef _K3B_GROWISOFS_HANDLER_H_
#define _K3B_GROWISOFS_HANDLER_H_
#include "k3bdevice.h"
#include <QtCore/QObject>
namespace K3b {
......@@ -49,6 +51,8 @@ namespace K3b {
int error() const { return m_error; }
void setMediaType(Device::MediaType mediaType);
public Q_SLOTS:
/**
* This will basically reset the error type
......@@ -82,6 +86,7 @@ namespace K3b {
int m_error;
bool m_dao;
Device::Device* m_device;
Device::MediaType m_mediaType;
};
}
......
......@@ -259,6 +259,7 @@ bool K3b::GrowisofsWriter::prepareProcess()
d->gh->reset( burnDevice(), false );
d->burnedMediumType = burnDevice()->mediaType();
d->gh->setMediaType(d->burnedMediumType);
//
// Never use the -dvd-compat parameter with DVD+RW media
......@@ -465,9 +466,6 @@ void K3b::GrowisofsWriter::slotReceivedStderr( const QString& line )
double speed = line.mid( pos, line.indexOf( 'x', pos ) - pos ).toDouble(&ok);
if (ok) {
if (d->lastWritingSpeed != speed) {
#ifdef K3B_DEBUG
qDebug() << "DEBUG:" << __PRETTY_FUNCTION__ << speed * d->speedMultiplicator() << speed << d->speedMultiplicator();
#endif
emit writeSpeed((int)(speed * d->speedMultiplicator()), d->speedMultiplicator());
}
d->lastWritingSpeed = speed;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment