Skip to content

Commit

Permalink
出力時に異常が発生した場合の手当てを追加。
Browse files Browse the repository at this point in the history
  • Loading branch information
rigaya committed Feb 11, 2020
1 parent 6efe1ce commit 5447b6c
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
6 changes: 3 additions & 3 deletions VCECore/rgy_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
#ifndef __RGY_VERSION_H__
#define __RGY_VERSION_H__

#define VER_FILEVERSION 0,5,1,0
#define VER_STR_FILEVERSION "5.01"
#define VER_STR_FILEVERSION_TCHAR _T("5.01")
#define VER_FILEVERSION 0,5,2,0
#define VER_STR_FILEVERSION "5.02"
#define VER_STR_FILEVERSION_TCHAR _T("5.02")


#ifdef _M_IX86
Expand Down
22 changes: 19 additions & 3 deletions VCECore/vce_core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1746,7 +1746,7 @@ RGY_ERR VCECore::run_decode() {
}

RGY_ERR VCECore::run_output() {
m_thOutput = std::thread([this]() {
m_thOutput = std::async(std::launch::async, [this]() {
const auto VCE_TIMEBASE = rgy_rational<int>(1, AMF_SECOND);
while (m_state == RGY_STATE_RUNNING) {
amf::AMFDataPtr data;
Expand Down Expand Up @@ -2135,6 +2135,10 @@ RGY_ERR VCECore::run() {
std::this_thread::sleep_for(std::chrono::milliseconds(1));
} else if (ar == AMF_REPEAT) {
pSurface = nullptr;
} else if (m_thOutput.wait_for(std::chrono::microseconds(0)) != std::future_status::timeout) {
PrintMes(RGY_LOG_ERROR, _T("Error during output.\n"));
m_state = RGY_STATE_ERROR;
break;
} else {
break;
}
Expand Down Expand Up @@ -2188,6 +2192,11 @@ RGY_ERR VCECore::run() {
m_state = RGY_STATE_ERROR;
break;
}
if (m_thOutput.wait_for(std::chrono::microseconds(0)) != std::future_status::timeout) {
PrintMes(RGY_LOG_ERROR, _T("Error during output.\n"));
m_state = RGY_STATE_ERROR;
break;
}
} else {
amf::AMFSurfacePtr surf;
auto ar = AMF_REPEAT;
Expand All @@ -2213,6 +2222,11 @@ RGY_ERR VCECore::run() {
break;
}
std::this_thread::sleep_for(std::chrono::milliseconds(1));
if (m_thOutput.wait_for(std::chrono::microseconds(0)) != std::future_status::timeout) {
PrintMes(RGY_LOG_ERROR, _T("Error during output.\n"));
m_state = RGY_STATE_ERROR;
break;
}
if ((res = run_send_streams(nInputFrame)) != RGY_ERR_NONE) {
m_state = RGY_STATE_ERROR;
break;
Expand Down Expand Up @@ -2302,8 +2316,10 @@ RGY_ERR VCECore::run() {
return err_to_rgy(ar);
}
PrintMes(RGY_LOG_DEBUG, _T("Flushed Encoder\n"));
if (m_thOutput.joinable()) {
m_thOutput.join();
if (m_thOutput.valid()) {
PrintMes(RGY_LOG_DEBUG, _T("Waiting for ouput thread to be finieshed...\n"));
m_thOutput.get();
PrintMes(RGY_LOG_DEBUG, _T("Closed output thread.\n"));
}
if (m_ssim) {
PrintMes(RGY_LOG_DEBUG, _T("Flushing ssim/psnr calc.\n"));
Expand Down
2 changes: 1 addition & 1 deletion VCECore/vce_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ class VCECore {
amf::AMFComponentPtr m_pEncoder;
amf::AMFComponentPtr m_pConverter;
std::thread m_thDecoder;
std::thread m_thOutput;
std::future<RGY_ERR> m_thOutput;

AMFParams m_params;

Expand Down

0 comments on commit 5447b6c

Please sign in to comment.