Browse Source

Handle toxcore failures in Core::onAvMediaChange

No, I'm not above using goto for centralized error handling.
pull/553/head
Tux3 / Mlkj / !Lev.uXFMLA 11 years ago
parent
commit
9fd8a6124e
No known key found for this signature in database
GPG Key ID: 7E086DD661263264
  1. 15
      src/coreav.cpp

15
src/coreav.cpp

@ -72,10 +72,14 @@ void Core::prepareCall(int friendId, int callId, ToxAv* toxav, bool videoEnabled @@ -72,10 +72,14 @@ void Core::prepareCall(int friendId, int callId, ToxAv* toxav, bool videoEnabled
void Core::onAvMediaChange(void* toxav, int32_t callId, void* core)
{
ToxAvCSettings settings;
toxav_get_peer_csettings((ToxAv*)toxav, callId, 0, &settings);
int friendId = toxav_get_peer_id((ToxAv*)toxav, callId, 0);
int friendId;
if (toxav_get_peer_csettings((ToxAv*)toxav, callId, 0, &settings) < 0)
goto fail;
friendId = toxav_get_peer_id((ToxAv*)toxav, callId, 0);
if (friendId < 0)
goto fail;
qWarning() << "Core: Received media change from friend "<<friendId;
qDebug() << "Core: Received media change from friend "<<friendId;
if (settings.call_type == TypeAudio)
{
@ -91,6 +95,11 @@ void Core::onAvMediaChange(void* toxav, int32_t callId, void* core) @@ -91,6 +95,11 @@ void Core::onAvMediaChange(void* toxav, int32_t callId, void* core)
calls[callId].sendVideoTimer->start();
emit ((Core*)core)->avMediaChange(friendId, callId, true);
}
return;
fail: // Centralized error handling
qWarning() << "Core: Toxcore error while receiving media change on call "<<callId;
return;
}
void Core::answerCall(int callId)

Loading…
Cancel
Save