Skip to content

Commit

Permalink
UI: Remove hotkeys for mon and sends buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
pkviet committed Oct 6, 2018
1 parent 5cbec72 commit 6d7c60c
Show file tree
Hide file tree
Showing 10 changed files with 3 additions and 240 deletions.
4 changes: 0 additions & 4 deletions UI/data/locale/en-US.ini
Original file line number Diff line number Diff line change
Expand Up @@ -782,10 +782,6 @@ Basic.AdvAudio.Volume="Volume (%)"
Basic.AdvAudio.Mono="Downmix to Mono"
Basic.AdvAudio.Balance="Balance"
Basic.AdvAudio.SyncOffset="Sync Offset (ms)"
Basic.AdvAudio.Monitoring="Audio Monitoring"
Basic.AdvAudio.Monitoring.None="Monitor Off"
Basic.AdvAudio.Monitoring.MonitorOnly="Monitor Only (mute output)"
Basic.AdvAudio.Monitoring.Both="Monitor and Output"
Basic.AdvAudio.AudioTracks="Tracks"

# basic mode 'hotkeys' settings
Expand Down
41 changes: 0 additions & 41 deletions UI/volume-control.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,37 +45,6 @@ void VolControl::OBSVolumeMuted(void *data, calldata_t *calldata)
Q_ARG(bool, muted));
}


void VolControl::MonitoringEnabled(bool checked)
{
if (mon->isChecked() != checked)
mon->setChecked(checked);
SetMon(checked);
}

void VolControl::OBSMonitoringEnabled(void *data, calldata_t *calldata)
{
VolControl *volControl = static_cast<VolControl*>(data);
bool monitoring = calldata_bool(calldata, "monitor");

QMetaObject::invokeMethod(volControl, "MonitoringEnabled",
Q_ARG(bool, monitoring));
}

void VolControl::SendEnabled(bool checked) {
if (send->isChecked() != checked)
send->setChecked(checked);
SetSends(checked);
}

void VolControl::OBSSend(void *data, calldata_t *calldata) {
VolControl *volControl = static_cast<VolControl*>(data);
bool send = calldata_bool(calldata, "send");

QMetaObject::invokeMethod(volControl, "SendEnabled",
Q_ARG(bool, send));
}

