summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2022-09-10 07:11:37 -0700
committerGeorge Hazan <ghazan@miranda.im>2022-09-10 07:11:37 -0700
commita929d4c862a60c9abc1b6e9fe507831326f232dc (patch)
treeebdfd47a4781e11e1501c6ff8a0e62000feda4a0
parentf0585b3e81a1a0a9cfde43313cadf0ee72daad27 (diff)
fixes #3192 (VoiceService: звук звонка воспроизводится лишь один раз)
-rw-r--r--include/m_skin.h7
-rw-r--r--libs/win32/mir_app.libbin225752 -> 225752 bytes
-rw-r--r--plugins/VoiceService/src/VoiceCall.cpp13
-rw-r--r--plugins/VoiceService/src/stdafx.h2
-rw-r--r--src/mir_app/src/sounds.cpp27
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
--- a/libs/win32/mir_app.lib
+++ b/libs/win32/mir_app.lib
Binary files 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;
}