From 90d9a5204fd07a7a57906858dba4b3666552f880 Mon Sep 17 00:00:00 2001 From: Danni Date: Sat, 24 May 2014 16:24:48 -0700 Subject: [PATCH] Updated per comments pull #90. --- libobs/media-io/audio-io.c | 13 +++++++++---- libobs/obs-source.c | 5 +---- obs/volume-control.cpp | 4 ++-- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/libobs/media-io/audio-io.c b/libobs/media-io/audio-io.c index 5d2b9abe6..0594b6dd0 100644 --- a/libobs/media-io/audio-io.c +++ b/libobs/media-io/audio-io.c @@ -711,6 +711,11 @@ uint32_t audio_output_samplerate(audio_t audio) return audio ? audio->info.samples_per_sec : 0; } +/* On some platforms, max() may already be defined */ +#ifndef max +#define max(a, b) ((a) > (b) ? (a) : (b)) +#endif + /* TODO: Optimization of volume multiplication functions */ static inline int mul_vol_u8bit(void *array, float volume, size_t total_num) @@ -798,15 +803,15 @@ static inline int mul_vol_float(void *array, float volume, size_t total_num) for (size_t i = 0; i < total_num; i++) { vals[i] *= volume; - maxVol = max(maxVol, (float)fabs(vals[i])); + maxVol = fmaxf(maxVol, (float)fabs(vals[i])); } return (int)(maxVol * 10000.f); } -// [Danni] changed to int for volume feedback. Seems like the most logical -// place to calculate this to avoid unnessisary iterations. -// scaled to max of 10000. +/* [Danni] changed to int for volume feedback. Seems like the most logical + place to calculate this to avoid unnessisary iterations. + scaled to max of 10000. */ static int audio_line_place_data_pos(struct audio_line *line, const struct audio_data *data, size_t position) diff --git a/libobs/obs-source.c b/libobs/obs-source.c index 80773f803..95ec47a02 100644 --- a/libobs/obs-source.c +++ b/libobs/obs-source.c @@ -29,8 +29,6 @@ #include "obs.h" #include "obs-internal.h" - - static inline bool source_valid(struct obs_source *source) { return source && source->context.data; @@ -82,7 +80,7 @@ static const char *source_signals[] = { "void show(ptr source)", "void hide(ptr source)", "void volume(ptr source, in out float volume)", - "void volumelevel(ptr source, in out float volume)", + "void volumelevel(ptr source, in out int volume)", NULL }; @@ -1617,7 +1615,6 @@ void obs_source_updatevolumelevel(obs_source_t source, int volume) } } - static void set_tree_preset_vol(obs_source_t parent, obs_source_t child, void *param) { diff --git a/obs/volume-control.cpp b/obs/volume-control.cpp index 5de818f72..5e893faaa 100644 --- a/obs/volume-control.cpp +++ b/obs/volume-control.cpp @@ -18,8 +18,8 @@ void VolControl::OBSVolumeChanged(void *data, calldata_t calldata) } -// [Danni] This may be a bit too resource intensive for such a simple -// application. +/* [Danni] This may be a bit too resource intensive for such a simple + application. */ void VolControl::OBSVolumeLevel(void *data, calldata_t calldata) {