本文整理汇总了C++中CGUIDialogProgress::IsCanceled方法的典型用法代码示例。如果您正苦于以下问题:C++ CGUIDialogProgress::IsCanceled方法的具体用法?C++ CGUIDialogProgress::IsCanceled怎么用?C++ CGUIDialogProgress::IsCanceled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CGUIDialogProgress
的用法示例。
在下文中一共展示了CGUIDialogProgress::IsCanceled方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: progress
/*! \brief Progress callback from rar manager.
\return true to continue processing, false to cancel.
*/
bool progress(int progress, const char *text)
{
bool cont(true);
if ((shown || showTime.IsTimePast()) && g_application.IsCurrentThread())
{
// grab the busy and show it
CGUIDialogProgress* dlg = (CGUIDialogProgress*)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS);
if (dlg)
{
if (!shown)
{
dlg->SetHeading(CVariant{heading});
dlg->Open();
}
if (progress >= 0)
{
dlg->ShowProgressBar(true);
dlg->SetPercentage(progress);
}
if (text)
dlg->SetLine(1, CVariant{text});
cont = !dlg->IsCanceled();
shown = true;
// tell render loop to spin
dlg->Progress();
}
}
return cont;
};
示例2: WaitForNetwork
bool CGUIMediaWindow::WaitForNetwork() const
{
if (g_application.getNetwork().IsAvailable())
return true;
CGUIDialogProgress *progress = (CGUIDialogProgress *)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS);
if (!progress)
return true;
CURL url(m_vecItems->GetPath());
progress->SetHeading(1040); // Loading Directory
progress->SetLine(1, url.GetWithoutUserDetails());
progress->ShowProgressBar(false);
progress->StartModal();
while (!g_application.getNetwork().IsAvailable())
{
progress->Progress();
if (progress->IsCanceled())
{
progress->Close();
return false;
}
}
progress->Close();
return true;
}
示例3: OnInitWindow
void CGUIWindowPVRBase::OnInitWindow(void)
{
if (!g_PVRManager.IsStarted() || !g_PVRClients->HasConnectedClients())
{
// wait until the PVR manager has been started
CGUIDialogProgress* dialog = static_cast<CGUIDialogProgress*>(g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS));
if (dialog)
{
dialog->SetHeading(CVariant{19235});
dialog->SetText(CVariant{19045});
dialog->ShowProgressBar(false);
dialog->Open();
// do not block the gfx context while waiting
CSingleExit exit(g_graphicsContext);
CEvent event(true);
while(!event.WaitMSec(1))
{
if (g_PVRManager.IsStarted() && g_PVRClients->HasConnectedClients())
event.Set();
if (dialog->IsCanceled())
{
// return to previous window if canceled
dialog->Close();
g_windowManager.PreviousWindow();
return;
}
g_windowManager.ProcessRenderLoop(false);
}
dialog->Close();
}
}
{
// set window group to playing group
CPVRChannelGroupPtr group = g_PVRManager.GetPlayingGroup(m_bRadio);
CSingleLock lock(m_critSection);
if (m_group != group)
m_viewControl.SetSelectedItem(0);
m_group = group;
}
SetProperty("IsRadio", m_bRadio ? "true" : "");
m_vecItems->SetPath(GetDirectoryPath());
CGUIMediaWindow::OnInitWindow();
// mark item as selected by channel path
m_viewControl.SetSelectedItem(GetSelectedItemPath(m_bRadio));
}
示例4: PromptForInstall
bool CAddonInstaller::PromptForInstall(const std::string &addonID, AddonPtr &addon)
{
if (!g_passwordManager.CheckMenuLock(WINDOW_ADDON_BROWSER))
return false;
// we assume that addons that are enabled don't get to this routine (i.e. that GetAddon() has been called)
if (CAddonMgr::Get().GetAddon(addonID, addon, ADDON_UNKNOWN, false))
return false; // addon is installed but disabled, and the user has specifically activated something that needs
// the addon - should we enable it?
// check we have it available
CAddonDatabase database;
database.Open();
if (database.GetAddon(addonID, addon))
{ // yes - ask user if they want it installed
if (!CGUIDialogYesNo::ShowAndGetInput(g_localizeStrings.Get(24076), g_localizeStrings.Get(24100),
addon->Name().c_str(), g_localizeStrings.Get(24101)))
return false;
if (Install(addonID, true))
{
CGUIDialogProgress *progress = (CGUIDialogProgress *)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS);
if (progress)
{
progress->SetHeading(13413); // Downloading
progress->SetLine(0, "");
progress->SetLine(1, addon->Name());
progress->SetLine(2, "");
progress->SetPercentage(0);
progress->StartModal();
while (true)
{
progress->Progress();
unsigned int percent;
if (progress->IsCanceled())
{
Cancel(addonID);
break;
}
if (!GetProgress(addonID, percent))
break;
progress->SetPercentage(percent);
}
progress->Close();
}
return CAddonMgr::Get().GetAddon(addonID, addon);
}
}
return false;
}
示例5: Copy
bool CAsyncFileCopy::Copy(const std::string &from, const std::string &to, const std::string &heading)
{
// reset the variables to their appropriate states
m_from = from;
m_to = to;
m_cancelled = false;
m_succeeded = false;
m_percent = 0;
m_speed = 0;
m_running = true;
CURL url1(from);
CURL url2(to);
// create our thread, which starts the file copy operation
Create();
CGUIDialogProgress *dlg = (CGUIDialogProgress *)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS);
unsigned int time = XbmcThreads::SystemClockMillis();
while (m_running)
{
m_event.WaitMSec(1000 / 30);
if (!m_running)
break;
// start the dialog up as needed
if (dlg && !dlg->IsDialogRunning() && (XbmcThreads::SystemClockMillis() - time) > 500) // wait 0.5 seconds before starting dialog
{
dlg->SetHeading(CVariant{heading});
dlg->SetLine(0, CVariant{url1.GetWithoutUserDetails()});
dlg->SetLine(1, CVariant{url2.GetWithoutUserDetails()});
dlg->SetPercentage(0);
dlg->StartModal();
}
// and update the dialog as we go
if (dlg && dlg->IsDialogRunning())
{
dlg->SetHeading(CVariant{heading});
dlg->SetLine(0, CVariant{url1.Get()});
dlg->SetLine(1, CVariant{url2.Get()});
dlg->SetLine(2, CVariant{ StringUtils::Format("%2.2f KB/s", m_speed / 1024) });
dlg->SetPercentage(m_percent);
dlg->Progress();
m_cancelled = dlg->IsCanceled();
}
}
if (dlg)
dlg->Close();
return !m_cancelled && m_succeeded;
}
示例6: GetDirectory
bool CPlexDirectory::GetDirectory(const CStdString& strPath, CFileItemList &items)
{
CStdString strRoot = strPath;
if (CUtil::HasSlashAtEnd(strRoot) && strRoot != "plex://")
strRoot.Delete(strRoot.size() - 1);
strRoot.Replace(" ", "%20");
// Start the download thread running.
printf("PlexDirectory::GetDirectory(%s)\n", strRoot.c_str());
m_url = strRoot;
CThread::Create(false, 0);
// Now display progress, look for cancel.
CGUIDialogProgress* dlgProgress = 0;
int time = GetTickCount();
while (m_downloadEvent.WaitMSec(100) == false)
{
// If enough time has passed, display the dialog.
if (GetTickCount() - time > 1000 && m_allowPrompting == true)
{
dlgProgress = (CGUIDialogProgress*)m_gWindowManager.GetWindow(WINDOW_DIALOG_PROGRESS);
if (dlgProgress)
{
dlgProgress->ShowProgressBar(false);
dlgProgress->SetHeading(40203);
dlgProgress->SetLine(0, 40204);
dlgProgress->SetLine(1, "");
dlgProgress->SetLine(2, "");
dlgProgress->StartModal();
}
}
if (dlgProgress)
{
dlgProgress->Progress();
if (dlgProgress->IsCanceled())
{
items.m_wasListingCancelled = true;
m_http.Cancel();
StopThread();
}
}
}
if (dlgProgress)
dlgProgress->Close();
// Wait for the thread to exit.
WaitForThreadExit(INFINITE);
// See if we suceeded.
if (m_bSuccess == false)
return false;
// See if we're supposed to parse the results or not.
if (m_bParseResults == false)
return true;
// Parse returned xml.
TiXmlDocument doc;
doc.Parse(m_data.c_str());
TiXmlElement* root = doc.RootElement();
if (root == 0)
{
CLog::Log(LOGERROR, "%s - Unable to parse XML\n%s", __FUNCTION__, m_data.c_str());
return false;
}
// Get the fanart.
const char* fanart = root->Attribute("art");
string strFanart;
if (fanart && strlen(fanart) > 0)
strFanart = ProcessUrl(strPath, fanart, false);
// Walk the parsed tree.
string strFileLabel = "%N - %T";
string strDirLabel = "%B";
string strSecondDirLabel = "%Y";
Parse(m_url, root, items, strFileLabel, strDirLabel, strSecondDirLabel);
// Set the window titles
const char* title1 = root->Attribute("title1");
const char* title2 = root->Attribute("title2");
if (title1 && strlen(title1) > 0)
items.SetFirstTitle(title1);
if (title2 && strlen(title2) > 0)
items.SetSecondTitle(title2);
// Set fanart on items if they don't have their own.
for (int i=0; i<items.Size(); i++)
{
CFileItemPtr pItem = items[i];
if (strFanart.size() > 0 && pItem->GetQuickFanart().size() == 0)
//.........这里部分代码省略.........
示例7: WaitOnScriptResult
bool CPluginDirectory::WaitOnScriptResult(const CStdString &scriptPath, int scriptId, const CStdString &scriptName, bool retrievingDir)
{
const unsigned int timeBeforeProgressBar = 1500;
const unsigned int timeToKillScript = 1000;
unsigned int startTime = XbmcThreads::SystemClockMillis();
CGUIDialogProgress *progressBar = NULL;
bool cancelled = false;
bool inMainAppThread = g_application.IsCurrentThread();
CLog::Log(LOGDEBUG, "%s - waiting on the %s (id=%d) plugin...", __FUNCTION__, scriptName.c_str(), scriptId);
while (true)
{
{
CSingleExit ex(g_graphicsContext);
// check if the python script is finished
if (m_fetchComplete.WaitMSec(20))
{ // python has returned
CLog::Log(LOGDEBUG, "%s- plugin returned %s", __FUNCTION__, m_success ? "successfully" : "failure");
break;
}
}
// check our script is still running
if (!CScriptInvocationManager::Get().IsRunning(scriptId))
{ // check whether we exited normally
if (!m_fetchComplete.WaitMSec(0))
{ // python didn't return correctly
CLog::Log(LOGDEBUG, " %s - plugin exited prematurely - terminating", __FUNCTION__);
m_success = false;
}
break;
}
// check whether we should pop up the progress dialog
if (!retrievingDir && !progressBar && XbmcThreads::SystemClockMillis() - startTime > timeBeforeProgressBar)
{ // loading takes more then 1.5 secs, show a progress dialog
progressBar = (CGUIDialogProgress *)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS);
// if script has shown progressbar don't override it
if (progressBar && progressBar->IsActive())
{
startTime = XbmcThreads::SystemClockMillis();
progressBar = NULL;
}
if (progressBar)
{
progressBar->SetHeading(scriptName);
progressBar->SetLine(0, retrievingDir ? 1040 : 10214);
progressBar->SetLine(1, "");
progressBar->SetLine(2, "");
progressBar->ShowProgressBar(retrievingDir);
progressBar->StartModal();
}
}
if (progressBar)
{ // update the progress bar and check for user cancel
progressBar->Progress();
if (progressBar->IsCanceled())
{ // user has cancelled our process - cancel our process
m_cancelled = true;
}
}
else // if the progressBar exists and we call StartModal or Progress we get the
// ProcessRenderLoop call anyway.
if (inMainAppThread)
g_windowManager.ProcessRenderLoop();
if (!cancelled && m_cancelled)
{
cancelled = true;
startTime = XbmcThreads::SystemClockMillis();
}
if (cancelled && XbmcThreads::SystemClockMillis() - startTime > timeToKillScript)
{ // cancel our script
if (scriptId != -1 && CScriptInvocationManager::Get().IsRunning(scriptId))
{
CLog::Log(LOGDEBUG, "%s- cancelling plugin %s (id=%d)", __FUNCTION__, scriptName.c_str(), scriptId);
CScriptInvocationManager::Get().Stop(scriptId);
break;
}
}
}
if (progressBar)
CApplicationMessenger::Get().Close(progressBar, false, false);
return !cancelled && m_success;
}
示例8: GetDirectory
bool CShoutcastDirectory::GetDirectory(const CStdString& strPath, CFileItemList &items)
{
CStdString strRoot = strPath;
if (CUtil::HasSlashAtEnd(strRoot))
strRoot.Delete(strRoot.size() - 1);
/* for old users wich doesn't have the full url */
if( strRoot.Equals("shout://www.shoutcast.com") )
strRoot = "shout://www.shoutcast.com/sbin/newxml.phtml";
if (g_directoryCache.GetDirectory(strRoot, items))
return true;
CGUIDialogProgress* dlgProgress = (CGUIDialogProgress*)m_gWindowManager.GetWindow(WINDOW_DIALOG_PROGRESS);
if (dlgProgress)
{
dlgProgress->ShowProgressBar(false);
dlgProgress->SetHeading(260);
dlgProgress->SetLine(0, 14003);
dlgProgress->SetLine(1, "");
dlgProgress->SetLine(2, "");
dlgProgress->StartModal();
}
CURL url(strRoot);
CStdString protocol = url.GetProtocol();
url.SetProtocol("http");
CFileCurl http;
//CURL doesn't seem to understand that data is encoded.. odd
// opening as text for now
//http.SetContentEncoding("deflate");
if( !http.Open(url, false) )
{
CLog::Log(LOGERROR, "%s - Unable to get shoutcast dir", __FUNCTION__);
if (dlgProgress) dlgProgress->Close();
return false;
}
/* restore protocol */
url.SetProtocol(protocol);
CStdString content = http.GetContent();
if( !(content.Equals("text/html") || content.Equals("text/xml")
|| content.Equals("text/html;charset=utf-8") || content.Equals("text/xml;charset=utf-8") ))
{
CLog::Log(LOGERROR, "%s - Invalid content type %s", __FUNCTION__, content.c_str());
if (dlgProgress) dlgProgress->Close();
return false;
}
int size_read = 0;
int size_total = (int)http.GetLength();
int data_size = 0;
CStdString data;
data.reserve(size_total);
/* read response from server into string buffer */
char buffer[16384];
while( (size_read = http.Read(buffer, sizeof(buffer)-1)) > 0 )
{
buffer[size_read] = 0;
data += buffer;
data_size += size_read;
dlgProgress->Progress();
if (dlgProgress->IsCanceled())
{
dlgProgress->Close();
return false;
}
}
/* parse returned xml */
TiXmlDocument doc;
doc.Parse(data.c_str());
TiXmlElement *root = doc.RootElement();
if(root == NULL)
{
CLog::Log(LOGERROR, "%s - Unable to parse xml", __FUNCTION__);
CLog::Log(LOGDEBUG, "%s - Sample follows...\n%s", __FUNCTION__, data.c_str());
dlgProgress->Close();
return false;
}
/* clear data to keep memusage down, not needed anymore */
data.Empty();
bool result = false;
if( strcmp(root->Value(), "genrelist") == 0 )
result = ParseGenres(root, items, url);
else if( strcmp(root->Value(), "stationlist") == 0 )
//.........这里部分代码省略.........
示例9: WaitOnScriptResult
bool CPluginDirectory::WaitOnScriptResult(const CStdString &scriptPath, const CStdString &scriptName, bool retrievingDir)
{
const unsigned int timeBeforeProgressBar = 1500;
const unsigned int timeToKillScript = 1000;
unsigned int startTime = XbmcThreads::SystemClockMillis();
CGUIDialogProgress *progressBar = NULL;
CLog::Log(LOGDEBUG, "%s - waiting on the %s plugin...", __FUNCTION__, scriptName.c_str());
while (true)
{
{
CSingleExit ex(g_graphicsContext);
// check if the python script is finished
if (m_fetchComplete.WaitMSec(20))
{ // python has returned
CLog::Log(LOGDEBUG, "%s- plugin returned %s", __FUNCTION__, m_success ? "successfully" : "failure");
break;
}
}
// check our script is still running
#ifdef HAS_PYTHON
if (!g_pythonParser.isRunning(g_pythonParser.getScriptId(scriptPath.c_str())))
#endif
{ // check whether we exited normally
if (!m_fetchComplete.WaitMSec(0))
{ // python didn't return correctly
CLog::Log(LOGDEBUG, " %s - plugin exited prematurely - terminating", __FUNCTION__);
m_success = false;
}
break;
}
// check whether we should pop up the progress dialog
if (!progressBar && XbmcThreads::SystemClockMillis() - startTime > timeBeforeProgressBar)
{ // loading takes more then 1.5 secs, show a progress dialog
progressBar = (CGUIDialogProgress *)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS);
// if script has shown progressbar don't override it
if (progressBar && progressBar->IsActive())
{
startTime = XbmcThreads::SystemClockMillis();
progressBar = NULL;
}
if (progressBar)
{
progressBar->SetHeading(scriptName);
progressBar->SetLine(0, retrievingDir ? 1040 : 10214);
progressBar->SetLine(1, "");
progressBar->SetLine(2, "");
progressBar->ShowProgressBar(retrievingDir);
progressBar->StartModal();
}
}
if (progressBar)
{ // update the progress bar and check for user cancel
if (retrievingDir)
{
CStdString label;
if (m_totalItems > 0)
{
label.Format(g_localizeStrings.Get(1042).c_str(), m_listItems->Size(), m_totalItems);
progressBar->SetPercentage((int)((m_listItems->Size() * 100 ) / m_totalItems));
progressBar->ShowProgressBar(true);
}
else
label.Format(g_localizeStrings.Get(1041).c_str(), m_listItems->Size());
progressBar->SetLine(2, label);
}
progressBar->Progress();
if (progressBar->IsCanceled())
{ // user has cancelled our process - cancel our process
if (!m_cancelled)
{
m_cancelled = true;
startTime = XbmcThreads::SystemClockMillis();
}
if (m_cancelled && XbmcThreads::SystemClockMillis() - startTime > timeToKillScript)
{ // cancel our script
#ifdef HAS_PYTHON
int id = g_pythonParser.getScriptId(scriptPath.c_str());
if (id != -1 && g_pythonParser.isRunning(id))
{
CLog::Log(LOGDEBUG, "%s- cancelling plugin %s", __FUNCTION__, scriptName.c_str());
g_pythonParser.stopScript(id);
break;
}
#endif
}
}
}
}
if (progressBar)
CApplicationMessenger::Get().Close(progressBar, false, false);
return !m_cancelled && m_success;
}
示例10: WaitOnScriptResult
bool CPluginDirectory::WaitOnScriptResult(const CStdString &scriptPath, const CStdString &scriptName)
{
const unsigned int timeBeforeProgressBar = 1500;
const unsigned int timeToKillScript = 1000;
DWORD startTime = timeGetTime();
CGUIDialogProgress *progressBar = NULL;
CLog::Log(LOGDEBUG, "%s - waiting on the %s plugin...", __FUNCTION__, scriptName.c_str());
while (true)
{
// check if the python script is finished
if (WaitForSingleObject(m_directoryFetched, 20) == WAIT_OBJECT_0)
{ // python has returned
CLog::Log(LOGDEBUG, "%s- plugin returned %s", __FUNCTION__, m_success ? "successfully" : "failure");
break;
}
// check our script is still running
int id = g_pythonParser.getScriptId(scriptPath.c_str());
if (id == -1)
{ // nope - bail
CLog::Log(LOGDEBUG, " %s - plugin exited prematurely - terminating", __FUNCTION__);
m_success = false;
break;
}
// check whether we should pop up the progress dialog
if (!progressBar && timeGetTime() - startTime > timeBeforeProgressBar)
{ // loading takes more then 1.5 secs, show a progress dialog
progressBar = (CGUIDialogProgress *)m_gWindowManager.GetWindow(WINDOW_DIALOG_PROGRESS);
if (progressBar)
{
progressBar->SetHeading(scriptName);
progressBar->SetLine(0, 1040);
progressBar->SetLine(1, "");
progressBar->SetLine(2, "");
progressBar->StartModal();
}
}
if (progressBar)
{ // update the progress bar and check for user cancel
CStdString label;
if (m_totalItems > 0)
{
label.Format(g_localizeStrings.Get(1042).c_str(), m_listItems->Size(), m_totalItems);
progressBar->SetPercentage((int)((m_listItems->Size() * 100 ) / m_totalItems));
progressBar->ShowProgressBar(true);
}
else
label.Format(g_localizeStrings.Get(1041).c_str(), m_listItems->Size());
progressBar->SetLine(2, label);
progressBar->Progress();
if (progressBar->IsCanceled())
{ // user has cancelled our process - cancel our process
if (!m_cancelled)
{
m_cancelled = true;
startTime = timeGetTime();
}
if (m_cancelled && timeGetTime() - startTime > timeToKillScript)
{ // cancel our script
int id = g_pythonParser.getScriptId(scriptPath.c_str());
if (id != -1 && g_pythonParser.isRunning(id))
{
CLog::Log(LOGDEBUG, "%s- cancelling plugin %s", __FUNCTION__, scriptName.c_str());
g_pythonParser.stopScript(id);
break;
}
}
}
}
}
if (progressBar)
progressBar->Close();
return !m_cancelled && m_success;
}
示例11: Open
bool CFileShoutcast::Open(const CURL& url, bool bBinary)
{
m_dwLastTime = timeGetTime();
int ret;
CGUIDialogProgress* dlgProgress = (CGUIDialogProgress*)m_gWindowManager.GetWindow(WINDOW_DIALOG_PROGRESS);
set_rip_manager_options_defaults(&m_opt);
strcpy(m_opt.output_directory, "./");
m_opt.proxyurl[0] = '\0';
// Use a proxy, if the GUI was configured as such
bool bProxyEnabled = g_guiSettings.GetBool("network.usehttpproxy");
if (bProxyEnabled)
{
const CStdString &strProxyServer = g_guiSettings.GetString("network.httpproxyserver");
const CStdString &strProxyPort = g_guiSettings.GetString("network.httpproxyport");
// Should we check for valid strings here
#ifndef _LINUX
_snprintf( m_opt.proxyurl, MAX_URL_LEN, "http://%s:%s", strProxyServer.c_str(), strProxyPort.c_str() );
#else
snprintf( m_opt.proxyurl, MAX_URL_LEN, "http://%s:%s", strProxyServer.c_str(), strProxyPort.c_str() );
#endif
}
CStdString strUrl;
url.GetURL(strUrl);
strUrl.Replace("shout://", "http://");
printf("Opening url: %s\n", strUrl.c_str());
strncpy(m_opt.url, strUrl.c_str(), MAX_URL_LEN);
sprintf(m_opt.useragent, "x%s", url.GetFileName().c_str());
if (dlgProgress)
{
dlgProgress->SetHeading(260);
dlgProgress->SetLine(0, 259);
dlgProgress->SetLine(1, strUrl);
dlgProgress->SetLine(2, "");
if (!dlgProgress->IsDialogRunning())
dlgProgress->StartModal();
dlgProgress->Progress();
}
if ((ret = rip_manager_start(rip_callback, &m_opt)) != SR_SUCCESS)
{
if (dlgProgress) dlgProgress->Close();
return false;
}
int iShoutcastTimeout = 10 * SHOUTCASTTIMEOUT; //i.e: 10 * 10 = 100 * 100ms = 10s
int iCount = 0;
while (!m_fileState.bRipDone && !m_fileState.bRipStarted && !m_fileState.bRipError && (!dlgProgress || !dlgProgress->IsCanceled()))
{
if (iCount <= iShoutcastTimeout) //Normally, this isn't the problem,
//because if RIP_MANAGER fails, this would be here
//with m_fileState.bRipError
{
Sleep(100);
}
else
{
if (dlgProgress)
{
dlgProgress->SetLine(1, 257);
dlgProgress->SetLine(2, "Connection timed out...");
Sleep(1500);
dlgProgress->Close();
}
return false;
}
iCount++;
}
if (dlgProgress && dlgProgress->IsCanceled())
{
Close();
dlgProgress->Close();
return false;
}
/* store content type of stream */
m_contenttype = rip_manager_get_content_type();
//CHANGED CODE: Don't reset timer anymore.
while (!m_fileState.bRipDone && !m_fileState.bRipError && m_fileState.bBuffering && (!dlgProgress || !dlgProgress->IsCanceled()))
{
if (iCount <= iShoutcastTimeout) //Here is the real problem: Sometimes the buffer fills just to
//slowly, thus the quality of the stream will be bad, and should be
//aborted...
{
Sleep(100);
char szTmp[1024];
//g_dialog.SetCaption(0, "Shoutcast" );
sprintf(szTmp, "Buffering %i bytes", m_ringbuf.GetMaxReadSize());
if (dlgProgress)
{
dlgProgress->SetLine(2, szTmp );
dlgProgress->Progress();
}
//.........这里部分代码省略.........
示例12: DoWork
bool CCDDARipJob::DoWork()
{
CLog::Log(LOGINFO, "Start ripping track %s to %s", m_input.c_str(),
m_output.c_str());
// if we are ripping to a samba share, rip it to hd first and then copy it it the share
CFileItem file(m_output, false);
if (file.IsRemote())
m_output = SetupTempFile();
if (m_output.IsEmpty())
{
CLog::Log(LOGERROR, "CCDDARipper: Error opening file");
return false;
}
// init ripper
CFile reader;
CEncoder* encoder;
if (!reader.Open(m_input,READ_CACHED) || !(encoder=SetupEncoder(reader)))
{
CLog::Log(LOGERROR, "Error: CCDDARipper::Init failed");
return false;
}
// setup the progress dialog
CGUIDialogProgress* pDlgProgress = (CGUIDialogProgress*)g_windowManager.GetWindow(WINDOW_DIALOG_PROGRESS);
CStdString strLine0, strLine1;
int iTrack = atoi(m_input.substr(13, m_input.size() - 13 - 5).c_str());
strLine0.Format("%s %i", g_localizeStrings.Get(606).c_str(), iTrack); // Track Number: %i
strLine1.Format("%s %s", g_localizeStrings.Get(607).c_str(), m_output.c_str()); // To: %s
pDlgProgress->SetHeading(605); // Ripping
pDlgProgress->SetLine(0, strLine0);
pDlgProgress->SetLine(1, strLine1);
pDlgProgress->SetLine(2, "");
pDlgProgress->StartModal();
pDlgProgress->ShowProgressBar(true);
// show progress dialog
pDlgProgress->Progress();
// start ripping
int percent=0;
int oldpercent=0;
bool cancelled(false);
int result;
while (!cancelled && (result=RipChunk(reader, encoder, percent)) == 0)
{
cancelled = ShouldCancel(percent,100);
cancelled |= pDlgProgress->IsCanceled();
if (percent > oldpercent)
{
oldpercent = percent;
pDlgProgress->SetPercentage(percent);
pDlgProgress->Progress();
}
}
pDlgProgress->Close();
// close encoder ripper
encoder->Close();
delete encoder;
reader.Close();
if (file.IsRemote() && !cancelled && result == 2)
{
// copy the ripped track to the share
if (!CFile::Cache(m_output, file.GetPath()))
{
CLog::Log(LOGERROR, "CDDARipper: Error copying file from %s to %s",
m_output.c_str(), file.GetPath().c_str());
CFile::Delete(m_output);
return false;
}
// delete cached file
CFile::Delete(m_output);
}
if (cancelled)
{
CLog::Log(LOGWARNING, "User Cancelled CDDA Rip");
CFile::Delete(m_output);
}
else if (result == 1)
CLog::Log(LOGERROR, "CDDARipper: Error ripping %s", m_input.c_str());
else if (result < 0)
CLog::Log(LOGERROR, "CDDARipper: Error encoding %s", m_input.c_str());
else
{
CLog::Log(LOGINFO, "Finished ripping %s", m_input.c_str());
if (m_eject)
{
CLog::Log(LOGINFO, "Ejecting CD");
g_mediaManager.EjectTray();
}
}
return !cancelled && result == 2;
}