mirror of
https://github.com/stenzek/duckstation.git
synced 2026-02-04 05:04:33 +00:00
PlatformMisc: Remove PlaySoundAsync()
No longer needed.
This commit is contained in:
@@ -14,10 +14,6 @@ bool InitializeSocketSupport(Error* error);
|
||||
void SuspendScreensaver();
|
||||
void ResumeScreensaver();
|
||||
|
||||
/// Abstracts platform-specific code for asynchronously playing a sound.
|
||||
/// On Windows, this will use PlaySound(). On Linux, it will shell out to aplay. On MacOS, it uses NSSound.
|
||||
bool PlaySoundAsync(const char* path);
|
||||
|
||||
/// Sets the rounded corner state for a window.
|
||||
/// Currently only supported on Windows.
|
||||
bool SetWindowRoundedCornerState(void* window_handle, bool enabled, Error* error = nullptr);
|
||||
|
||||
@@ -78,16 +78,6 @@ void PlatformMisc::ResumeScreensaver()
|
||||
s_screensaver_suspended = false;
|
||||
}
|
||||
|
||||
bool PlatformMisc::PlaySoundAsync(const char* path)
|
||||
{
|
||||
NSString* nspath = [[NSString alloc] initWithUTF8String:path];
|
||||
NSSound* sound = [[NSSound alloc] initWithContentsOfFile:nspath byReference:YES];
|
||||
const bool result = [sound play];
|
||||
[sound release];
|
||||
[nspath release];
|
||||
return result;
|
||||
}
|
||||
|
||||
bool PlatformMisc::SetWindowRoundedCornerState(void* window_handle, bool enabled, Error* error /* = nullptr */)
|
||||
{
|
||||
Error::SetStringView(error, "Unsupported on this platform.");
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
#include <dbus/dbus.h>
|
||||
#include <mutex>
|
||||
#include <signal.h>
|
||||
#include <spawn.h>
|
||||
#include <unistd.h>
|
||||
|
||||
LOG_CHANNEL(PlatformMisc);
|
||||
@@ -197,44 +196,6 @@ void PlatformMisc::ResumeScreensaver()
|
||||
s_screensaver_suspended = false;
|
||||
}
|
||||
|
||||
bool PlatformMisc::PlaySoundAsync(const char* path)
|
||||
{
|
||||
#ifdef __linux__
|
||||
// This is... pretty awful. But I can't think of a better way without linking to e.g. gstreamer.
|
||||
const char* cmdname = "aplay";
|
||||
const char* argv[] = {cmdname, path, nullptr};
|
||||
pid_t pid;
|
||||
|
||||
// Since we set SA_NOCLDWAIT in Qt, we don't need to wait here.
|
||||
int res = posix_spawnp(&pid, cmdname, nullptr, nullptr, const_cast<char**>(argv), environ);
|
||||
if (res == 0)
|
||||
return true;
|
||||
|
||||
// Try gst-play-1.0.
|
||||
const char* gst_play_cmdname = "gst-play-1.0";
|
||||
const char* gst_play_argv[] = {cmdname, path, nullptr};
|
||||
res = posix_spawnp(&pid, gst_play_cmdname, nullptr, nullptr, const_cast<char**>(gst_play_argv), environ);
|
||||
if (res == 0)
|
||||
return true;
|
||||
|
||||
// gst-launch? Bit messier for sure.
|
||||
TinyString location_str = TinyString::from_format("location={}", path);
|
||||
TinyString parse_str = TinyString::from_format("{}parse", Path::GetExtension(path));
|
||||
const char* gst_launch_cmdname = "gst-launch-1.0";
|
||||
const char* gst_launch_argv[] = {gst_launch_cmdname, "filesrc", location_str.c_str(), "!",
|
||||
parse_str.c_str(), "!", "alsasink", nullptr};
|
||||
res = posix_spawnp(&pid, gst_launch_cmdname, nullptr, nullptr, const_cast<char**>(gst_launch_argv), environ);
|
||||
if (res == 0)
|
||||
return true;
|
||||
|
||||
ERROR_LOG("Failed to play sound effect {}. Make sure you have aplay, gst-play-1.0, or gst-launch-1.0 available.",
|
||||
path);
|
||||
return false;
|
||||
#else
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool PlatformMisc::SetWindowRoundedCornerState(void* window_handle, bool enabled, Error* error /* = nullptr */)
|
||||
{
|
||||
Error::SetStringView(error, "Unsupported on this platform.");
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
#include <Psapi.h>
|
||||
#include <WinSock2.h>
|
||||
#include <dwmapi.h>
|
||||
#include <mmsystem.h>
|
||||
|
||||
LOG_CHANNEL(PlatformMisc);
|
||||
|
||||
@@ -82,12 +81,6 @@ void PlatformMisc::ResumeScreensaver()
|
||||
s_screensaver_suspended = false;
|
||||
}
|
||||
|
||||
bool PlatformMisc::PlaySoundAsync(const char* path)
|
||||
{
|
||||
const std::wstring wpath(FileSystem::GetWin32Path(path));
|
||||
return PlaySoundW(wpath.c_str(), NULL, SND_ASYNC | SND_NODEFAULT);
|
||||
}
|
||||
|
||||
bool PlatformMisc::SetWindowRoundedCornerState(void* window_handle, bool enabled, Error* error)
|
||||
{
|
||||
const DWM_WINDOW_CORNER_PREFERENCE value = enabled ? DWMWCP_DEFAULT : DWMWCP_DONOTROUND;
|
||||
|
||||
Reference in New Issue
Block a user