diff options
author | Alexander Lantsev <aunsane@gmail.com> | 2015-04-18 12:16:33 +0000 |
---|---|---|
committer | Alexander Lantsev <aunsane@gmail.com> | 2015-04-18 12:16:33 +0000 |
commit | 3bc30875e34c2c16f2ee489227c0c7da7fee7f7f (patch) | |
tree | f244e90fdae81af8e74008a8de545e70fd0b062d /protocols/Tox/src | |
parent | 078629bda35180976d96e0f0a130343f8918a05a (diff) |
Tox: some fixes
git-svn-id: http://svn.miranda-ng.org/main/trunk@12908 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Tox/src')
-rw-r--r-- | protocols/Tox/src/tox_core.cpp | 4 | ||||
-rw-r--r-- | protocols/Tox/src/tox_menus.cpp | 10 | ||||
-rw-r--r-- | protocols/Tox/src/tox_multimedia.cpp | 109 | ||||
-rw-r--r-- | protocols/Tox/src/tox_proto.h | 3 |
4 files changed, 81 insertions, 45 deletions
diff --git a/protocols/Tox/src/tox_core.cpp b/protocols/Tox/src/tox_core.cpp index 36b53f8c19..400091cbed 100644 --- a/protocols/Tox/src/tox_core.cpp +++ b/protocols/Tox/src/tox_core.cpp @@ -67,8 +67,8 @@ bool CToxProto::InitToxCore() toxav_register_callstate_callback(toxAv, OnAvCancel, av_OnCancel, this);
toxav_register_callstate_callback(toxAv, OnAvReject, av_OnReject, this);
toxav_register_callstate_callback(toxAv, OnAvEnd, av_OnEnd, this);
- toxav_register_callstate_callback(toxAv, OnAvTimeout, av_OnRequestTimeout, this);
- //toxav_register_callstate_callback(toxAv, OnAvTimeout, av_OnPeerTimeout, this);
+ toxav_register_callstate_callback(toxAv, OnAvCallTimeout, av_OnRequestTimeout, this);
+ toxav_register_callstate_callback(toxAv, OnAvPeerTimeout, av_OnPeerTimeout, this);
uint8_t data[TOX_ADDRESS_SIZE];
tox_self_get_address(tox, data);
diff --git a/protocols/Tox/src/tox_menus.cpp b/protocols/Tox/src/tox_menus.cpp index 10f3316bdf..aaf06a9acc 100644 --- a/protocols/Tox/src/tox_menus.cpp +++ b/protocols/Tox/src/tox_menus.cpp @@ -61,18 +61,10 @@ void CToxProto::InitMenus() ContactMenuItems[CMI_AUTH_GRANT] = Menu_AddContactMenuItem(&mi);
CreateServiceFunction(mi.pszService, GlobalService<&CToxProto::OnGrantAuth>);
- // Grant authorization
- mi.pszService = MODULE"/GrantAuth";
- mi.ptszName = LPGENT("Grant authorization");
- mi.position = CMI_POSITION + CMI_AUTH_GRANT;
- mi.icolibItem = LoadSkinnedIconHandle(SKINICON_AUTH_GRANT);
- ContactMenuItems[CMI_AUTH_GRANT] = Menu_AddContactMenuItem(&mi);
- CreateServiceFunction(mi.pszService, GlobalService<&CToxProto::OnGrantAuth>);
-
// Start audio call
mi.pszService = MODULE"/Audio/Call";
mi.ptszName = LPGENT("Audio call");
- mi.position = CMI_POSITION + CMI_AUDIO_CALL;
+ mi.position = CMI_POSITION + CMI_AUDIO_CALL + 100000;
mi.icolibItem = GetIconHandle("audio_start");
ContactMenuItems[CMI_AUDIO_CALL] = Menu_AddContactMenuItem(&mi);
CreateServiceFunction(mi.pszService, GlobalService<&CToxProto::OnSendAudioCall>);
diff --git a/protocols/Tox/src/tox_multimedia.cpp b/protocols/Tox/src/tox_multimedia.cpp index e33ed69487..cd29eb0cde 100644 --- a/protocols/Tox/src/tox_multimedia.cpp +++ b/protocols/Tox/src/tox_multimedia.cpp @@ -53,18 +53,20 @@ ToxAvCSettings* CToxProto::GetAudioCSettings() {
ToxAvCSettings *cSettings = (ToxAvCSettings*)mir_calloc(sizeof(ToxAvCSettings));
- DWORD deviceId = getDword("AudioInputDeviceID", TOX_ERROR);
- if (deviceId == TOX_ERROR)
- {
- debugLogA(__FUNCTION__": failed to get input device id");
- mir_free(cSettings);
- return NULL;
- }
+ DWORD deviceId = getDword("AudioInputDeviceID", WAVE_MAPPER);
WAVEINCAPS wic;
- if (waveInGetDevCaps(deviceId, &wic, sizeof(WAVEINCAPS)) != MMSYSERR_NOERROR)
+ MMRESULT error = waveInGetDevCaps(deviceId, &wic, sizeof(WAVEINCAPS));
+ if (error != MMSYSERR_NOERROR)
{
- debugLogA(__FUNCTION__": failed to get input device caps");
+ debugLogA(__FUNCTION__": failed to get input device caps (%d)", error);
+
+ TCHAR errorMessage[MAX_PATH];
+ waveInGetErrorText(error, errorMessage, SIZEOF(errorMessage));
+ CToxProto::ShowNotification(
+ TranslateT("Unable to find input audio device"),
+ errorMessage);
+
mir_free(cSettings);
return NULL;
}
@@ -110,10 +112,10 @@ ToxAvCSettings* CToxProto::GetAudioCSettings() cSettings->audio_bitrate = 8 * 1000;
cSettings->audio_sample_rate = 11025;
}
- else - { - debugLogA(__FUNCTION__": failed to get input device caps"); - mir_free(cSettings); + else
+ {
+ debugLogA(__FUNCTION__": failed to get input device caps");
+ mir_free(cSettings);
return NULL;
}
@@ -165,7 +167,7 @@ void CToxProto::OnAvInvite(void*, int32_t callId, void *arg) if (friendNumber == TOX_ERROR)
{
proto->debugLogA(__FUNCTION__": failed to get friend number");
- toxav_stop_call(proto->toxAv, callId);
+ toxav_reject(proto->toxAv, callId, NULL);
return;
}
@@ -173,7 +175,7 @@ void CToxProto::OnAvInvite(void*, int32_t callId, void *arg) if (hContact == NULL)
{
proto->debugLogA(__FUNCTION__": failed to get contact");
- toxav_stop_call(proto->toxAv, callId);
+ toxav_reject(proto->toxAv, callId, NULL);
return;
}
@@ -181,7 +183,7 @@ void CToxProto::OnAvInvite(void*, int32_t callId, void *arg) if (toxav_get_peer_csettings(proto->toxAv, callId, 0, &dest) != av_ErrorNone)
{
proto->debugLogA(__FUNCTION__": failed to get codec settings");
- toxav_stop_call(proto->toxAv, callId);
+ toxav_reject(proto->toxAv, callId, NULL);
return;
}
@@ -371,7 +373,7 @@ void CToxProto::OnAvReject(void*, int32_t callId, void *arg) WindowList_Broadcast(proto->hAudioDialogs, WM_AUDIO_END, hContact, 0);
}
-void CToxProto::OnAvTimeout(void*, int32_t callId, void *arg)
+void CToxProto::OnAvCallTimeout(void*, int32_t callId, void *arg)
{
CToxProto *proto = (CToxProto*)arg;
@@ -476,6 +478,46 @@ void CToxProto::OnAvEnd(void*, int32_t callId, void *arg) db_event_add(hContact, &dbei);
WindowList_Broadcast(proto->hAudioDialogs, WM_AUDIO_END, hContact, 0);
+
+ toxav_kill_transmission(proto->toxAv, callId);
+}
+
+void CToxProto::OnAvPeerTimeout(void*, int32_t callId, void *arg)
+{
+ CToxProto *proto = (CToxProto*)arg;
+
+ int friendNumber = toxav_get_peer_id(proto->toxAv, callId, 0);
+ if (friendNumber == TOX_ERROR)
+ {
+ proto->debugLogA(__FUNCTION__": failed to get friend number");
+ toxav_stop_call(proto->toxAv, callId);
+ return;
+ }
+
+ MCONTACT hContact = proto->GetContact(friendNumber);
+ if (hContact == NULL)
+ {
+ proto->debugLogA(__FUNCTION__": failed to get contact");
+ toxav_stop_call(proto->toxAv, callId);
+ return;
+ }
+
+ CLISTEVENT *cle = (CLISTEVENT*)CallService(MS_CLIST_GETEVENT, hContact, 0);
+ if (cle)
+ CallService(MS_CLIST_REMOVEEVENT, hContact, cle->hDbEvent);
+
+ DBEVENTINFO dbei = { sizeof(dbei) };
+ dbei.szModule = proto->m_szModuleName;
+ dbei.timestamp = time(NULL);
+ dbei.flags = DBEF_UTF;
+ dbei.eventType = DB_EVENT_AUDIO_END;
+ dbei.pBlob = (PBYTE)mir_utf8encodeT(TranslateT("Audio call end"));;
+ dbei.cbBlob = (DWORD)mir_strlen((char*)dbei.pBlob) + 1;
+ db_event_add(hContact, &dbei);
+
+ WindowList_Broadcast(proto->hAudioDialogs, WM_AUDIO_END, hContact, 0);
+
+ toxav_kill_transmission(proto->toxAv, callId);
}
//////
@@ -506,19 +548,20 @@ void CToxProto::OnFriendAudio(void*, int32_t callId, const int16_t *PCM, uint16_ wfx.nBlockAlign = (wfx.nChannels * wfx.wBitsPerSample) / 8;
wfx.nAvgBytesPerSec = wfx.nSamplesPerSec * wfx.nBlockAlign;
- DWORD deviceId = proto->getDword("AudioOutputDeviceID", TOX_ERROR);
- if (deviceId == TOX_ERROR)
- {
- proto->debugLogA(__FUNCTION__": failed to get device id");
- toxav_stop_call(proto->toxAv, callId);
- return;
- }
+ DWORD deviceId = proto->getDword("AudioOutputDeviceID", WAVE_MAPPER);
HWAVEOUT hDevice;
- MMRESULT result = waveOutOpen(&hDevice, deviceId, &wfx, 0, 0, CALLBACK_NULL);
- if (result != MMSYSERR_NOERROR)
+ MMRESULT error = waveOutOpen(&hDevice, deviceId, &wfx, 0, 0, CALLBACK_NULL);
+ if (error != MMSYSERR_NOERROR)
{
- proto->debugLogA(__FUNCTION__": failed to open audio device (%d)", result);
+ proto->debugLogA(__FUNCTION__": failed to open audio device (%d)", error);
+
+ TCHAR errorMessage[MAX_PATH];
+ waveInGetErrorText(error, errorMessage, SIZEOF(errorMessage));
+ CToxProto::ShowNotification(
+ TranslateT("Unable to find output audio device"),
+ errorMessage);
+
return;
}
@@ -528,17 +571,17 @@ void CToxProto::OnFriendAudio(void*, int32_t callId, const int16_t *PCM, uint16_ waveOutSetVolume(hDevice, 0xFFFF);
- result = waveOutPrepareHeader(hDevice, &header, sizeof(WAVEHDR));
- if (result != MMSYSERR_NOERROR)
+ error = waveOutPrepareHeader(hDevice, &header, sizeof(WAVEHDR));
+ if (error != MMSYSERR_NOERROR)
{
- proto->debugLogA(__FUNCTION__": failed to prepare audio device header (%d)", result);
+ proto->debugLogA(__FUNCTION__": failed to prepare audio device header (%d)", error);
return;
}
- result = waveOutWrite(hDevice, &header, sizeof(WAVEHDR));
- if (result != MMSYSERR_NOERROR)
+ error = waveOutWrite(hDevice, &header, sizeof(WAVEHDR));
+ if (error != MMSYSERR_NOERROR)
{
- proto->debugLogA(__FUNCTION__": failed to write to audio device (%d)", result);
+ proto->debugLogA(__FUNCTION__": failed to write to audio device (%d)", error);
return;
}
diff --git a/protocols/Tox/src/tox_proto.h b/protocols/Tox/src/tox_proto.h index 5919b97f84..6f11e44c0b 100644 --- a/protocols/Tox/src/tox_proto.h +++ b/protocols/Tox/src/tox_proto.h @@ -258,7 +258,8 @@ private: static void OnAvEnd(void*, int32_t callId, void *arg);
static void OnAvReject(void*, int32_t callId, void *arg);
static void OnAvCancel(void*, int32_t callId, void *arg);
- static void OnAvTimeout(void*, int32_t callId, void *arg);
+ static void OnAvCallTimeout(void*, int32_t callId, void *arg);
+ static void OnAvPeerTimeout(void*, int32_t callId, void *arg);
// utils
TOX_USER_STATUS MirandaToToxStatus(int status);
|