From 655d4c37a3227195654ea9e6bc74a8049383ab27 Mon Sep 17 00:00:00 2001 From: Fred Gleason Date: Thu, 11 May 2017 08:17:04 -0400 Subject: [PATCH] 2017-05-11 Fred Gleason * Added a workaround for icedax(1)'s idiotic user prompt in 'lib/rdcddblookup.cpp' to prevent freezes when attempting to read CD-TEXT. --- ChangeLog | 4 ++++ lib/rdcddblookup.cpp | 35 ++++++++++++++++++++++++++++++----- 2 files changed, 34 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 79639b48..54cfc9e5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -15767,3 +15767,7 @@ last modified datestamp. 2017-05-10 Fred Gleason * Incremented the package version to 2.15.3int05. +2017-05-11 Fred Gleason + * Added a workaround for icedax(1)'s idiotic user prompt in + 'lib/rdcddblookup.cpp' to prevent freezes when attempting to read + CD-TEXT. diff --git a/lib/rdcddblookup.cpp b/lib/rdcddblookup.cpp index 599d2b0d..cec81000 100644 --- a/lib/rdcddblookup.cpp +++ b/lib/rdcddblookup.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -320,7 +321,6 @@ int RDCddbLookup::GetIndex(QString *tag) bool RDCddbLookup::ReadCdText(const QString &cdda_dir,const QString &cdda_dev) { - int err=0; RDProfile *title_profile=new RDProfile(); bool ret=false; QString str; @@ -329,12 +329,37 @@ bool RDCddbLookup::ReadCdText(const QString &cdda_dir,const QString &cdda_dev) // // Write the Track Title Data to a Temp File // - cmd=QString().sprintf("CURDIR=`pwd`;cd %s;cdda2wav -D %s --info-only -v titles 2> /dev/null;cd $CURDIR", - (const char *)cdda_dir, - (const char *)cdda_dev); - if((err=system(cmd))!=0) { + QByteArray output; + QProcess *proc=new QProcess(this); + proc->addArgument("cdda2wav"); + proc->addArgument("-D"); + proc->addArgument(cdda_dev); + proc->addArgument("--info-only"); + proc->addArgument("-v"); + proc->addArgument("titles"); + proc->setWorkingDirectory(cdda_dir); + if(!proc->start()) { + delete proc; return false; } + while(proc->isRunning()) { + output=proc->readStderr(); + if(output.size()>0) { // Work around icedax(1)'s idiotic user prompt + if(strncmp(output,"load cdrom please and press enter",33)==0) { + printf("icedax killed!\n"); + proc->kill(); + delete proc; + return false; + } + printf("icedax spinning...\n"); + } + } + if((!proc->normalExit())||(proc->exitStatus()!=0)) { + delete proc; + return false; + } + delete proc; + printf("icedax success!\n"); // // Read the Track Title Data File