Add beep sound to platforms with no beep

This commit is contained in:
elasota
2021-05-09 23:45:27 -04:00
parent d54ad576bc
commit 24169507bd
21 changed files with 85 additions and 25 deletions

View File

@@ -13,6 +13,7 @@
#include "WindowDef.h"
#include "WindowManager.h"
#include "PLApplication.h"
#include "PLArrayView.h"
#include "PLBigEndian.h"
#include "PLButtonWidget.h"
@@ -471,7 +472,7 @@ namespace PortabilityLayer
Rect2i windowFullRect = WindowManager::GetInstance()->GetWindowFullRect(window);
if (!windowFullRect.Contains(Vec2i(mouseEvent.m_x, mouseEvent.m_y)))
{
PLDrivers::GetSystemServices()->Beep();
SysBeep(1);
continue;
}
}
@@ -834,7 +835,7 @@ namespace PortabilityLayer
// If sound index is 0, play no sound
if (soundIndexes[0] != 0)
PLDrivers::GetSystemServices()->Beep();
SysBeep(1);
const Rect dialogRect = alertResData.m_rect.ToRect();

View File

@@ -21,6 +21,7 @@
#include "WindowDef.h"
#include "MacRomanConversion.h"
#include "PLApplication.h"
#include "PLArrayView.h"
#include "PLControlDefinitions.h"
#include "PLCore.h"
@@ -756,7 +757,7 @@ namespace PortabilityLayer
PLPasStr nameStr = editBox->GetString();
if (nameStr.Length() == 0 || !fs->ValidateFilePath(nameStr.Chars(), nameStr.Length()))
{
PLDrivers::GetSystemServices()->Beep();
SysBeep(1);
FileBrowserUIImpl::PopUpAlert(Rect::Create(0, 0, 135, 327), kFileBrowserUIBadNameDialogTemplateID, nullptr);
hit = -1;
}
@@ -772,7 +773,7 @@ namespace PortabilityLayer
{
DialogTextSubstitutions substitutions(nameStr);
PLDrivers::GetSystemServices()->Beep();
SysBeep(1);
int16_t subHit = FileBrowserUIImpl::PopUpAlert(Rect::Create(0, 0, 135, 327), kFileBrowserUIOverwriteDialogTemplateID, &substitutions);
if (subHit == kOverwriteNoButton)
@@ -783,7 +784,7 @@ namespace PortabilityLayer
if ((mode == Mode_Open && hit == kOpenDeleteButton) || (mode == Mode_SaveWithDelete && hit == kSaveDeleteButton))
{
PLDrivers::GetSystemServices()->Beep();
SysBeep(1);
int16_t subHit = FileBrowserUIImpl::PopUpAlert(Rect::Create(0, 0, 135, 327), kFileBrowserUIDeleteDialogTemplateID, &substitutions);
if (subHit == kOverwriteYesButton)

View File

@@ -18,9 +18,18 @@ namespace PortabilityLayer
memcpy(dest + 1, src, sz);
}
}
static BeepFunction_t gs_beepFunction = nullptr;
}
void SysBeep(int duration)
{
PLDrivers::GetSystemServices()->Beep();
if (!PLDrivers::GetSystemServices()->Beep())
if (PortabilityLayer::gs_beepFunction != nullptr)
PortabilityLayer::gs_beepFunction(duration);
}
void SetBeepFunction(BeepFunction_t beepFunction)
{
PortabilityLayer::gs_beepFunction = beepFunction;
}

View File

@@ -23,7 +23,11 @@ void PasStringCopy(const unsigned char *src, unsigned char *dest);
template<size_t TSize>
void PasStringCopy(const PortabilityLayer::PascalStrLiteral<TSize> &src, unsigned char *dest);
void SysBeep(int duration);
void SysBeep(int duration);
typedef void (*BeepFunction_t)(int duration);
void SetBeepFunction(BeepFunction_t beepFunction);
///////////////////////////////////////////////////////////////////////////////
#include "PascalStrLiteral.h"

View File

@@ -180,6 +180,9 @@ namespace PortabilityLayer
bool AudioChannelImpl::AddBuffer(IGpAudioBuffer *buffer, bool blocking)
{
if (!buffer)
return false;
buffer->AddRef();
AudioCommand cmd;