本文整理汇总了C++中CEncoder::Close方法的典型用法代码示例。如果您正苦于以下问题:C++ CEncoder::Close方法的具体用法?C++ CEncoder::Close怎么用?C++ CEncoder::Close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CEncoder
的用法示例。
在下文中一共展示了CEncoder::Close方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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.empty())
{
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
CGUIDialogExtendedProgressBar* pDlgProgress =
(CGUIDialogExtendedProgressBar*)g_windowManager.GetWindow(WINDOW_DIALOG_EXT_PROGRESS);
CGUIDialogProgressBarHandle* handle = pDlgProgress->GetHandle(g_localizeStrings.Get(605));
int iTrack = atoi(m_input.substr(13, m_input.size() - 13 - 5).c_str());
CStdString strLine0 = StringUtils::Format("%02i. %s - %s", iTrack,
StringUtils::Join(m_tag.GetArtist(), g_advancedSettings.m_musicItemSeparator).c_str(),
m_tag.GetTitle().c_str());
handle->SetText(strLine0);
// 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);
if (percent > oldpercent)
{
oldpercent = percent;
handle->SetPercentage(static_cast<float>(percent));
}
}
// close encoder ripper
encoder->Close();
delete encoder;
reader.Close();
if (file.IsRemote() && !cancelled && result == 2)
{
// copy the ripped track to the share
if (!CFile::Copy(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();
}
}
handle->MarkFinished();
return !cancelled && result == 2;
}
示例2: 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;
}