EventHandler: Remove unnecessary calldata helper

This commit is contained in:
tt2468 2021-06-13 04:50:04 -07:00
parent ebbb1391fe
commit aaadf4d2ff
3 changed files with 6 additions and 23 deletions

View File

@ -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;

View File

@ -27,13 +27,11 @@ enum ObsMediaInputAction {
};
template <typename T> T* GetCalldataPointer(const calldata_t *data, const char* name) {
void* ptr = nullptr;
void *ptr = nullptr;
calldata_get_ptr(data, name, &ptr);
return reinterpret_cast<T*>(ptr);
}
std::string GetCalldataString(const calldata_t *data, const char* name);
class EventHandler
{
public:

View File

@ -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++) {