Commit 47a5f840 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Modernize code

parent 724375c9
......@@ -43,7 +43,7 @@ KAudiocdModule::KAudiocdModule(QWidget *parent, const QVariantList &lst)
{
Q_UNUSED(lst);
QVBoxLayout *box = new QVBoxLayout(this);
auto box = new QVBoxLayout(this);
audioConfig = new AudiocdConfig(this);
......@@ -60,7 +60,7 @@ KAudiocdModule::KAudiocdModule(QWidget *parent, const QVariantList &lst)
QWidget *widget = encoder->getConfigureWidget(&config);
if (widget && config) {
audioConfig->tabWidget->addTab(widget, i18n("%1 Encoder", encoder->type()));
KConfigDialogManager *configManager = new KConfigDialogManager(widget, config);
auto configManager = new KConfigDialogManager(widget, config);
encoderSettings.append(configManager);
}
}
......@@ -90,7 +90,7 @@ KAudiocdModule::KAudiocdModule(QWidget *parent, const QVariantList &lst)
connect(audioConfig->kcfg_replaceOutput, &QLineEdit::textChanged, this, &KAudiocdModule::slotConfigChanged);
connect(audioConfig->example, &QLineEdit::textChanged, this, &KAudiocdModule::slotConfigChanged);
KAboutData *about = new KAboutData(QStringLiteral("kcmaudiocd"), i18n("KDE Audio CD IO Slave"), QStringLiteral(AUDIOCDPLUGINS_VERSION_STRING));
auto about = new KAboutData(QStringLiteral("kcmaudiocd"), i18n("KDE Audio CD IO Slave"), QStringLiteral(AUDIOCDPLUGINS_VERSION_STRING));
about->addAuthor(i18n("Benjamin C. Meyer"), i18n("Former Maintainer"), QStringLiteral("ben@meyerhome.net"));
about->addAuthor(i18n("Carsten Duvenhorst"), i18n("Original Author"), QStringLiteral("duvenhorst@duvnet.de"));
......
......@@ -70,7 +70,7 @@ static FLAC__StreamEncoderWriteStatus WriteCallback(const FLAC__StreamEncoder *e
Q_UNUSED(samples)
Q_UNUSED(current_frame)
EncoderFLAC::Private *d = (EncoderFLAC::Private *)client_data;
auto *d = (EncoderFLAC::Private *)client_data;
d->data += bytes;
......@@ -183,7 +183,7 @@ long EncoderFLAC::readInit(long size) {
long EncoderFLAC::read(qint16 *buf, int frames)
{
unsigned long olddata = d->data;
FLAC__int32 *buffer = new FLAC__int32[frames * 2];
auto buffer = new FLAC__int32[frames * 2];
for (int i = 0; i < frames * 2; i++) {
buffer[i] = (FLAC__int32)buf[i];
}
......@@ -213,7 +213,7 @@ void EncoderFLAC::fillSongInfo(KCDDB::CDInfo info, int track, const QString &com
// d->metadata[2] =
// FLAC__metadata_object_new(FLAC__METADATA_TYPE_SEEKTABLE)
typedef QPair<QString, QVariant> Comment;
using Comment = QPair<QString, QVariant>;
Comment comments[7] = {Comment(QLatin1String("TITLE"), info.track(track - 1).get(Title)),
Comment(QLatin1String("ARTIST"), info.track(track - 1).get(Artist)),
Comment(QLatin1String("ALBUM"), info.get(Title)),
......
......@@ -72,7 +72,7 @@ EncoderLame::~EncoderLame()
QWidget *EncoderLame::getConfigureWidget(KConfigSkeleton **manager) const
{
(*manager) = Settings::self();
EncoderLameConfig *config = new EncoderLameConfig();
auto config = new EncoderLameConfig();
config->cbr_settings->hide();
return config;
}
......
......@@ -73,7 +73,7 @@ EncoderOpus::~EncoderOpus()
QWidget *EncoderOpus::getConfigureWidget(KConfigSkeleton **manager) const
{
(*manager) = Settings::self();
EncoderOpusConfig *config = new EncoderOpusConfig();
auto config = new EncoderOpusConfig();
config->kcfg_opus_complexity->setRange(0, 10);
config->kcfg_opus_complexity->setSingleStep(1);
config->opus_bitrate_settings->hide();
......
......@@ -80,7 +80,7 @@ EncoderVorbis::~EncoderVorbis()
QWidget *EncoderVorbis::getConfigureWidget(KConfigSkeleton **manager) const
{
(*manager) = Settings::self();
EncoderVorbisConfig *config = new EncoderVorbisConfig();
auto config = new EncoderVorbisConfig();
config->kcfg_vorbis_quality->setRange(0.0, 10.0);
config->kcfg_vorbis_quality->setSingleStep(0.1);
config->vorbis_bitrate_settings->hide();
......@@ -142,35 +142,36 @@ void EncoderVorbis::loadSettings()
}
}
long EncoderVorbis::flush_vorbis(void) {
long processed(0);
while (vorbis_analysis_blockout(&d->vd, &d->vb) == 1) {
vorbis_analysis(&d->vb, nullptr);
/* Non-ancient case. */
vorbis_bitrate_addblock(&d->vb);
while (vorbis_bitrate_flushpacket(&d->vd, &d->op)) {
ogg_stream_packetin(&d->os, &d->op);
while (int result = ogg_stream_pageout(&d->os, &d->og)) {
if (!result)
break;
char *oggheader = reinterpret_cast<char *>(d->og.header);
char *oggbody = reinterpret_cast<char *>(d->og.body);
if (d->og.header_len) {
ioslave->data(QByteArray::fromRawData(oggheader, d->og.header_len));
}
if (d->og.body_len) {
ioslave->data(QByteArray::fromRawData(oggbody, d->og.body_len));
}
processed += d->og.header_len + d->og.body_len;
}
}
}
return processed;
long EncoderVorbis::flush_vorbis()
{
long processed(0);
while (vorbis_analysis_blockout(&d->vd, &d->vb) == 1) {
vorbis_analysis(&d->vb, nullptr);
/* Non-ancient case. */
vorbis_bitrate_addblock(&d->vb);
while (vorbis_bitrate_flushpacket(&d->vd, &d->op)) {
ogg_stream_packetin(&d->os, &d->op);
while (int result = ogg_stream_pageout(&d->os, &d->og)) {
if (!result)
break;
char *oggheader = reinterpret_cast<char *>(d->og.header);
char *oggbody = reinterpret_cast<char *>(d->og.body);
if (d->og.header_len) {
ioslave->data(QByteArray::fromRawData(oggheader, d->og.header_len));
}
if (d->og.body_len) {
ioslave->data(QByteArray::fromRawData(oggbody, d->og.body_len));
}
processed += d->og.header_len + d->og.body_len;
}
}
}
return processed;
}
unsigned long EncoderVorbis::size(long time_secs) const {
......@@ -270,7 +271,7 @@ void EncoderVorbis::fillSongInfo(KCDDB::CDInfo info, int track, const QString &c
if (!d->write_vorbis_comments)
return;
typedef QPair<QByteArray, QVariant> CommentField;
using CommentField = QPair<QByteArray, QVariant>;
QList<CommentField> commentFields;
commentFields.append(CommentField("TITLE", info.track(track - 1).get(Title)));
......
Supports Markdown
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