mirror of
https://github.com/obsproject/obs-studio.git
synced 2024-07-15 07:44:10 +00:00
libobs: Add funcs to determine whether audio active
Adds functions to allow sources to inform the UI whether the audio is currently active or not. Allows the ability to turn on/off the items in the mixer.
This commit is contained in:
parent
3baa75c7ca
commit
33c09d91c2
|
@ -602,6 +602,7 @@ struct obs_source {
|
|||
bool audio_failed;
|
||||
bool audio_pending;
|
||||
bool pending_stop;
|
||||
bool audio_active;
|
||||
bool user_muted;
|
||||
bool muted;
|
||||
struct obs_source *next_audio_source;
|
||||
|
|
|
@ -72,6 +72,8 @@ static const char *source_signals[] = {
|
|||
"void update_flags(ptr source, int flags)",
|
||||
"void audio_sync(ptr source, int out int offset)",
|
||||
"void audio_mixers(ptr source, in out int mixers)",
|
||||
"void audio_activate(ptr source)",
|
||||
"void audio_deactivate(ptr source)",
|
||||
"void filter_add(ptr source, ptr filter)",
|
||||
"void filter_remove(ptr source, ptr filter)",
|
||||
"void reorder_filters(ptr source)",
|
||||
|
@ -152,6 +154,7 @@ static bool obs_source_init(struct obs_source *source)
|
|||
source->volume = 1.0f;
|
||||
source->sync_offset = 0;
|
||||
source->balance = 0.5f;
|
||||
source->audio_active = true;
|
||||
pthread_mutex_init_value(&source->filter_mutex);
|
||||
pthread_mutex_init_value(&source->async_mutex);
|
||||
pthread_mutex_init_value(&source->audio_mutex);
|
||||
|
@ -4669,3 +4672,26 @@ float obs_source_get_balance_value(const obs_source_t *source)
|
|||
? source->balance
|
||||
: 0.5f;
|
||||
}
|
||||
|
||||
void obs_source_set_audio_active(obs_source_t *source, bool active)
|
||||
{
|
||||
if (!obs_source_valid(source, "obs_source_set_audio_active"))
|
||||
return;
|
||||
|
||||
if (os_atomic_set_bool(&source->audio_active, active) == active)
|
||||
return;
|
||||
|
||||
if (active)
|
||||
obs_source_dosignal(source, "source_audio_activate",
|
||||
"audio_activate");
|
||||
else
|
||||
obs_source_dosignal(source, "source_audio_deactivate",
|
||||
"audio_deactivate");
|
||||
}
|
||||
|
||||
bool obs_source_audio_active(const obs_source_t *source)
|
||||
{
|
||||
return obs_source_valid(source, "obs_source_audio_active")
|
||||
? os_atomic_load_bool(&source->audio_active)
|
||||
: false;
|
||||
}
|
||||
|
|
|
@ -703,6 +703,8 @@ static const char *obs_signals[] = {
|
|||
"void source_deactivate(ptr source)",
|
||||
"void source_show(ptr source)",
|
||||
"void source_hide(ptr source)",
|
||||
"void source_audio_activate(ptr source)",
|
||||
"void source_audio_deactivate(ptr source)",
|
||||
"void source_rename(ptr source, string new_name, string prev_name)",
|
||||
"void source_volume(ptr source, in out float volume)",
|
||||
"void source_volume_level(ptr source, float level, float magnitude, "
|
||||
|
|
|
@ -1312,6 +1312,9 @@ EXPORT bool obs_source_async_unbuffered(const obs_source_t *source);
|
|||
EXPORT void obs_source_set_async_decoupled(obs_source_t *source, bool decouple);
|
||||
EXPORT bool obs_source_async_decoupled(const obs_source_t *source);
|
||||
|
||||
EXPORT void obs_source_set_audio_active(obs_source_t *source, bool show);
|
||||
EXPORT bool obs_source_audio_active(const obs_source_t *source);
|
||||
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* Transition-specific functions */
|
||||
enum obs_transition_target {
|
||||
|
|
Loading…
Reference in a new issue