fix exception handling to gracefully exit (#49)
* fix exception handling to gracefully exit * addressed review comments
이 커밋은 다음에 포함됨:
@@ -254,7 +254,7 @@ int RocVideoDecoder::HandleVideoSequence(RocdecVideoFormat *pVideoFormat) {
|
||||
ROCDEC_API_CALL(rocDecGetDecoderCaps(&decode_caps));
|
||||
|
||||
if(!decode_caps.bIsSupported){
|
||||
THROW("Rocdec:: Codec not supported on this GPU: " + TOSTR(ROCDEC_NOT_SUPPORTED));
|
||||
ROCDEC_THROW("Rocdec:: Codec not supported on this GPU: ", ROCDEC_NOT_SUPPORTED);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -268,8 +268,8 @@ int RocVideoDecoder::HandleVideoSequence(RocdecVideoFormat *pVideoFormat) {
|
||||
<< "Resolution not supported on this GPU ";
|
||||
|
||||
const std::string cErr = errorString.str();
|
||||
THROW(cErr+ TOSTR(ROCDEC_NOT_SUPPORTED));
|
||||
return nDecodeSurface;
|
||||
ROCDEC_THROW(cErr, ROCDEC_NOT_SUPPORTED);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (width_ && height_ && chroma_height_) {
|
||||
@@ -304,7 +304,7 @@ int RocVideoDecoder::HandleVideoSequence(RocdecVideoFormat *pVideoFormat) {
|
||||
else if (decode_caps.nOutputFormatMask & (1 << rocDecVideoSurfaceFormat_YUV444_16Bit))
|
||||
video_surface_format_ = rocDecVideoSurfaceFormat_YUV444_16Bit;
|
||||
else
|
||||
THROW("No supported output format found" + TOSTR(ROCDEC_NOT_SUPPORTED));
|
||||
ROCDEC_THROW("No supported output format found", ROCDEC_NOT_SUPPORTED);
|
||||
}
|
||||
video_format_ = *pVideoFormat;
|
||||
|
||||
@@ -394,7 +394,7 @@ int RocVideoDecoder::HandleVideoSequence(RocdecVideoFormat *pVideoFormat) {
|
||||
|
||||
|
||||
int RocVideoDecoder::ReconfigureDecoder(RocdecVideoFormat *pVideoFormat) {
|
||||
THROW("ReconfigureDecoder is not supported in this version: " + TOSTR(ROCDEC_NOT_SUPPORTED));
|
||||
ROCDEC_THROW("ReconfigureDecoder is not supported in this version: ", ROCDEC_NOT_SUPPORTED);
|
||||
return ROCDEC_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
@@ -407,8 +407,7 @@ int RocVideoDecoder::ReconfigureDecoder(RocdecVideoFormat *pVideoFormat) {
|
||||
int RocVideoDecoder::HandlePictureDecode(RocdecPicParams *pPicParams) {
|
||||
if (!roc_decoder_)
|
||||
{
|
||||
THROW("Decoder not initialized: failed with ErrCode: " + TOSTR(ROCDEC_NOT_INITIALIZED));
|
||||
return false;
|
||||
THROW("RocDecoder not initialized: failed with ErrCode: " + TOSTR(ROCDEC_NOT_INITIALIZED));
|
||||
}
|
||||
pic_num_in_dec_order_[pPicParams->CurrPicIdx] = decode_poc_++;
|
||||
ROCDEC_API_CALL(rocDecDecodeFrame(roc_decoder_, pPicParams));
|
||||
|
||||
@@ -64,23 +64,27 @@ typedef enum {
|
||||
class rocVideoDecodeException : public std::exception {
|
||||
public:
|
||||
|
||||
explicit rocVideoDecodeException(const std::string& message):_message(message){}
|
||||
explicit rocVideoDecodeException(const std::string& message, const int errCode):_message(message), _err_code(errCode) {}
|
||||
explicit rocVideoDecodeException(const std::string& message):_message(message), _err_code(-1) {}
|
||||
virtual const char* what() const throw() override {
|
||||
return _message.c_str();
|
||||
}
|
||||
int getErrorCode() const { return _err_code; }
|
||||
private:
|
||||
std::string _message;
|
||||
int _err_code;
|
||||
};
|
||||
|
||||
#define THROW(X) throw rocVideoDecodeException(" { "+std::string(__func__)+" } " + X);
|
||||
#define ROCDEC_THROW(X, CODE) throw rocVideoDecodeException(" { " + std::string(__func__) + " } " + X , CODE);
|
||||
#define THROW(X) throw rocVideoDecodeException(" { " + std::string(__func__) + " } " + X);
|
||||
|
||||
#define ROCDEC_API_CALL( rocDecAPI ) \
|
||||
do { \
|
||||
rocDecStatus errorCode = rocDecAPI; \
|
||||
if( errorCode != ROCDEC_SUCCESS) { \
|
||||
std::ostringstream errorLog; \
|
||||
errorLog << #rocDecAPI << " returned error " << errorCode; \
|
||||
THROW(errorLog.str() + TOSTR(errorCode)); \
|
||||
errorLog << #rocDecAPI << " returned err " << errorCode << " at " <<__FILE__ <<":" << __LINE__; \
|
||||
ROCDEC_THROW(errorLog.str(), errorCode); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
@@ -92,7 +96,7 @@ private:
|
||||
szErrName = hipGetErrorName(hip_status); \
|
||||
std::ostringstream errorLog; \
|
||||
errorLog << "hip API error " << szErrName ; \
|
||||
THROW(errorLog.str()); \
|
||||
ROCDEC_THROW(errorLog.str(), hip_status); \
|
||||
} \
|
||||
} \
|
||||
while (0)
|
||||
|
||||
새 이슈에서 참조
사용자 차단