summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gles3/rasterizer_scene_gles3.cpp2
-rw-r--r--drivers/unix/file_access_unix.cpp5
-rw-r--r--drivers/unix/file_access_unix.h1
-rw-r--r--drivers/unix/stream_peer_tcp_posix.cpp2
-rw-r--r--drivers/unix/stream_peer_tcp_posix.h2
-rw-r--r--drivers/wasapi/audio_driver_wasapi.cpp88
-rw-r--r--drivers/windows/file_access_windows.cpp8
-rw-r--r--drivers/windows/file_access_windows.h1
-rw-r--r--drivers/windows/stream_peer_tcp_winsock.cpp2
-rw-r--r--drivers/windows/stream_peer_tcp_winsock.h2
10 files changed, 106 insertions, 7 deletions
diff --git a/drivers/gles3/rasterizer_scene_gles3.cpp b/drivers/gles3/rasterizer_scene_gles3.cpp
index da6df7198d..d1892eb1e8 100644
--- a/drivers/gles3/rasterizer_scene_gles3.cpp
+++ b/drivers/gles3/rasterizer_scene_gles3.cpp
@@ -4916,7 +4916,6 @@ void RasterizerSceneGLES3::initialize() {
const int ubo_light_size = 160;
state.ubo_light_size = ubo_light_size;
state.max_ubo_lights = MIN(RenderList::MAX_LIGHTS, max_ubo_size / ubo_light_size);
- print_line("GLES3: max ubo light: " + itos(state.max_ubo_lights));
state.spot_array_tmp = (uint8_t *)memalloc(ubo_light_size * state.max_ubo_lights);
state.omni_array_tmp = (uint8_t *)memalloc(ubo_light_size * state.max_ubo_lights);
@@ -4942,7 +4941,6 @@ void RasterizerSceneGLES3::initialize() {
state.scene_shader.add_custom_define("#define MAX_FORWARD_LIGHTS " + itos(state.max_forward_lights_per_object) + "\n");
state.max_ubo_reflections = MIN(RenderList::MAX_REFLECTIONS, max_ubo_size / sizeof(ReflectionProbeDataUBO));
- print_line("GLES3: max ubo reflections: " + itos(state.max_ubo_reflections) + ", ubo size: " + itos(sizeof(ReflectionProbeDataUBO)));
state.reflection_array_tmp = (uint8_t *)memalloc(sizeof(ReflectionProbeDataUBO) * state.max_ubo_reflections);
diff --git a/drivers/unix/file_access_unix.cpp b/drivers/unix/file_access_unix.cpp
index 1ed3999e1e..5b093a5885 100644
--- a/drivers/unix/file_access_unix.cpp
+++ b/drivers/unix/file_access_unix.cpp
@@ -236,6 +236,11 @@ void FileAccessUnix::store_8(uint8_t p_dest) {
ERR_FAIL_COND(fwrite(&p_dest, 1, 1, f) != 1);
}
+void FileAccessUnix::store_buffer(const uint8_t *p_src, int p_length) {
+ ERR_FAIL_COND(!f);
+ ERR_FAIL_COND(fwrite(p_src, 1, p_length, f) != p_length);
+}
+
bool FileAccessUnix::file_exists(const String &p_path) {
int err;
diff --git a/drivers/unix/file_access_unix.h b/drivers/unix/file_access_unix.h
index 6f792076b8..dbb1c9f3b5 100644
--- a/drivers/unix/file_access_unix.h
+++ b/drivers/unix/file_access_unix.h
@@ -75,6 +75,7 @@ public:
virtual void flush();
virtual void store_8(uint8_t p_dest); ///< store a byte
+ virtual void store_buffer(const uint8_t *p_src, int p_length); ///< store an array of bytes
virtual bool file_exists(const String &p_path); ///< return true if a file exists
diff --git a/drivers/unix/stream_peer_tcp_posix.cpp b/drivers/unix/stream_peer_tcp_posix.cpp
index ba9481d36b..17112e5ab5 100644
--- a/drivers/unix/stream_peer_tcp_posix.cpp
+++ b/drivers/unix/stream_peer_tcp_posix.cpp
@@ -304,7 +304,7 @@ Error StreamPeerTCPPosix::read(uint8_t *p_buffer, int p_bytes, int &r_received,
return OK;
};
-void StreamPeerTCPPosix::set_nodelay(bool p_enabled) {
+void StreamPeerTCPPosix::set_no_delay(bool p_enabled) {
ERR_FAIL_COND(!is_connected_to_host());
int flag = p_enabled ? 1 : 0;
diff --git a/drivers/unix/stream_peer_tcp_posix.h b/drivers/unix/stream_peer_tcp_posix.h
index 5770ae48f4..bcebe57771 100644
--- a/drivers/unix/stream_peer_tcp_posix.h
+++ b/drivers/unix/stream_peer_tcp_posix.h
@@ -77,7 +77,7 @@ public:
virtual Status get_status() const;
virtual void disconnect_from_host();
- virtual void set_nodelay(bool p_enabled);
+ virtual void set_no_delay(bool p_enabled);
static void make_default();
diff --git a/drivers/wasapi/audio_driver_wasapi.cpp b/drivers/wasapi/audio_driver_wasapi.cpp
index 4c80e70a95..36acfb10d1 100644
--- a/drivers/wasapi/audio_driver_wasapi.cpp
+++ b/drivers/wasapi/audio_driver_wasapi.cpp
@@ -40,6 +40,76 @@ const IID IID_IMMDeviceEnumerator = __uuidof(IMMDeviceEnumerator);
const IID IID_IAudioClient = __uuidof(IAudioClient);
const IID IID_IAudioRenderClient = __uuidof(IAudioRenderClient);
+static bool default_device_changed = false;
+
+class CMMNotificationClient : public IMMNotificationClient {
+ LONG _cRef;
+ IMMDeviceEnumerator *_pEnumerator;
+
+public:
+ CMMNotificationClient() :
+ _cRef(1),
+ _pEnumerator(NULL) {}
+ ~CMMNotificationClient() {
+ if ((_pEnumerator) != NULL) {
+ (_pEnumerator)->Release();
+ (_pEnumerator) = NULL;
+ }
+ }
+
+ ULONG STDMETHODCALLTYPE AddRef() {
+ return InterlockedIncrement(&_cRef);
+ }
+
+ ULONG STDMETHODCALLTYPE Release() {
+ ULONG ulRef = InterlockedDecrement(&_cRef);
+ if (0 == ulRef) {
+ delete this;
+ }
+ return ulRef;
+ }
+
+ HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, VOID **ppvInterface) {
+ if (IID_IUnknown == riid) {
+ AddRef();
+ *ppvInterface = (IUnknown *)this;
+ } else if (__uuidof(IMMNotificationClient) == riid) {
+ AddRef();
+ *ppvInterface = (IMMNotificationClient *)this;
+ } else {
+ *ppvInterface = NULL;
+ return E_NOINTERFACE;
+ }
+ return S_OK;
+ }
+
+ HRESULT STDMETHODCALLTYPE OnDeviceAdded(LPCWSTR pwstrDeviceId) {
+ return S_OK;
+ };
+
+ HRESULT STDMETHODCALLTYPE OnDeviceRemoved(LPCWSTR pwstrDeviceId) {
+ return S_OK;
+ }
+
+ HRESULT STDMETHODCALLTYPE OnDeviceStateChanged(LPCWSTR pwstrDeviceId, DWORD dwNewState) {
+ return S_OK;
+ }
+
+ HRESULT STDMETHODCALLTYPE OnDefaultDeviceChanged(EDataFlow flow, ERole role, LPCWSTR pwstrDeviceId) {
+ if (flow == eRender && role == eConsole) {
+ default_device_changed = true;
+ }
+
+ return S_OK;
+ }
+
+ HRESULT STDMETHODCALLTYPE OnPropertyValueChanged(LPCWSTR pwstrDeviceId, const PROPERTYKEY key) {
+ return S_OK;
+ }
+};
+
+static CMMNotificationClient notif_client;
+
Error AudioDriverWASAPI::init_device(bool reinit) {
WAVEFORMATEX *pwfex;
@@ -54,7 +124,7 @@ Error AudioDriverWASAPI::init_device(bool reinit) {
hr = enumerator->GetDefaultAudioEndpoint(eRender, eConsole, &device);
if (reinit) {
// In case we're trying to re-initialize the device prevent throwing this error on the console,
- // otherwise if there is currently no devie available this will spam the console.
+ // otherwise if there is currently no device available this will spam the console.
if (hr != S_OK) {
return ERR_CANT_OPEN;
}
@@ -62,6 +132,11 @@ Error AudioDriverWASAPI::init_device(bool reinit) {
ERR_FAIL_COND_V(hr != S_OK, ERR_CANT_OPEN);
}
+ hr = enumerator->RegisterEndpointNotificationCallback(&notif_client);
+ if (hr != S_OK) {
+ ERR_PRINT("WASAPI: RegisterEndpointNotificationCallback error");
+ }
+
hr = device->Activate(IID_IAudioClient, CLSCTX_ALL, NULL, (void **)&audio_client);
if (reinit) {
if (hr != S_OK) {
@@ -148,6 +223,8 @@ Error AudioDriverWASAPI::finish_device() {
if (audio_client) {
if (active) {
audio_client->Stop();
+ audio_client->Release();
+ audio_client = NULL;
active = false;
}
}
@@ -323,6 +400,15 @@ void AudioDriverWASAPI::thread_func(void *p_udata) {
}
}
+ if (default_device_changed) {
+ Error err = ad->finish_device();
+ if (err != OK) {
+ ERR_PRINT("WASAPI: finish_device error");
+ }
+
+ default_device_changed = false;
+ }
+
if (!ad->audio_client) {
Error err = ad->init_device(true);
if (err == OK) {
diff --git a/drivers/windows/file_access_windows.cpp b/drivers/windows/file_access_windows.cpp
index 832d75b17d..072790876f 100644
--- a/drivers/windows/file_access_windows.cpp
+++ b/drivers/windows/file_access_windows.cpp
@@ -148,6 +148,9 @@ void FileAccessWindows::close() {
}
save_path = "";
+ if (rename_error) {
+ ERR_EXPLAIN("Safe save failed. This may be a permissions problem, but also may happen because you are running a paranoid antivirus. If this is the case, please switch to Windows Defender or disable the 'safe save' option in editor settings. This makes it work, but increases the risk of file corruption in a crash.");
+ }
ERR_FAIL_COND(rename_error);
}
}
@@ -232,6 +235,11 @@ void FileAccessWindows::store_8(uint8_t p_dest) {
fwrite(&p_dest, 1, 1, f);
}
+void FileAccessWindows::store_buffer(const uint8_t *p_src, int p_length) {
+ ERR_FAIL_COND(!f);
+ ERR_FAIL_COND(fwrite(p_src, 1, p_length, f) != p_length);
+}
+
bool FileAccessWindows::file_exists(const String &p_name) {
FILE *g;
diff --git a/drivers/windows/file_access_windows.h b/drivers/windows/file_access_windows.h
index bbdf830c96..26bd08b7af 100644
--- a/drivers/windows/file_access_windows.h
+++ b/drivers/windows/file_access_windows.h
@@ -67,6 +67,7 @@ public:
virtual void flush();
virtual void store_8(uint8_t p_dest); ///< store a byte
+ virtual void store_buffer(const uint8_t *p_src, int p_length); ///< store an array of bytes
virtual bool file_exists(const String &p_name); ///< return true if a file exists
diff --git a/drivers/windows/stream_peer_tcp_winsock.cpp b/drivers/windows/stream_peer_tcp_winsock.cpp
index d6a320fb5e..55775fc231 100644
--- a/drivers/windows/stream_peer_tcp_winsock.cpp
+++ b/drivers/windows/stream_peer_tcp_winsock.cpp
@@ -332,7 +332,7 @@ Error StreamPeerTCPWinsock::connect_to_host(const IP_Address &p_host, uint16_t p
return OK;
};
-void StreamPeerTCPWinsock::set_nodelay(bool p_enabled) {
+void StreamPeerTCPWinsock::set_no_delay(bool p_enabled) {
ERR_FAIL_COND(!is_connected_to_host());
int flag = p_enabled ? 1 : 0;
setsockopt(sockfd, IPPROTO_TCP, TCP_NODELAY, (char *)&flag, sizeof(int));
diff --git a/drivers/windows/stream_peer_tcp_winsock.h b/drivers/windows/stream_peer_tcp_winsock.h
index 9be8414878..a0177d374e 100644
--- a/drivers/windows/stream_peer_tcp_winsock.h
+++ b/drivers/windows/stream_peer_tcp_winsock.h
@@ -81,7 +81,7 @@ public:
static void make_default();
static void cleanup();
- virtual void set_nodelay(bool p_enabled);
+ virtual void set_no_delay(bool p_enabled);
StreamPeerTCPWinsock();
~StreamPeerTCPWinsock();