From a929d4c862a60c9abc1b6e9fe507831326f232dc Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sat, 10 Sep 2022 07:11:37 -0700 Subject: =?UTF-8?q?fixes=20#3192=20(VoiceService:=20=D0=B7=D0=B2=D1=83?= =?UTF-8?q?=D0=BA=20=D0=B7=D0=B2=D0=BE=D0=BD=D0=BA=D0=B0=20=D0=B2=D0=BE?= =?UTF-8?q?=D1=81=D0=BF=D1=80=D0=BE=D0=B8=D0=B7=D0=B2=D0=BE=D0=B4=D0=B8?= =?UTF-8?q?=D1=82=D1=81=D1=8F=20=D0=BB=D0=B8=D1=88=D1=8C=20=D0=BE=D0=B4?= =?UTF-8?q?=D0=B8=D0=BD=20=D1=80=D0=B0=D0=B7)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- include/m_skin.h | 7 +++++-- libs/win32/mir_app.lib | Bin 225752 -> 225752 bytes plugins/VoiceService/src/VoiceCall.cpp | 13 ++++++++++--- plugins/VoiceService/src/stdafx.h | 2 +- src/mir_app/src/sounds.cpp | 27 ++++++++++++++++----------- 5 files changed, 32 insertions(+), 17 deletions(-) diff --git a/include/m_skin.h b/include/m_skin.h index 7727910f3a..fa3fd5051a 100644 --- a/include/m_skin.h +++ b/include/m_skin.h @@ -124,13 +124,16 @@ EXTERN_C MIR_APP_DLL(HANDLE) Skin_GetProtoIcon(const char *szProto, int status); // plays a registered sound // returns 0 on success, nonzero otherwise -EXTERN_C MIR_APP_DLL(int) Skin_PlaySound(const char *name); +#define SPS_FORCEPLAY 0x0001 // play sound even if Options - Sounds - Enabled is unset +#define SPS_LOOP 0x0002 // loop sound until Skin_PlaySoundFile(NULL) is called + +EXTERN_C MIR_APP_DLL(int) Skin_PlaySound(const char *name, int spsFlags = 0); ///////////////////////////////////////////////////////////////////////////////////////// // plays the sound file (non-registered) // returns 0 on success, nonzero otherwise -EXTERN_C MIR_APP_DLL(int) Skin_PlaySoundFile(const wchar_t *pwszFileName); +EXTERN_C MIR_APP_DLL(int) Skin_PlaySoundFile(const wchar_t *pwszFileName, int spsFlags = 0); ///////////////////////////////////////////////////////////////////////////////////////// // wParam: 0 when playing sound (1 when sound is being previewed) diff --git a/libs/win32/mir_app.lib b/libs/win32/mir_app.lib index 72427341a7..c533d3c89d 100644 Binary files a/libs/win32/mir_app.lib and b/libs/win32/mir_app.lib differ diff --git a/plugins/VoiceService/src/VoiceCall.cpp b/plugins/VoiceService/src/VoiceCall.cpp index 40ea12aedf..8198ee8c61 100644 --- a/plugins/VoiceService/src/VoiceCall.cpp +++ b/plugins/VoiceService/src/VoiceCall.cpp @@ -196,6 +196,11 @@ void VoiceCall::RemoveNotifications() g_clistApi.pfnRemoveEvent(hContact, MEVENT(1001)); clistBlinking = false; } + + if (soundActive) { + Skin_PlaySoundFile(nullptr); + soundActive = false; + } } void VoiceCall::SetState(int aState) @@ -259,10 +264,12 @@ void VoiceCall::SetStatus(const wchar_t *text) void VoiceCall::Notify(bool popup, bool sound, bool clist) { - if (sound) - Skin_PlaySound(g_sounds[state].szName); + if (sound) { + soundActive = true; + Skin_PlaySound(g_sounds[state].szName, SPS_LOOP); + } - if(IsWindowVisible(GetHwnd())) + if (IsWindowVisible(GetHwnd())) return; if (popup) diff --git a/plugins/VoiceService/src/stdafx.h b/plugins/VoiceService/src/stdafx.h index 4233afc08c..1c99427162 100644 --- a/plugins/VoiceService/src/stdafx.h +++ b/plugins/VoiceService/src/stdafx.h @@ -125,7 +125,7 @@ public: wchar_t number[256]; wchar_t displayName[256]; int state = -1; - bool incoming = false, secure = false, clistBlinking = false; + bool incoming = false, secure = false, clistBlinking = false, soundActive = false; VoiceCall(VoiceProvider *module, const char *id); ~VoiceCall(); diff --git a/src/mir_app/src/sounds.cpp b/src/mir_app/src/sounds.cpp index 54b8b00ca6..2a38d9b164 100644 --- a/src/mir_app/src/sounds.cpp +++ b/src/mir_app/src/sounds.cpp @@ -408,24 +408,29 @@ int CMPluginBase::addSound(const char *pszName, const wchar_t *pwszSection, cons static int Skin_PlaySoundDefault(WPARAM wParam, LPARAM lParam) { wchar_t *pszFile = (wchar_t*)lParam; - if (pszFile && (db_get_b(0, "Skin", "UseSound", 0) || (int)wParam == 1)) - PlaySound(pszFile, nullptr, SND_ASYNC | SND_FILENAME | SND_NOSTOP); + if (db_get_b(0, "Skin", "UseSound", 0) || (wParam & SPS_FORCEPLAY) != 0) { + int flags = SND_ASYNC | SND_FILENAME | SND_NOSTOP; + if (wParam & SPS_LOOP) + flags |= SND_LOOP; + PlaySoundW(pszFile, nullptr, flags); + } return 0; } -MIR_APP_DLL(int) Skin_PlaySoundFile(const wchar_t *pwszFileName) +MIR_APP_DLL(int) Skin_PlaySoundFile(const wchar_t *pwszFileName, int flags) { - if (pwszFileName == nullptr) - return 1; - - wchar_t tszFull[MAX_PATH]; - PathToAbsoluteW(pwszFileName, tszFull); - NotifyEventHooks(hPlayEvent, 0, (LPARAM)tszFull); + if (pwszFileName) { + wchar_t tszFull[MAX_PATH]; + PathToAbsoluteW(pwszFileName, tszFull); + NotifyEventHooks(hPlayEvent, flags, (LPARAM)tszFull); + } + else NotifyEventHooks(hPlayEvent, flags, 0); + return 0; } -MIR_APP_DLL(int) Skin_PlaySound(const char *pszSoundName) +MIR_APP_DLL(int) Skin_PlaySound(const char *pszSoundName, int flags) { if (pszSoundName == nullptr) return 1; @@ -441,7 +446,7 @@ MIR_APP_DLL(int) Skin_PlaySound(const char *pszSoundName) if (wszFilePath == nullptr) return 1; - Skin_PlaySoundFile(wszFilePath); + Skin_PlaySoundFile(wszFilePath, flags); return 0; } -- cgit v1.2.3