void operator()(const Formats::Archived::File& cur) { if (Progress.get()) { const String text = ProgressMessage(Id, Path, cur.GetName()); Progress->OnProgress(Current, text); } }
void ProgressAction::ShowProgress() { DWORD dwTicks1 = GetTickCount(); if(dwTicks1-dwTicks > TICK_INTERVAL_TO_SHOW) { TCHAR buf[80]; ProgressMessage(buf); const TCHAR *Items[]={ProgressTitle(),buf}; Message(0,NULL,Items,_countof(Items),0); if(CheckForEsc()) { AbortAction(); SetLastError(ERROR_CANCELLED); throw WinExcept(ERROR_CANCELLED); } dwTicks = dwTicks1; } }
bool RDRenderer::Render(const QString &outfile,RDLogEvent *log,RDSettings *s, const QTime &start_time,bool ignore_stops, QString *err_msg,int first_line,int last_line, const QTime &first_time,const QTime &last_time) { float *pcm=NULL; QTime current_time=start_time; QString temp_output_filename; render_warnings.clear(); render_abort=false; // // Open Output File // SF_INFO sf_info; SNDFILE *sf_out; memset(&sf_info,0,sizeof(sf_info)); sf_info.samplerate=rda->system()->sampleRate(); sf_info.channels=s->channels(); if(s->format()==RDSettings::Pcm16) { sf_info.format=SF_FORMAT_WAV|SF_FORMAT_PCM_16; } else { sf_info.format=SF_FORMAT_WAV|SF_FORMAT_PCM_24; } sf_out=sf_open(outfile,SFM_WRITE,&sf_info); if(sf_out==NULL) { fprintf(stderr,"rdrender: unable to open output file [%s]\n", sf_strerror(sf_out)); return 1; } // // Initialize the log // std::vector<__RDRenderLogLine *> lls; for(int i=0;i<log->size();i++) { lls.push_back(new __RDRenderLogLine(log->logLine(i),s->channels())); if(ignore_stops&&(lls.back()->transType()==RDLogLine::Stop)) { lls.back()->setTransType(RDLogLine::Play); } if((!first_time.isNull())&& (lls.back()->timeType()==RDLogLine::Hard)&& (first_line==-1)&& (lls.back()->startTime(RDLogLine::Imported)==first_time)) { first_line=i; } if((!last_time.isNull())&& (lls.back()->timeType()==RDLogLine::Hard)&& (last_line==-1)&& (lls.back()->startTime(RDLogLine::Imported)==last_time)) { last_line=i; } } if((!first_time.isNull())&&(first_line==-1)) { *err_msg+=tr("first-time event not found"); } if((!last_time.isNull())&&(last_line==-1)) { if(!err_msg->isEmpty()) { *err_msg+=", "; } *err_msg+=tr("last-time event not found"); } if(!err_msg->isEmpty()) { return false; } lls.push_back(new __RDRenderLogLine(new RDLogLine(),s->channels())); lls.back()->setTransType(RDLogLine::Play); if((!first_time.isNull())&&(first_line==-1)) { first_line=log->size(); } // // Iterate through it // for(unsigned i=0;i<lls.size();i++) { if(render_abort) { emit lineStarted(log->size()+render_total_passes-1, log->size()+render_total_passes-1); *err_msg+="Render aborted.\n"; sf_close(sf_out); return false; } emit lineStarted(i,log->size()+render_total_passes-1); if(((first_line==-1)||(first_line<=(int)i))&& ((last_line==-1)||(last_line>(int)i))) { if(lls.at(i)->transType()==RDLogLine::Stop) { ProgressMessage(current_time,i,tr("STOP")+" ",lls.at(i)->summary()); render_warnings. push_back(tr("log render halted at line")+QString().sprintf(" %d ",i)+ tr("due to STOP")); break; } if(lls.at(i)->open(current_time)) { ProgressMessage(current_time,i, RDLogLine::transText(lls.at(i)->transType()), QString().sprintf(" cart %06u [",lls.at(i)->cartNumber())+ lls.at(i)->title()+"]"); sf_count_t frames=0; if((lls.at(i+1)->transType()==RDLogLine::Segue)&& (lls.at(i)->segueStartPoint()>=0)) { frames=FramesFromMsec(lls.at(i)->segueStartPoint()- lls.at(i)->startPoint()); current_time= current_time.addMSecs(lls.at(i)->segueStartPoint()- lls.at(i)->startPoint()); } else { frames=FramesFromMsec(lls.at(i)->endPoint()- lls.at(i)->startPoint()); current_time=current_time.addMSecs(lls.at(i)->endPoint()- lls.at(i)->startPoint()); } pcm=new float[frames*s->channels()]; memset(pcm,0,frames*s->channels()*sizeof(float)); for(unsigned j=0;j<i;j++) { Sum(pcm,lls.at(j),frames,s->channels()); } Sum(pcm,lls.at(i),frames,s->channels()); sf_writef_float(sf_out,pcm,frames); delete pcm; pcm=NULL; lls.at(i)->setRamp(lls.at(i+1)->transType()); } else { if(i<(lls.size()-1)) { if(lls.at(i)->type()==RDLogLine::Cart) { ProgressMessage(current_time,i,tr("FAIL"),lls.at(i)->summary()+ " ("+tr("NO AUDIO AVAILABLE")+")"); render_warnings. push_back(lls.at(i)->summary()+tr("at line")+ QString().sprintf(" %d ",i)+ tr("failed to play (NO AUDIO AVAILABLE)")); } else { ProgressMessage(current_time,i,tr("SKIP"),lls.at(i)->summary()); } } else { ProgressMessage(current_time,lls.size()-1, tr("STOP"),tr("--- end of log ---")); } } } } sf_close(sf_out); return true; }
bool RDRenderer::renderToCart(unsigned cartnum,int cutnum,RDLogEvent *log, RDSettings *s,const QTime &start_time, bool ignore_stops,QString *err_msg, int first_line,int last_line, const QTime &first_time,const QTime &last_time) { QString temp_output_filename; char tempdir[PATH_MAX]; bool ok=false; if(first_line<0) { first_line=0; } if(last_line<0) { last_line=log->size(); } // // Check that we won't overflow the 32 bit BWF structures // when we go to import the rendered log back into the audio store // if((double)log->length(first_line,last_line-1)/1000.0>= (1073741824.0/((double)s->channels()*(double)s->sampleRate()))) { *err_msg=tr("Rendered log is too long!"); return false; } ProgressMessage(tr("Pass 1 of 2")); render_total_passes=2; // // Verify Destination // if(!RDCart::exists(cartnum)) { *err_msg=tr("no such cart"); return false; } if(!RDCut::exists(cartnum,cutnum)) { *err_msg=tr("no such cut"); return false; } // // Get Temporary File // strncpy(tempdir,RDTempDirectory::basePath()+"/rdrenderXXXXXX",PATH_MAX); temp_output_filename=QString(mkdtemp(tempdir))+"/log.wav"; ProgressMessage(tr("Using temporary file")+" \""+temp_output_filename+"\"."); // // Render It // if(!Render(temp_output_filename,log,s,start_time,ignore_stops,err_msg, first_line,last_line,first_time,last_time)) { return false; } // // Convert It // ProgressMessage(tr("Pass 2 of 2")); ProgressMessage(tr("Importing cart")); ok=ImportCart(temp_output_filename,cartnum,cutnum,s->channels(),err_msg); DeleteTempFile(temp_output_filename); emit lineStarted(log->size()+1,log->size()+1); if(!ok) { return false; } return true; }
bool RDRenderer::renderToFile(const QString &outfile,RDLogEvent *log, RDSettings *s,const QTime &start_time, bool ignore_stops,QString *err_msg, int first_line,int last_line, const QTime &first_time,const QTime &last_time) { QString temp_output_filename; char tempdir[PATH_MAX]; bool ok=false; FILE *f=NULL; bool ret; // // Verify Destination // if((f=fopen(outfile,"w"))==NULL) { *err_msg=tr("unable to open output file")+" ["+QString(strerror(errno))+"]"; return false; } fclose(f); if(((s->format()!=RDSettings::Pcm16)&&(s->format()!=RDSettings::Pcm24))|| (s->normalizationLevel()!=0)) { ProgressMessage("Pass 1 of 2"); render_total_passes=2; // // Get Temporary File // strncpy(tempdir,RDTempDirectory::basePath()+"/rdrenderXXXXXX",PATH_MAX); temp_output_filename=QString(mkdtemp(tempdir))+"/log.wav"; ProgressMessage(tr("Using temporary file")+" \""+temp_output_filename+"\"."); // // Render It // if(!Render(temp_output_filename,log,s,start_time,ignore_stops,err_msg, first_line,last_line,first_time,last_time)) { return false; } // // Convert It // ProgressMessage(tr("Pass 2 of 2")); ProgressMessage(tr("Writing output file")); ok=ConvertAudio(temp_output_filename,outfile,s,err_msg); DeleteTempFile(temp_output_filename); emit lineStarted(log->size()+1,log->size()+1); if(!ok) { return false; } } else { ProgressMessage(tr("Pass 1 of 1")); render_total_passes=1; ret=Render(outfile,log,s,start_time,ignore_stops,err_msg, first_line,last_line,first_time,last_time); emit lineStarted(log->size(),log->size()); return ret; } return true; }
RawProgressCallback(const Module::DetectCallback& callback, uint_t limit, const String& path) : Delegate(CreateProgressCallback(callback, limit)) , Text(ProgressMessage(ID, path)) { }