diff --git a/src/eventhandler/EventHandler.cpp b/src/eventhandler/EventHandler.cpp index e1e32824..9145f0b0 100644 --- a/src/eventhandler/EventHandler.cpp +++ b/src/eventhandler/EventHandler.cpp @@ -2,14 +2,6 @@ #include "../plugin-macros.generated.h" -std::string GetCalldataString(const calldata_t *data, const char* name) -{ - const char* value = calldata_string(data, name); - if (!value) - return ""; - return value; -} - EventHandler::EventHandler(WebSocketServerPtr webSocketServer) : _webSocketServer(webSocketServer), _obsLoaded(false) @@ -380,8 +372,8 @@ void EventHandler::SourceRenamedMultiHandler(void *param, calldata_t *data) if (!source) return; - std::string oldSourceName = GetCalldataString(data, "prev_name"); - std::string sourceName = GetCalldataString(data, "new_name"); + std::string oldSourceName = calldata_string(data, "prev_name"); + std::string sourceName = calldata_string(data, "new_name"); if (oldSourceName.empty() || sourceName.empty()) return; diff --git a/src/eventhandler/EventHandler.h b/src/eventhandler/EventHandler.h index 645963d0..8f6cc203 100644 --- a/src/eventhandler/EventHandler.h +++ b/src/eventhandler/EventHandler.h @@ -27,13 +27,11 @@ enum ObsMediaInputAction { }; template T* GetCalldataPointer(const calldata_t *data, const char* name) { - void* ptr = nullptr; + void *ptr = nullptr; calldata_get_ptr(data, name, &ptr); return reinterpret_cast(ptr); } -std::string GetCalldataString(const calldata_t *data, const char* name); - class EventHandler { public: diff --git a/src/eventhandler/EventHandler_Inputs.cpp b/src/eventhandler/EventHandler_Inputs.cpp index 9d6e8238..0b6884b7 100644 --- a/src/eventhandler/EventHandler_Inputs.cpp +++ b/src/eventhandler/EventHandler_Inputs.cpp @@ -94,9 +94,7 @@ void EventHandler::HandleInputVolumeChanged(void *param, calldata_t *data) return; // Volume must be grabbed from the calldata. Running obs_source_get_volume() will return the previous value. - double inputVolumeMul = 0; - if (!calldata_get_float(data, "volume", &inputVolumeMul)) - return; + double inputVolumeMul = calldata_float(data, "volume"); double inputVolumeDb = obs_mul_to_db(inputVolumeMul); if (inputVolumeDb == -INFINITY) @@ -120,9 +118,7 @@ void EventHandler::HandleInputAudioSyncOffsetChanged(void *param, calldata_t *da if (obs_source_get_type(source) != OBS_SOURCE_TYPE_INPUT) return; - long long inputAudioSyncOffset = 0; - if (!calldata_get_int(data, "offset", &inputAudioSyncOffset)) - return; + long long inputAudioSyncOffset = calldata_int(data, "offset"); json eventData; eventData["inputName"] = obs_source_get_name(source); @@ -141,10 +137,7 @@ void EventHandler::HandleInputAudioTracksChanged(void *param, calldata_t *data) if (obs_source_get_type(source) != OBS_SOURCE_TYPE_INPUT) return; - long long tracks; - if (!calldata_get_int(data, "mixers", &tracks)) { - return; - } + long long tracks = calldata_int(data, "mixers"); json inputAudioTracks; for (size_t i = 0; i < MAX_AUDIO_MIXES; i++) {