Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
尘离序散
obs-studio
提交
7b3b0838
O
obs-studio
项目概览
尘离序散
/
obs-studio
与 Fork 源项目一致
从无法访问的项目Fork
通知
30
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
obs-studio
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
7b3b0838
编写于
5月 01, 2015
作者:
P
Palana
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
libobs: Add audio source hotkeys
上级
1d39c3e9
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
306 addition
and
1 deletion
+306
-1
libobs/obs-hotkey.c
libobs/obs-hotkey.c
+12
-0
libobs/obs-hotkey.h
libobs/obs-hotkey.h
+3
-0
libobs/obs-internal.h
libobs/obs-internal.h
+17
-0
libobs/obs-source.c
libobs/obs-source.c
+239
-1
libobs/obs.c
libobs/obs.c
+21
-0
libobs/obs.h
libobs/obs.h
+14
-0
未找到文件。
libobs/obs-hotkey.c
浏览文件 @
7b3b0838
...
...
@@ -1495,3 +1495,15 @@ void obs_hotkey_update_atomic(obs_hotkey_atomic_update_func func, void *data)
unlock
();
}
void
obs_hotkeys_set_audio_hotkeys_translations
(
const
char
*
mute
,
const
char
*
unmute
,
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
(
push_to_mute
);
SET_T
(
push_to_talk
);
#undef SET_T
}
libobs/obs-hotkey.h
浏览文件 @
7b3b0838
...
...
@@ -120,6 +120,9 @@ EXPORT void obs_hotkeys_set_translations_s(
obs_hotkeys_set_translations_s(translations, \
sizeof(struct obs_hotkeys_translations))
EXPORT
void
obs_hotkeys_set_audio_hotkeys_translations
(
const
char
*
mute
,
const
char
*
unmute
,
const
char
*
push_to_mute
,
const
char
*
push_to_talk
);
/* registering hotkeys (giving hotkeys a name and a function) */
...
...
libobs/obs-internal.h
浏览文件 @
7b3b0838
...
...
@@ -299,6 +299,10 @@ struct obs_core_hotkeys {
signal_handler_t
*
signals
;
char
*
translations
[
OBS_KEY_LAST_VALUE
];
char
*
mute
;
char
*
unmute
;
char
*
push_to_mute
;
char
*
push_to_talk
;
};
struct
obs_core
{
...
...
@@ -512,6 +516,19 @@ struct obs_source {
gs_texrender_t
*
filter_texrender
;
enum
obs_allow_direct_render
allow_direct
;
bool
rendering_filter
;
/* sources specific hotkeys */
obs_hotkey_pair_id
mute_unmute_key
;
obs_hotkey_id
push_to_mute_key
;
obs_hotkey_id
push_to_talk_key
;
bool
push_to_mute_enabled
:
1
;
bool
push_to_mute_pressed
:
1
;
bool
push_to_talk_enabled
:
1
;
bool
push_to_talk_pressed
:
1
;
uint64_t
push_to_mute_delay
;
uint64_t
push_to_mute_stop_time
;
uint64_t
push_to_talk_delay
;
uint64_t
push_to_talk_stop_time
;
};
extern
const
struct
obs_source_info
*
find_source
(
struct
darray
*
list
,
...
...
libobs/obs-source.c
浏览文件 @
7b3b0838
...
...
@@ -79,6 +79,10 @@ static const char *source_signals[] = {
"void show(ptr source)"
,
"void hide(ptr source)"
,
"void mute(ptr source, bool muted)"
,
"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)"
,
"void push_to_talk_delay(ptr source, int delay)"
,
"void enable(ptr source, bool enabled)"
,
"void rename(ptr source, string new_name, string prev_name)"
,
"void volume(ptr source, in out float volume)"
,
...
...
@@ -155,6 +159,83 @@ bool obs_source_init(struct obs_source *source,
return
true
;
}
static
bool
obs_source_hotkey_mute
(
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
||
obs_source_muted
(
source
))
return
false
;
obs_source_set_muted
(
source
,
true
);
return
true
;
}
static
bool
obs_source_hotkey_unmute
(
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
||
!
obs_source_muted
(
source
))
return
false
;
obs_source_set_muted
(
source
,
false
);
return
true
;
}
static
void
obs_source_hotkey_push_to_mute
(
void
*
data
,
obs_hotkey_id
id
,
obs_hotkey_t
*
key
,
bool
pressed
)
{
UNUSED_PARAMETER
(
id
);
UNUSED_PARAMETER
(
key
);
struct
obs_source
*
source
=
data
;
pthread_mutex_lock
(
&
source
->
audio_mutex
);
source
->
push_to_mute_pressed
=
pressed
;
pthread_mutex_unlock
(
&
source
->
audio_mutex
);
}
static
void
obs_source_hotkey_push_to_talk
(
void
*
data
,
obs_hotkey_id
id
,
obs_hotkey_t
*
key
,
bool
pressed
)
{
UNUSED_PARAMETER
(
id
);
UNUSED_PARAMETER
(
key
);
struct
obs_source
*
source
=
data
;
pthread_mutex_lock
(
&
source
->
audio_mutex
);
source
->
push_to_talk_pressed
=
pressed
;
pthread_mutex_unlock
(
&
source
->
audio_mutex
);
}
static
void
obs_source_init_audio_hotkeys
(
struct
obs_source
*
source
)
{
if
(
!
(
source
->
info
.
output_flags
&
OBS_SOURCE_AUDIO
))
{
source
->
mute_unmute_key
=
OBS_INVALID_HOTKEY_ID
;
source
->
push_to_talk_key
=
OBS_INVALID_HOTKEY_ID
;
return
;
}
source
->
mute_unmute_key
=
obs_hotkey_pair_register_source
(
source
,
"libobs.mute"
,
obs
->
hotkeys
.
mute
,
"libobs.unmute"
,
obs
->
hotkeys
.
unmute
,
obs_source_hotkey_mute
,
obs_source_hotkey_unmute
,
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
);
source
->
push_to_talk_key
=
obs_hotkey_register_source
(
source
,
"libobs.push-to-talk"
,
obs
->
hotkeys
.
push_to_talk
,
obs_source_hotkey_push_to_talk
,
source
);
}
static
inline
void
obs_source_dosignal
(
struct
obs_source
*
source
,
const
char
*
signal_obs
,
const
char
*
signal_source
)
{
...
...
@@ -186,6 +267,10 @@ obs_source_t *obs_source_create(enum obs_source_type type, const char *id,
source
->
info
=
*
info
;
}
source
->
mute_unmute_key
=
OBS_INVALID_HOTKEY_PAIR_ID
;
source
->
push_to_mute_key
=
OBS_INVALID_HOTKEY_ID
;
source
->
push_to_talk_key
=
OBS_INVALID_HOTKEY_ID
;
if
(
!
obs_source_init_context
(
source
,
settings
,
name
,
hotkey_data
))
goto
fail
;
...
...
@@ -195,6 +280,8 @@ obs_source_t *obs_source_create(enum obs_source_type type, const char *id,
if
(
!
obs_source_init
(
source
,
info
))
goto
fail
;
obs_source_init_audio_hotkeys
(
source
);
/* allow the source to be created even if creation fails so that the
* user's data doesn't become lost */
if
(
info
)
...
...
@@ -274,6 +361,10 @@ void obs_source_destroy(struct obs_source *source)
source
->
context
.
data
=
NULL
;
}
obs_hotkey_unregister
(
source
->
push_to_talk_key
);
obs_hotkey_unregister
(
source
->
push_to_mute_key
);
obs_hotkey_pair_unregister
(
source
->
mute_unmute_key
);
for
(
i
=
0
;
i
<
source
->
async_cache
.
num
;
i
++
)
obs_source_frame_decref
(
source
->
async_cache
.
array
[
i
].
frame
);
...
...
@@ -829,7 +920,22 @@ static void source_output_audio_line(obs_source_t *source,
source
->
present_volume
*
obs
->
audio
.
user_volume
*
obs
->
audio
.
present_volume
;
bool
muted
=
!
source
->
enabled
||
source
->
muted
;
if
(
source
->
push_to_mute_enabled
&&
source
->
push_to_mute_pressed
)
source
->
push_to_mute_stop_time
=
os_time
+
source
->
push_to_mute_delay
*
1000000
;
if
(
source
->
push_to_talk_enabled
&&
source
->
push_to_talk_pressed
)
source
->
push_to_talk_stop_time
=
os_time
+
source
->
push_to_talk_delay
*
1000000
;
bool
push_to_mute_active
=
source
->
push_to_mute_pressed
||
os_time
<
source
->
push_to_mute_stop_time
;
bool
push_to_talk_active
=
source
->
push_to_talk_pressed
||
os_time
<
source
->
push_to_talk_stop_time
;
bool
muted
=
!
source
->
enabled
||
source
->
muted
||
(
source
->
push_to_mute_enabled
&&
push_to_mute_active
)
||
(
source
->
push_to_talk_enabled
&&
!
push_to_talk_active
);
if
(
muted
)
in
.
volume
=
0
.
0
f
;
...
...
@@ -2820,3 +2926,135 @@ void obs_source_set_muted(obs_source_t *source, bool muted)
calldata_free
(
&
data
);
}
static
void
source_signal_push_to_changed
(
obs_source_t
*
source
,
const
char
*
signal
,
bool
enabled
)
{
struct
calldata
data
=
{
0
};
calldata_set_ptr
(
&
data
,
"source"
,
source
);
calldata_set_bool
(
&
data
,
"enabled"
,
enabled
);
signal_handler_signal
(
source
->
context
.
signals
,
signal
,
&
data
);
calldata_free
(
&
data
);
}
static
void
source_signal_push_to_delay
(
obs_source_t
*
source
,
const
char
*
signal
,
uint64_t
delay
)
{
struct
calldata
data
=
{
0
};
calldata_set_ptr
(
&
data
,
"source"
,
source
);
calldata_set_bool
(
&
data
,
"delay"
,
delay
);
signal_handler_signal
(
source
->
context
.
signals
,
signal
,
&
data
);
calldata_free
(
&
data
);
}
bool
obs_source_push_to_mute_enabled
(
obs_source_t
*
source
)
{
bool
enabled
;
if
(
!
source
)
return
false
;
pthread_mutex_lock
(
&
source
->
audio_mutex
);
enabled
=
source
->
push_to_mute_enabled
;
pthread_mutex_unlock
(
&
source
->
audio_mutex
);
return
enabled
;
}
void
obs_source_enable_push_to_mute
(
obs_source_t
*
source
,
bool
enabled
)
{
if
(
!
source
)
return
;
pthread_mutex_lock
(
&
source
->
audio_mutex
);
bool
changed
=
source
->
push_to_mute_enabled
!=
enabled
;
if
(
obs_source_get_output_flags
(
source
)
&
OBS_SOURCE_AUDIO
&&
changed
)
blog
(
LOG_INFO
,
"source '%s' %s push-to-mute"
,
obs_source_get_name
(
source
),
enabled
?
"enabled"
:
"disabled"
);
source
->
push_to_mute_enabled
=
enabled
;
if
(
changed
)
source_signal_push_to_changed
(
source
,
"push_to_mute_changed"
,
enabled
);
pthread_mutex_unlock
(
&
source
->
audio_mutex
);
}
uint64_t
obs_source_get_push_to_mute_delay
(
obs_source_t
*
source
)
{
uint64_t
delay
;
if
(
!
source
)
return
0
;
pthread_mutex_lock
(
&
source
->
audio_mutex
);
delay
=
source
->
push_to_mute_delay
;
pthread_mutex_unlock
(
&
source
->
audio_mutex
);
return
delay
;
}
void
obs_source_set_push_to_mute_delay
(
obs_source_t
*
source
,
uint64_t
delay
)
{
if
(
!
source
)
return
;
pthread_mutex_lock
(
&
source
->
audio_mutex
);
source
->
push_to_mute_delay
=
delay
;
source_signal_push_to_delay
(
source
,
"push_to_mute_delay"
,
delay
);
pthread_mutex_unlock
(
&
source
->
audio_mutex
);
}
bool
obs_source_push_to_talk_enabled
(
obs_source_t
*
source
)
{
bool
enabled
;
if
(
!
source
)
return
false
;
pthread_mutex_lock
(
&
source
->
audio_mutex
);
enabled
=
source
->
push_to_talk_enabled
;
pthread_mutex_unlock
(
&
source
->
audio_mutex
);
return
enabled
;
}
void
obs_source_enable_push_to_talk
(
obs_source_t
*
source
,
bool
enabled
)
{
if
(
!
source
)
return
;
pthread_mutex_lock
(
&
source
->
audio_mutex
);
bool
changed
=
source
->
push_to_talk_enabled
!=
enabled
;
if
(
obs_source_get_output_flags
(
source
)
&
OBS_SOURCE_AUDIO
&&
changed
)
blog
(
LOG_INFO
,
"source '%s' %s push-to-talk"
,
obs_source_get_name
(
source
),
enabled
?
"enabled"
:
"disabled"
);
source
->
push_to_talk_enabled
=
enabled
;
if
(
changed
)
source_signal_push_to_changed
(
source
,
"push_to_talk_changed"
,
enabled
);
pthread_mutex_unlock
(
&
source
->
audio_mutex
);
}
uint64_t
obs_source_get_push_to_talk_delay
(
obs_source_t
*
source
)
{
uint64_t
delay
;
if
(
!
source
)
return
0
;
pthread_mutex_lock
(
&
source
->
audio_mutex
);
delay
=
source
->
push_to_talk_delay
;
pthread_mutex_unlock
(
&
source
->
audio_mutex
);
return
delay
;
}
void
obs_source_set_push_to_talk_delay
(
obs_source_t
*
source
,
uint64_t
delay
)
{
if
(
!
source
)
return
;
pthread_mutex_lock
(
&
source
->
audio_mutex
);
source
->
push_to_talk_delay
=
delay
;
source_signal_push_to_delay
(
source
,
"push_to_talk_delay"
,
delay
);
pthread_mutex_unlock
(
&
source
->
audio_mutex
);
}
libobs/obs.c
浏览文件 @
7b3b0838
...
...
@@ -642,6 +642,10 @@ static inline bool obs_init_hotkeys(void)
da_init
(
hotkeys
->
hotkeys
);
hotkeys
->
signals
=
obs
->
signals
;
hotkeys
->
name_map_init_token
=
obs_pthread_once_init_token
;
hotkeys
->
mute
=
bstrdup
(
"Mute"
);
hotkeys
->
unmute
=
bstrdup
(
"Unmute"
);
hotkeys
->
push_to_mute
=
bstrdup
(
"Push-to-mute"
);
hotkeys
->
push_to_talk
=
bstrdup
(
"Push-to-talk"
);
if
(
!
obs_hotkeys_platform_init
(
hotkeys
))
return
false
;
...
...
@@ -687,6 +691,11 @@ static inline void obs_free_hotkeys(void)
{
struct
obs_core_hotkeys
*
hotkeys
=
&
obs
->
hotkeys
;
bfree
(
hotkeys
->
mute
);
bfree
(
hotkeys
->
unmute
);
bfree
(
hotkeys
->
push_to_mute
);
bfree
(
hotkeys
->
push_to_talk
);
obs_hotkey_name_map_free
();
obs_hotkeys_platform_free
(
hotkeys
);
...
...
@@ -1451,6 +1460,14 @@ static obs_source_t *obs_load_source_type(obs_data_t *source_data,
obs_data_set_default_bool
(
source_data
,
"muted"
,
false
);
obs_source_set_muted
(
source
,
obs_data_get_bool
(
source_data
,
"muted"
));
obs_data_set_default_bool
(
source_data
,
"push-to-talk"
,
false
);
obs_source_enable_push_to_talk
(
source
,
obs_data_get_bool
(
source_data
,
"push-to-talk"
));
obs_data_set_default_int
(
source_data
,
"push-to-talk-delay"
,
0
);
obs_source_set_push_to_talk_delay
(
source
,
obs_data_get_int
(
source_data
,
"push-to-talk-delay"
));
if
(
filters
)
{
size_t
count
=
obs_data_array_count
(
filters
);
...
...
@@ -1524,6 +1541,8 @@ obs_data_t *obs_save_source(obs_source_t *source)
const
char
*
id
=
obs_source_get_id
(
source
);
bool
enabled
=
obs_source_enabled
(
source
);
bool
muted
=
obs_source_muted
(
source
);
bool
push_to_talk
=
obs_source_push_to_talk_enabled
(
source
);
uint64_t
ptt_delay
=
obs_source_get_push_to_talk_delay
(
source
);
obs_source_save
(
source
);
hotkeys
=
obs_hotkeys_save_source
(
source
);
...
...
@@ -1543,6 +1562,8 @@ obs_data_t *obs_save_source(obs_source_t *source)
obs_data_set_double
(
source_data
,
"volume"
,
volume
);
obs_data_set_bool
(
source_data
,
"enabled"
,
enabled
);
obs_data_set_bool
(
source_data
,
"muted"
,
muted
);
obs_data_set_bool
(
source_data
,
"push-to-talk"
,
push_to_talk
);
obs_data_set_int
(
source_data
,
"push-to-talk-delay"
,
ptt_delay
);
obs_data_set_obj
(
source_data
,
"hotkeys"
,
hotkey_data
);
pthread_mutex_lock
(
&
source
->
filter_mutex
);
...
...
libobs/obs.h
浏览文件 @
7b3b0838
...
...
@@ -865,6 +865,20 @@ EXPORT void obs_source_set_enabled(obs_source_t *source, bool enabled);
EXPORT
bool
obs_source_muted
(
const
obs_source_t
*
source
);
EXPORT
void
obs_source_set_muted
(
obs_source_t
*
source
,
bool
muted
);
EXPORT
bool
obs_source_push_to_mute_enabled
(
obs_source_t
*
source
);
EXPORT
void
obs_source_enable_push_to_mute
(
obs_source_t
*
source
,
bool
enabled
);
EXPORT
uint64_t
obs_source_get_push_to_mute_delay
(
obs_source_t
*
source
);
EXPORT
void
obs_source_set_push_to_mute_delay
(
obs_source_t
*
source
,
uint64_t
delay
);
EXPORT
bool
obs_source_push_to_talk_enabled
(
obs_source_t
*
source
);
EXPORT
void
obs_source_enable_push_to_talk
(
obs_source_t
*
source
,
bool
enabled
);
EXPORT
uint64_t
obs_source_get_push_to_talk_delay
(
obs_source_t
*
source
);
EXPORT
void
obs_source_set_push_to_talk_delay
(
obs_source_t
*
source
,
uint64_t
delay
);
/* ------------------------------------------------------------------------- */
/* Functions used by sources */
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录