Skip to content

Commit

Permalink
Implement Steam Audio log callback
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenjt authored and stechyo committed Oct 12, 2024
1 parent 8bf7b66 commit b84001a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/server_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ IPLSceneSettings create_scene_cfg(IPLContext ctx) {
IPLContext create_ctx() {
IPLContextSettings ctx_cfg{};
ctx_cfg.version = STEAMAUDIO_VERSION;
ctx_cfg.logCallback = log_callback;
IPLContext ctx;
IPLerror err = iplContextCreate(&ctx_cfg, &ctx);
handleErr(err);
Expand Down
19 changes: 19 additions & 0 deletions src/steam_audio.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,4 +119,23 @@ inline void handleErr(IPLerror err) {
}
}

inline void log_callback(IPLLogLevel level, const char *message) {
SteamAudio::GodotSteamAudioLogLevel godot_log_level;
switch (level) {
case IPL_LOGLEVEL_INFO:
godot_log_level = SteamAudio::GodotSteamAudioLogLevel::log_info;
break;
case IPL_LOGLEVEL_WARNING:
godot_log_level = SteamAudio::GodotSteamAudioLogLevel::log_warn;
break;
case IPL_LOGLEVEL_ERROR:
godot_log_level = SteamAudio::GodotSteamAudioLogLevel::log_error;
break;
case IPL_LOGLEVEL_DEBUG:
godot_log_level = SteamAudio::GodotSteamAudioLogLevel::log_debug;
break;
}
SteamAudio::log(godot_log_level, String(message).strip_edges().utf8().get_data());
}

#endif

0 comments on commit b84001a

Please sign in to comment.