-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathcjacktheripper.cpp
781 lines (682 loc) · 21.7 KB
/
cjacktheripper.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
/**
* Copyright (C) 2021 Jo2003 (olenka.joerg@gmail.com)
* This file is part of cd2netmd_gui
*
* cd2netmd is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* cd2netmd is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
*/
#include "cjacktheripper.h"
#include <QVector>
#include <QFileInfo>
#include <stdexcept>
#include <QDir>
#include "cffmpeg.h"
#include "helpers.h"
#include "defines.h"
///
/// \brief CJackTheRipper::CJackTheRipper
/// \param parent
///
CJackTheRipper::CJackTheRipper(QObject *parent)
: QObject(parent), mpCDIO(nullptr), mpCDAudio(nullptr),
mpCDParanoia(nullptr), mpRipThread(nullptr),
mpCddb(nullptr), mBusy(false), mbCDDB(false),
mpFFMpeg(nullptr), miFlacTrack(-99)
#ifdef Q_OS_MAC
, mpDrUtil(nullptr)
#endif
{
mpCddb = new CCDDB(this);
mpFFMpeg = new CFFMpeg(this);
#ifdef Q_OS_MAC
mpDrUtil = new CDRUtil(this);
connect(mpDrUtil, &CDRUtil::fileDone, this, &CJackTheRipper::macCDText);
#endif
connect(mpFFMpeg, &CFFMpeg::fileDone, this, &CJackTheRipper::extractDone);
connect(mpFFMpeg, &CFFMpeg::progress, this, &CJackTheRipper::getProgress);
}
///
/// \brief CJackTheRipper::~CJackTheRipper
///
CJackTheRipper::~CJackTheRipper()
{
// cleanup time
cleanup();
}
//--------------------------------------------------------------------------
//! @brief Initializes from CD image / CD drive
//!
//! @param[in] cddb if true, do cddb request
//!
//! @return 0 -> ok
//--------------------------------------------------------------------------
int CJackTheRipper::init(bool cddb)
{
mbCDDB = cddb;
mAudioTracks.clear();
cleanup();
CCDInitThread *pInit = new CCDInitThread(this, &mpCDIO, &mpCDAudio, &mpCDParanoia);
if (pInit)
{
connect(pInit, &CCDInitThread::finished, pInit, &QObject::deleteLater);
connect(pInit, &CCDInitThread::finished, this, &CJackTheRipper::cddbReqString);
pInit->start(QThread::LowPriority);
return 0;
}
return -1;
}
int CJackTheRipper::cleanup()
{
if (mpRipThread != nullptr)
{
mpRipThread->join();
delete mpRipThread;
mpRipThread = nullptr;
}
if (mpCDParanoia != nullptr)
{
cdio_paranoia_free(mpCDParanoia);
mpCDParanoia = nullptr;
}
if (mpCDAudio != nullptr)
{
cdio_cddap_close_no_free_cdio(mpCDAudio);
mpCDAudio = nullptr;
}
if (mpCDIO != nullptr)
{
cdio_destroy(mpCDIO);
mpCDIO = nullptr;
}
return 0;
}
int CJackTheRipper::extractTrack(int trackNo, const QString &fName, bool paranoia)
{
qInfo("Extract track %d to %s ...", trackNo, static_cast<const char*>(fName.toUtf8()));
if (mpRipThread != nullptr)
{
mpRipThread->join();
delete mpRipThread;
}
if (mAudioTracks.listType() == c2n::AudioTracks::CD)
{
mpRipThread = new std::thread(&CJackTheRipper::ripThread, this, trackNo, fName, paranoia);
if (mpRipThread)
{
mBusy = true;
return 0;
}
}
else
{
miFlacTrack = trackNo;
mFlacFName = fName;
extractWave();
return 0;
}
return -1;
}
CCDDB *CJackTheRipper::cddb()
{
return mpCddb;
}
//--------------------------------------------------------------------------
//! @brief parse CD Text
//!
//! @param pCDT The cd text object
//! @param[in] track track number
//! @param[out] ttitle The track title
//!
//! @return 0 on success
//--------------------------------------------------------------------------
int CJackTheRipper::parseCDText(cdtext_t* pCDT, track_t track, QString& ttitle)
{
int ret = -1;
ttitle = "";
if (pCDT)
{
ret = 0;
const char* tok;
QString performer, title;
tok = cdtext_get_const(pCDT, CDTEXT_FIELD_PERFORMER, track);
if (tok)
{
performer = QString(tok).trimmed();
ttitle = QString("%1 - ").arg(performer);
}
tok = cdtext_get_const(pCDT, CDTEXT_FIELD_TITLE, track);
if (tok)
{
title = QString(tok).trimmed();
if (title.indexOf(performer) != -1)
{
ttitle = title;
}
else
{
ttitle += title;
}
}
}
if (ttitle.isEmpty())
{
ttitle = tr("<untitled>");
}
qInfo() << "Title" << track << "is named" << ttitle;
return ret;
}
bool CJackTheRipper::busy() const
{
return mBusy;
}
int CJackTheRipper::ripThread(int track, const QString &fName, bool paranoia)
{
int ret = 0;
try
{
if ((mpCDAudio == nullptr) || (mpCDParanoia == nullptr))
{
throw std::runtime_error("CD device(s) not initialized!");
}
cdio_paranoia_modeset(mpCDParanoia, paranoia ? (PARANOIA_MODE_FULL ^ PARANOIA_MODE_NEVERSKIP) : PARANOIA_MODE_DISABLE);
// lsn_t disctStart = cdio_cddap_disc_firstsector(mpCDAudio);
track_t firstTrack = cdio_get_first_track_num(mpCDIO);
track_t lastTrack = cdio_get_last_track_num(mpCDIO);
lsn_t trkStart = 0;
lsn_t trkEnd = 0;
if (track != -1)
{
if (cdio_get_track_format(mpCDIO, track) != TRACK_FORMAT_AUDIO)
{
throw std::runtime_error("Track is no audio track!");
}
if ((track < firstTrack) || (track > lastTrack))
{
throw std::runtime_error("Track is not part of disc!");
}
// get track sectors
trkStart = cdio_cddap_track_firstsector(mpCDAudio, track);
trkEnd = cdio_cddap_track_lastsector(mpCDAudio, track);
}
else
{
// track == -1 -> disc at once mode
// first track might have data (Mixed Mode)
if (cdio_get_track_format(mpCDIO, firstTrack) != TRACK_FORMAT_AUDIO)
{
// start extraction from next track
firstTrack++;
}
// last track might have data (CD-Plus / CD-Extra)
if (cdio_get_track_format(mpCDIO, lastTrack) != TRACK_FORMAT_AUDIO)
{
// start extraction from next track
lastTrack--;
}
trkStart = cdio_cddap_track_firstsector(mpCDAudio, firstTrack);
trkEnd = cdio_cddap_track_lastsector(mpCDAudio, lastTrack);
}
// get track size ...
size_t trkSz = (trkEnd - trkStart) * CDIO_CD_FRAMESIZE_RAW;
size_t read = 0;
cdio_paranoia_seek(mpCDParanoia, trkStart, SEEK_SET);
int16_t* pRAWFrame;
QFile f(fName);
if (f.open(QIODevice::WriteOnly | QIODevice::Truncate))
{
audio::writeWaveHeader(f, trkSz);
cdio_cddap_speed_set(mpCDAudio, 8);
int curPercent = 0, oldPercent = 0;
while (read < trkSz)
{
if((pRAWFrame = cdio_paranoia_read(mpCDParanoia, nullptr)) != nullptr)
{
read += CDIO_CD_FRAMESIZE_RAW;
f.write(reinterpret_cast<char*>(pRAWFrame), CDIO_CD_FRAMESIZE_RAW);
curPercent = (read * 100) / trkSz;
if (curPercent != oldPercent)
{
emit progress(curPercent);
oldPercent = curPercent;
}
}
}
f.close();
}
}
catch (const std::exception& e)
{
qWarning() << e.what();
ret = -1;
}
noBusy();
emit finished();
return ret;
}
//--------------------------------------------------------------------------
//! @brief copy shop thread ended
//--------------------------------------------------------------------------
void CJackTheRipper::copyDone()
{
noBusy();
emit finished();
}
//--------------------------------------------------------------------------
//! @brief flac extract done
//--------------------------------------------------------------------------
void CJackTheRipper::extractDone()
{
extractWave();
}
//--------------------------------------------------------------------------
//! @brief extract to wave
//--------------------------------------------------------------------------
void CJackTheRipper::extractWave()
{
QFileInfo fi;
bool startCopy = true;
constexpr uint32_t DONE_MARK = 0xDEADBEEF;
if ((miFlacTrack > 0) && (miFlacTrack < mAudioTracks.size()))
{
c2n::STrackInfo& ci = mAudioTracks[miFlacTrack];
if (ci.mWaveFileName.isEmpty())
{
if (ci.mConversion)
{
fi.setFile(ci.mFileName);
ci.mWaveFileName = QString("%1/cd2netmd_audio_decode_%2.wav").arg(QDir::tempPath()).arg(fi.baseName());
if (!QFile::exists(ci.mWaveFileName))
{
mpFFMpeg->start(ci.mFileName, ci.mWaveFileName, ci.mConversion);
startCopy = false;
}
}
else
{
ci.mWaveFileName = ci.mFileName;
}
}
}
else if (miFlacTrack == -1)
{
// DAO stuff
QStringList srcFiles;
// all done already?
if (mAudioTracks[0].mConversion == DONE_MARK)
{
mAudioTracks[0].mConversion = 0;
noBusy();
getProgress(100);
emit finished();
// over and out
return;
}
else
{
// mark this as done for next call
mAudioTracks[0].mConversion = DONE_MARK;
// something to concatinate?
for (int track = 1; track < mAudioTracks.size(); track ++)
{
if (!srcFiles.contains(mAudioTracks[track].mFileName))
{
srcFiles << mAudioTracks[track].mFileName;
}
}
if (srcFiles.size() == 1)
{
// only one source file ...
for (auto& t : mAudioTracks)
{
if (t.mFileName == srcFiles.at(0))
{
if (t.mConversion)
{
// convert this one file into target wave file
mpFFMpeg->start(t.mFileName, mFlacFName, t.mConversion);
startCopy = false;
}
else
{
// No need for conversion -
// copy shop will make our copy instead ...
t.mWaveFileName = t.mFileName;
}
break;
}
}
}
else if (srcFiles.size() > 1)
{
// call ffmpeg to concatinate all audio files
// in only one call
mpFFMpeg->concatFiles(srcFiles, mFlacFName);
startCopy = false;
}
}
}
if (startCopy)
{
startCopyShop();
}
}
//--------------------------------------------------------------------------
//! @brief start file copy stuff
//--------------------------------------------------------------------------
void CJackTheRipper::startCopyShop()
{
CCopyShopThread* pCopyShop = new CCopyShopThread(this, mAudioTracks, miFlacTrack, mFlacFName);
if (pCopyShop != nullptr)
{
connect(pCopyShop, &CCopyShopThread::finished, pCopyShop, &QObject::deleteLater);
connect(pCopyShop, &CCopyShopThread::finished, this, &CJackTheRipper::copyDone);
connect(pCopyShop, &CCopyShopThread::progress, this, &CJackTheRipper::getProgress);
pCopyShop->start(QThread::NormalPriority);
mBusy = true;
}
}
//--------------------------------------------------------------------------
//! @brief create cddbp query and start request
//--------------------------------------------------------------------------
int CJackTheRipper::cddbRequest()
{
uint32_t checkSum = 0, tmp = 0;
QString req, lbas;
uint32_t discId = 0;
for (const auto& t : mAudioTracks)
{
if (t.mCDTrackNo > 0)
{
// checksum
tmp = t.mStartLba / CDIO_CD_FRAMES_PER_SEC;
do
{
checkSum += tmp % 10;
tmp /= 10;
} while (tmp != 0);
lbas += QString("+%1").arg(t.mStartLba);
}
}
discId = checkSum << 24
| (mAudioTracks.at(0).mLbCount / CDIO_CD_FRAMES_PER_SEC) << 8
| (mAudioTracks.size() - 1);
req = QString("%1+%2").arg(discId, 8, 16, QChar('0')).arg(mAudioTracks.size() - 1);
req += lbas;
req += QString("+%1").arg(mAudioTracks.at(0).mLbCount / CDIO_CD_FRAMES_PER_SEC);
mCDDBRequest = req;
qInfo() << "No CD-Text, do CDDB request: " << req;
// no CDText -> ask CDDB
mpCddb->getEntries(req, mAudioTracks);
return 0;
}
QString CJackTheRipper::deviceInfo()
{
QString ret;
cdio_hwinfo_t hwInf;
if (mpCDIO != nullptr)
{
if (cdio_get_hwinfo (mpCDIO, &hwInf))
{
ret = QString("%1 %2 %3").arg(hwInf.psz_vendor).arg(hwInf.psz_model).arg(hwInf.psz_revision);
qInfo() << "Found CD Device " << ret;
}
}
else
{
ret = mDevInfo;
}
return ret;
}
int CJackTheRipper::cddbReqString()
{
if ((mDrvId == DRIVER_BINCUE) && !mImgFile.isEmpty())
{
emit parseCue(mImgFile);
return 0;
}
bool doSignal = true;
mAudioTracks.clear();
mAudioTracks.setListType(c2n::AudioTracks::CD);
c2n::STrackInfo trackInfo;
track_t firstTrack, lastTrack;
mCDDBRequest = "";
if (mpCDIO != nullptr)
{
firstTrack = cdio_get_first_track_num(mpCDIO);
lastTrack = cdio_get_last_track_num(mpCDIO);
if ((firstTrack == CDIO_INVALID_TRACK) || (lastTrack == CDIO_INVALID_TRACK))
{
qInfo() << "Empty disc detected!";
}
else
{
qInfo() << "First track: " << firstTrack << "Last track: " << lastTrack;
cdtext_t* pCdText = cdio_get_cdtext(mpCDIO);
trackInfo.mCDTrackNo = 0;
trackInfo.mStartLba = 0;
trackInfo.mTType = c2n::TrackType::DISC;
trackInfo.mLbCount = cdio_cddap_track_lastsector(mpCDAudio, lastTrack) - cdio_cddap_track_firstsector(mpCDAudio, firstTrack);
parseCDText(pCdText, 0, trackInfo.mTitle);
mAudioTracks.append(trackInfo);
for (track_t t = firstTrack; t <= lastTrack; t++)
{
trackInfo.mCDTrackNo = t;
trackInfo.mTType = (cdio_get_track_format(mpCDIO, t) == TRACK_FORMAT_AUDIO) ? c2n::TrackType::AUDIO : c2n::TrackType::DATA;
trackInfo.mStartLba = cdio_cddap_track_firstsector(mpCDAudio, t);
trackInfo.mLbCount = cdio_cddap_track_lastsector(mpCDAudio, t) - trackInfo.mStartLba;
parseCDText(pCdText, t, trackInfo.mTitle);
mAudioTracks.append(trackInfo);
}
#ifdef Q_OS_MAC
if (!pCdText)
{
doSignal = false;
mpDrUtil->start();
}
#else
if (!pCdText && mbCDDB)
{
doSignal = false;
cddbRequest();
}
#endif // Q_OS_MAC
}
}
if (doSignal)
{
emit match(mAudioTracks);
}
return mAudioTracks.isEmpty() ? -1 : 0;
}
#ifdef Q_OS_MAC
//--------------------------------------------------------------------------
//! @brief CD-Text data created by CDRUtil
//!
//! @param[in] cdtdata CD-Text data
//--------------------------------------------------------------------------
void CJackTheRipper::macCDText(CDRUtil::CDTextData cdtdata)
{
if (!cdtdata.isEmpty())
{
QString title;
for (int i = 0; i < mAudioTracks.count(); i++)
{
title = "";
if (i < cdtdata.count())
{
if (!cdtdata.at(i).mArtist.isEmpty())
{
title = cdtdata.at(i).mArtist.trimmed() + " - ";
}
title += cdtdata.at(i).mTitle.trimmed();
mAudioTracks[i].mTitle = title;
}
}
}
else if (mbCDDB)
{
cddbRequest();
return;
}
emit match(mAudioTracks);
}
#endif
void CJackTheRipper::noBusy()
{
mBusy = false;
}
void CJackTheRipper::getProgress(int percent)
{
emit progress(percent);
}
//--------------------------------------------------------------------------
//! @brief remove temporary files
//--------------------------------------------------------------------------
void CJackTheRipper::removeTemp()
{
for (const auto& c : mAudioTracks)
{
if (c.mWaveFileName != c.mFileName)
{
if (QFile::exists(c.mWaveFileName))
{
QFile::remove(c.mWaveFileName);
}
}
}
}
//--------------------------------------------------------------------------
//! @brief set audio tracks
//!
//! @param[in] audio tracks vector
//--------------------------------------------------------------------------
void CJackTheRipper::setAudioTracks(const c2n::AudioTracks &tracks)
{
mAudioTracks = tracks;
}
//--------------------------------------------------------------------------
//! @brief set device info
//!
//! @param[in] info device info
//--------------------------------------------------------------------------
void CJackTheRipper::setDeviceInfo(const QString &info)
{
mDevInfo = info;
}
///////////////////////////////////////////////////////////////////////////////////
//--------------------------------------------------------------------------
//! @brief Constructs a new instance.
//!
//! @param parent The parent
//! @param ppCDIO The pp cdio
//! @param ppCDAudio The pp cd audio
//! @param ppCDParanoia The pp cd paranoia
//--------------------------------------------------------------------------
CCDInitThread::CCDInitThread(QObject* parent, CdIo_t** ppCDIO, cdrom_drive_t** ppCDAudio,
cdrom_paranoia_t** ppCDParanoia)
:QThread(parent), mppCDIO(ppCDIO), mppCDAudio(ppCDAudio), mppCDParanoia(ppCDParanoia)
{
}
void CCDInitThread::run()
{
char **ppsz_cd_drives = nullptr;
QString devName;
ppsz_cd_drives = cdio_get_devices_with_cap(nullptr, CDIO_FS_AUDIO, false);
if (ppsz_cd_drives && *ppsz_cd_drives)
{
devName = *ppsz_cd_drives;
cdio_free_device_list(ppsz_cd_drives);
}
if (!devName.isEmpty())
{
*mppCDIO = cdio_open(static_cast<const char*>(devName.toUtf8()), DRIVER_UNKNOWN);
if (*mppCDIO)
{
*mppCDAudio = cdio_cddap_identify_cdio(*mppCDIO, CDDA_MESSAGE_FORGETIT, nullptr);
if (*mppCDAudio)
{
if (cdio_cddap_open(*mppCDAudio) == 0)
{
*mppCDParanoia = cdio_paranoia_init(*mppCDAudio);
}
}
else
{
qInfo() << "Can't identify CDDA!";
}
}
}
emit finished();
}
////////////////////////////////////////////////////////////////////////
const int CCopyShopThread::PERCENTS[] = {0, 25, 50, 75};
//--------------------------------------------------------------------------
//! @brief Constructs a new instance.
//!
//! @param parent The parent
//! @param cueMap ref. to cue map
//! @param track The track number
//! @param fName The target file name
//--------------------------------------------------------------------------
CCopyShopThread::CCopyShopThread(QObject* parent, AudioTracks& cueMap, int track, const QString& fName)
:QThread(parent), mCueMap(cueMap), mTrack(track), mName(fName), mPercentPos(0)
{
}
//--------------------------------------------------------------------------
//! @brief pseudo update progress
//--------------------------------------------------------------------------
void CCopyShopThread::updPercent()
{
if (++mPercentPos >= (sizeof(PERCENTS) / sizeof(int)))
{
mPercentPos = 0;
}
emit progress(PERCENTS[mPercentPos]);
}
//--------------------------------------------------------------------------
//! @brief thread function
//--------------------------------------------------------------------------
void CCopyShopThread::run()
{
if (mTrack == -1)
{
// DAO
for (const auto& t : mCueMap)
{
updPercent();
if (!t.mWaveFileName.isEmpty() && (t.mWaveFileName == t.mFileName))
{
if (QFile::exists(mName))
{
QFile::remove(mName);
}
QFile::copy(t.mWaveFileName, mName);
break;
}
}
}
else if ((mTrack > 0) && (mTrack < mCueMap.size()))
{
STrackInfo& cinfo = mCueMap[mTrack];
updPercent();
if (audio::extractRange(cinfo.mWaveFileName, mName, cinfo.mStartLba, cinfo.mLbCount) != 0)
{
qInfo() << "Can't extract wave data.";
}
}
else
{
qWarning() << "Track" << mTrack << "not included in cue file!";
}
emit progress(100);
emit finished();
}