Browse Source

feat(core): Add error parsing for Toxav_Err_Call

reviewable/pr6578/r8
Anthony Bilinski 3 years ago
parent
commit
47a05c7592
No known key found for this signature in database
GPG Key ID: 2AA8E0DA1B31FB3C
  1. 7
      src/core/coreav.cpp
  2. 1
      util/include/util/toxcoreerrorparser.h
  3. 34
      util/src/toxcoreerrorparser.cpp

7
src/core/coreav.cpp

@ -292,9 +292,12 @@ bool CoreAV::startCall(uint32_t friendNum, bool video) @@ -292,9 +292,12 @@ bool CoreAV::startCall(uint32_t friendNum, bool video)
}
uint32_t videoBitrate = video ? VIDEO_DEFAULT_BITRATE : 0;
if (!toxav_call(toxav.get(), friendNum, audioSettings.getAudioBitrate(), videoBitrate,
nullptr))
Toxav_Err_Call err;
toxav_call(toxav.get(), friendNum, audioSettings.getAudioBitrate(), videoBitrate,
&err);
if (!PARSE_ERR(err)) {
return false;
}
// Audio backend must be set before making a call
assert(audio != nullptr);

1
util/include/util/toxcoreerrorparser.h

@ -56,4 +56,5 @@ namespace ToxcoreErrorParser { @@ -56,4 +56,5 @@ namespace ToxcoreErrorParser {
bool parseErr(Tox_Err_File_Send error, int line);
bool parseErr(Tox_Err_File_Send_Chunk error, int line);
bool parseErr(Toxav_Err_Call_Control error, int line);
bool parseErr(Toxav_Err_Call error, int line);
} // namespace ToxcoreErrorParser

34
util/src/toxcoreerrorparser.cpp

@ -569,3 +569,37 @@ bool ToxcoreErrorParser::parseErr(Toxav_Err_Call_Control error, int line) @@ -569,3 +569,37 @@ bool ToxcoreErrorParser::parseErr(Toxav_Err_Call_Control error, int line)
qCritical() << line << "Unknown Toxav_Err_Call_Control error code:" << error;
return false;
}
bool ToxcoreErrorParser::parseErr(Toxav_Err_Call error, int line)
{
switch (error) {
case TOXAV_ERR_CALL_OK:
return true;
case TOXAV_ERR_CALL_MALLOC:
qCritical() << line << ": A resource allocation error occurred.";
return false;
case TOXAV_ERR_CALL_SYNC:
qCritical() << line << ": Synchronization error occurred.";
return false;
case TOXAV_ERR_CALL_FRIEND_NOT_FOUND:
qCritical() << line << ": The friend number did not designate a valid friend.";
return false;
case TOXAV_ERR_CALL_FRIEND_NOT_CONNECTED:
qCritical() << line << ": The friend was valid, but not currently connected.";
return false;
case TOXAV_ERR_CALL_FRIEND_ALREADY_IN_CALL:
qCritical() << line << ": Attempted to call a friend while already in a call with them.";
return false;
case TOXAV_ERR_CALL_INVALID_BIT_RATE:
qCritical() << line << ": Audio or video bit rate is invalid.";
return false;
}
qCritical() << line << "Unknown Toxav_Err_Call error code:" << error;
return false;
}

Loading…
Cancel
Save