void VolControl::VolumeChanged()
{
slider->blockSignals(true);
Expand Down Expand Up @@ -468,9 +437,6 @@ VolControl::VolControl(OBSSource source_, bool *mutePtr, bool showConfig, bool v
SetMon(monON);
mon->setAccessibleName(QTStr("VolControl.Mon"));
mon->setToolTip(QTStr("VolControl.Mon.Tooltip"));
if (source != nullptr)
signal_handler_connect(obs_source_get_signal_handler(source), "monitor",
OBSMonitoringEnabled, this);

QWidget::connect(mon, SIGNAL(clicked(bool)), this, SLOT(SetMon(bool)));
/* The send button toggles the sends of the source to output tracks.
Expand All @@ -496,9 +462,6 @@ VolControl::VolControl(OBSSource source_, bool *mutePtr, bool showConfig, bool v

send->setAccessibleName(QTStr("VolControl.Sends"));
send->setToolTip(QTStr("VolControl.Sends.Tooltip"));
if (source != nullptr)
signal_handler_connect(obs_source_get_signal_handler(source),
"send", OBSSend, this);
QWidget::connect(send, SIGNAL(clicked(bool)), this,
SLOT(SetSends(bool)));
}
Expand Down Expand Up @@ -563,10 +526,6 @@ VolControl::~VolControl()
if (source != nullptr) {
signal_handler_disconnect(obs_source_get_signal_handler(source),
"mute", OBSVolumeMuted, this);
signal_handler_disconnect(obs_source_get_signal_handler(source),
"monitor", OBSMonitoringEnabled, this);
signal_handler_disconnect(obs_source_get_signal_handler(source),
"sends", OBSSend, this);
}
obs_fader_destroy(obs_fader);
obs_volmeter_destroy(obs_volmeter);
Expand Down
4 changes: 0 additions & 4 deletions UI/volume-control.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,15 +264,11 @@ class VolControl : public QWidget {
const float peak[MAX_AUDIO_CHANNELS],
const float inputPeak[MAX_AUDIO_CHANNELS]);
static void OBSVolumeMuted(void *data, calldata_t *calldata);
static void OBSMonitoringEnabled(void *data, calldata_t *calldata);
static void OBSSend(void *data, calldata_t *calldata);

void EmitConfigClicked();

private slots:
void VolumeMuted(bool muted);
void MonitoringEnabled(bool checked);
void SendEnabled(bool checked);
void SetMuted(bool checked);
void SetStream(bool checked);
void SetRec(bool checked);
Expand Down
2 changes: 0 additions & 2 deletions UI/window-basic-main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1993,8 +1993,6 @@ void OBSBasic::InitHotkeys()
obs_hotkeys_set_translations(&t);

obs_hotkeys_set_audio_hotkeys_translations(Str("Mute"), Str("Unmute"),
Str("Monitor"), Str("Unmonitor"),
Str("Send"), Str("Unsend"),
Str("Push-to-mute"), Str("Push-to-talk"));

obs_hotkeys_set_sceneitem_hotkeys_translations(
Expand Down
6 changes: 0 additions & 6 deletions libobs/obs-hotkey.c
Original file line number Diff line number Diff line change
Expand Up @@ -1591,17 +1591,11 @@ void obs_hotkey_update_atomic(obs_hotkey_atomic_update_func func, void *data)

void obs_hotkeys_set_audio_hotkeys_translations(
const char *mute, const char *unmute,
const char *monitor, const char *unmonitor,
const char *send, const char *unsend,
const char *push_to_mute, const char *push_to_talk)
{
#define SET_T(n) bfree(obs->hotkeys.n); obs->hotkeys.n = bstrdup(n)
SET_T(mute);
SET_T(unmute);
SET_T(monitor);
SET_T(unmonitor);
SET_T(send);
SET_T(unsend);
SET_T(push_to_mute);
SET_T(push_to_talk);
#undef SET_T
Expand Down
2 changes: 0 additions & 2 deletions libobs/obs-hotkey.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,6 @@ EXPORT void obs_hotkeys_set_translations_s(

EXPORT void obs_hotkeys_set_audio_hotkeys_translations(
const char *mute, const char *unmute,
const char *monitor, const char *unmonitor,
const char *send, const char *unsend,
const char *push_to_mute, const char *push_to_talk);

EXPORT void obs_hotkeys_set_sceneitem_hotkeys_translations(
Expand Down
17 changes: 3 additions & 14 deletions libobs/obs-internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -383,10 +383,6 @@ struct obs_core_hotkeys {
char *push_to_talk;
char *sceneitem_show;
char *sceneitem_hide;
char *monitor;
char *unmonitor;
char *send;
char *unsend;
};

struct obs_core {
Expand Down Expand Up @@ -535,8 +531,6 @@ enum audio_action_type {
AUDIO_ACTION_MUTE,
AUDIO_ACTION_PTT,
AUDIO_ACTION_PTM,
AUDIO_ACTION_MON,
AUDIO_ACTION_SEND,
};

struct audio_action {
Expand Down Expand Up @@ -682,7 +676,6 @@ struct obs_source {

/* sources specific hotkeys */
obs_hotkey_pair_id mute_unmute_key;
obs_hotkey_pair_id monitor_unmonitor_key;
obs_hotkey_id push_to_mute_key;
obs_hotkey_id push_to_talk_key;
bool push_to_mute_enabled;
Expand Down Expand Up @@ -721,15 +714,11 @@ struct obs_source {
enum obs_monitoring_type monitoring_type;

obs_data_t *private_settings;
/* 'monitoring' bool: controls whether source is monitored or not;
* overlaps with 'monitoring_type'.
* The 'sends' bool tracks whether the source sends audio to Audio
* tracks. The two bool enable a mapping to current monitoring_type API
* but allow a complete decoupling of monitoring and output.
/* The 'sends' bool tracks whether the source sends audio to Audio
* tracks. It is used to decouple monitoring and output.
*/
bool monitoring;

bool sends;
obs_hotkey_pair_id send_unsend_key;
};

extern struct obs_source_info *get_source_info(const char *id);
Expand Down
149 changes: 0 additions & 149 deletions libobs/obs-source.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ static const char *source_signals[] = {
"void show(ptr source)",
"void hide(ptr source)",
"void mute(ptr source, bool muted)",
"void monitor(ptr source, bool monitoring)",
"void send(ptr source, bool send)",
"void push_to_mute_changed(ptr source, bool enabled)",
"void push_to_mute_delay(ptr source, int delay)",
"void push_to_talk_changed(ptr source, bool enabled)",
Expand Down Expand Up @@ -235,71 +233,6 @@ static bool obs_source_hotkey_unmute(void *data,
return true;
}

static bool obs_source_hotkey_monitor(void *data,
obs_hotkey_pair_id id, obs_hotkey_t *key, bool pressed)
{
UNUSED_PARAMETER(id);
UNUSED_PARAMETER(key);
bool monON;
struct obs_source *source = data;

enum obs_monitoring_type type = obs_source_get_monitoring_type(source);
monON = type == OBS_MONITORING_TYPE_NONE ? false : true;
if (!pressed || monON)
return false;

source->monitoring = true;
obs_source_set_monitoring(source, true);

return true;
}

static bool obs_source_hotkey_unmonitor(void *data,
obs_hotkey_pair_id id, obs_hotkey_t *key, bool pressed)
{
UNUSED_PARAMETER(id);
UNUSED_PARAMETER(key);
bool monOFF;
struct obs_source *source = data;

enum obs_monitoring_type type = obs_source_get_monitoring_type(source);
monOFF = type == OBS_MONITORING_TYPE_NONE ? true : false;
if (!pressed || monOFF)
return false;

source->monitoring = false;
obs_source_set_monitoring(source, false);
return true;
}

static bool obs_source_hotkey_send(void *data,
obs_hotkey_pair_id id, obs_hotkey_t *key, bool pressed)
{
UNUSED_PARAMETER(id);
UNUSED_PARAMETER(key);
struct obs_source *source = data;

if (!pressed || source->sends)
return false;

obs_source_set_send_hotkey(source, true);
return true;
}

static bool obs_source_hotkey_unsend(void *data,
obs_hotkey_pair_id id, obs_hotkey_t *key, bool pressed)
{
UNUSED_PARAMETER(id);
UNUSED_PARAMETER(key);
struct obs_source *source = data;

if (!pressed || !source->sends)
return false;

obs_source_set_send_hotkey(source, false);
return true;
}

static void obs_source_hotkey_push_to_mute(void *data,
obs_hotkey_id id, obs_hotkey_t *key, bool pressed)
{
Expand Down Expand Up @@ -347,8 +280,6 @@ static void obs_source_init_audio_hotkeys(struct obs_source *source)
if (!(source->info.output_flags & OBS_SOURCE_AUDIO) ||
source->info.type != OBS_SOURCE_TYPE_INPUT) {
source->mute_unmute_key = OBS_INVALID_HOTKEY_ID;
source->monitor_unmonitor_key = OBS_INVALID_HOTKEY_PAIR_ID;
source->send_unsend_key = OBS_INVALID_HOTKEY_PAIR_ID;
source->push_to_talk_key = OBS_INVALID_HOTKEY_ID;
return;
}
Expand All @@ -359,19 +290,7 @@ static void obs_source_init_audio_hotkeys(struct obs_source *source)
obs_source_hotkey_mute, obs_source_hotkey_unmute,
source, source);

source->monitor_unmonitor_key = obs_hotkey_pair_register_source(source,
"libobs.monitor", obs->hotkeys.monitor,
"libobs.unmonitor", obs->hotkeys.unmonitor,
obs_source_hotkey_monitor, obs_source_hotkey_unmonitor,
source, source);

if (!(source->info.output_flags & OBS_SOURCE_TRACK)) {
source->send_unsend_key = obs_hotkey_pair_register_source(source,
"libobs.send", obs->hotkeys.send,
"libobs.unsend", obs->hotkeys.unsend,
obs_source_hotkey_send, obs_source_hotkey_unsend,
source, source);

source->push_to_mute_key = obs_hotkey_register_source(source,
"libobs.push-to-mute", obs->hotkeys.push_to_mute,
obs_source_hotkey_push_to_mute, source);
Expand Down Expand Up @@ -406,8 +325,6 @@ static obs_source_t *obs_source_create_internal(const char *id,
}

source->mute_unmute_key = OBS_INVALID_HOTKEY_PAIR_ID;
source->monitor_unmonitor_key = OBS_INVALID_HOTKEY_PAIR_ID;
source->send_unsend_key = OBS_INVALID_HOTKEY_PAIR_ID;
source->push_to_mute_key = OBS_INVALID_HOTKEY_ID;
source->push_to_talk_key = OBS_INVALID_HOTKEY_ID;

Expand Down Expand Up @@ -656,8 +573,6 @@ void obs_source_destroy(struct obs_source *source)
obs_hotkey_unregister(source->push_to_talk_key);
obs_hotkey_unregister(source->push_to_mute_key);
obs_hotkey_pair_unregister(source->mute_unmute_key);
obs_hotkey_pair_unregister(source->monitor_unmonitor_key);
obs_hotkey_pair_unregister(source->send_unsend_key);

for (i = 0; i < source->async_cache.num; i++)
obs_source_frame_decref(source->async_cache.array[i].frame);
Expand Down Expand Up @@ -3759,55 +3674,6 @@ void obs_source_set_muted(obs_source_t *source, bool muted)
pthread_mutex_unlock(&source->audio_actions_mutex);
}

void obs_source_set_monitoring(obs_source_t *source, bool monitoring) {
struct calldata data;
uint8_t stack[128];
struct audio_action action = {
.timestamp = os_gettime_ns(),
.type = AUDIO_ACTION_MON,
.set = monitoring
};

if (!obs_source_valid(source, "obs_source_set_monitoring"))
return;

source->monitoring = monitoring;

calldata_init_fixed(&data, stack, sizeof(stack));
calldata_set_ptr(&data, "source", source);
calldata_set_bool(&data, "monitor", monitoring);

signal_handler_signal(source->context.signals, "monitor", &data);

pthread_mutex_lock(&source->audio_actions_mutex);
da_push_back(source->audio_actions, &action);
pthread_mutex_unlock(&source->audio_actions_mutex);
}

void obs_source_set_send_hotkey(obs_source_t *source, bool send)
{
struct calldata data;
uint8_t stack[128];
struct audio_action action = {
.timestamp = os_gettime_ns(),
.type = AUDIO_ACTION_SEND,
.set = send
};

if (!obs_source_valid(source, "obs_source_set_send_hotkey"))
return;

calldata_init_fixed(&data, stack, sizeof(stack));
calldata_set_ptr(&data, "source", source);
calldata_set_bool(&data, "send", send);

signal_handler_signal(source->context.signals, "send", &data);

pthread_mutex_lock(&source->audio_actions_mutex);
da_push_back(source->audio_actions, &action);
pthread_mutex_unlock(&source->audio_actions_mutex);
}

static void source_signal_push_to_changed(obs_source_t *source,
const char *signal, bool enabled)
{
Expand Down Expand Up @@ -4014,14 +3880,10 @@ static inline void apply_audio_action(obs_source_t *source,
source->volume = action->vol; break;
case AUDIO_ACTION_MUTE:
source->muted = action->set; break;
case AUDIO_ACTION_MON:
source->monitoring = action->set; break;
case AUDIO_ACTION_PTT:
source->push_to_talk_pressed = action->set; break;
case AUDIO_ACTION_PTM:
source->push_to_mute_pressed = action->set; break;
case AUDIO_ACTION_SEND:
source->sends = action->set; break;
}
}

Expand Down Expand Up @@ -4296,17 +4158,6 @@ enum obs_monitoring_type obs_source_get_monitoring_type(
source->monitoring_type : OBS_MONITORING_TYPE_NONE;
}

void obs_source_set_monitoring_state(obs_source_t *source, bool monitorActive)
{
source->monitoring = monitorActive;
}

bool obs_source_get_monitoring_state(const obs_source_t *source)
{
return obs_source_valid(source, "obs_source_get_monitoring_state") ?
source->monitoring : false;
}

void obs_source_set_sends(obs_source_t *source, bool sends)
{
source->sends = sends;
Expand Down
Loading

0 comments on commit 6d7c60c

Please sign in to comment.