mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-10-29 05:40:23 -04:00
rtp-send: Add "inhibit_auto_suspend" module argument
Some people want module-rtp-send to send silence when the sink that is monitored goes idle, and some people want module-rtp-send to pause the RTP stream to avoid unnecessary bandwidth consumption.
This commit is contained in:
parent
b55de5179a
commit
4ebe88c2b2
1 changed files with 62 additions and 1 deletions
|
|
@ -68,7 +68,8 @@ PA_MODULE_USAGE(
|
|||
"port=<port number> "
|
||||
"mtu=<maximum transfer unit> "
|
||||
"loop=<loopback to local host?> "
|
||||
"ttl=<ttl value>"
|
||||
"ttl=<ttl value> "
|
||||
"inhibit_auto_suspend=<always|never|only_with_non_monitor_sources>"
|
||||
);
|
||||
|
||||
#define DEFAULT_PORT 46000
|
||||
|
|
@ -92,9 +93,16 @@ static const char* const valid_modargs[] = {
|
|||
"mtu" ,
|
||||
"loop",
|
||||
"ttl",
|
||||
"inhibit_auto_suspend",
|
||||
NULL
|
||||
};
|
||||
|
||||
enum inhibit_auto_suspend {
|
||||
INHIBIT_AUTO_SUSPEND_ALWAYS,
|
||||
INHIBIT_AUTO_SUSPEND_NEVER,
|
||||
INHIBIT_AUTO_SUSPEND_ONLY_WITH_NON_MONITOR_SOURCES
|
||||
};
|
||||
|
||||
struct userdata {
|
||||
pa_module *module;
|
||||
|
||||
|
|
@ -106,6 +114,8 @@ struct userdata {
|
|||
size_t mtu;
|
||||
|
||||
pa_time_event *sap_event;
|
||||
|
||||
enum inhibit_auto_suspend inhibit_auto_suspend;
|
||||
};
|
||||
|
||||
/* Called from I/O thread context */
|
||||
|
|
@ -139,6 +149,39 @@ static void source_output_push_cb(pa_source_output *o, const pa_memchunk *chunk)
|
|||
pa_rtp_send(&u->rtp_context, u->mtu, u->memblockq);
|
||||
}
|
||||
|
||||
static pa_source_output_flags_t get_dont_inhibit_auto_suspend_flag(pa_source *source,
|
||||
enum inhibit_auto_suspend inhibit_auto_suspend) {
|
||||
pa_assert(source);
|
||||
|
||||
switch (inhibit_auto_suspend) {
|
||||
case INHIBIT_AUTO_SUSPEND_ALWAYS:
|
||||
return 0;
|
||||
|
||||
case INHIBIT_AUTO_SUSPEND_NEVER:
|
||||
return PA_SOURCE_OUTPUT_DONT_INHIBIT_AUTO_SUSPEND;
|
||||
|
||||
case INHIBIT_AUTO_SUSPEND_ONLY_WITH_NON_MONITOR_SOURCES:
|
||||
return source->monitor_of ? 0 : PA_SOURCE_OUTPUT_DONT_INHIBIT_AUTO_SUSPEND;
|
||||
}
|
||||
|
||||
pa_assert_not_reached();
|
||||
}
|
||||
|
||||
/* Called from the main thread. */
|
||||
static void source_output_moving_cb(pa_source_output *o, pa_source *dest) {
|
||||
struct userdata *u;
|
||||
|
||||
pa_assert(o);
|
||||
|
||||
u = o->userdata;
|
||||
|
||||
if (!dest)
|
||||
return;
|
||||
|
||||
o->flags &= ~PA_SOURCE_OUTPUT_DONT_INHIBIT_AUTO_SUSPEND;
|
||||
o->flags |= get_dont_inhibit_auto_suspend_flag(dest, u->inhibit_auto_suspend);
|
||||
}
|
||||
|
||||
/* Called from main context */
|
||||
static void source_output_kill_cb(pa_source_output* o) {
|
||||
struct userdata *u;
|
||||
|
|
@ -188,6 +231,8 @@ int pa__init(pa_module*m) {
|
|||
socklen_t k;
|
||||
char hn[128], *n;
|
||||
bool loop = false;
|
||||
enum inhibit_auto_suspend inhibit_auto_suspend = INHIBIT_AUTO_SUSPEND_ONLY_WITH_NON_MONITOR_SOURCES;
|
||||
const char *inhibit_auto_suspend_str;
|
||||
pa_source_output_new_data data;
|
||||
|
||||
pa_assert(m);
|
||||
|
|
@ -207,6 +252,19 @@ int pa__init(pa_module*m) {
|
|||
goto fail;
|
||||
}
|
||||
|
||||
if ((inhibit_auto_suspend_str = pa_modargs_get_value(ma, "inhibit_auto_suspend", NULL))) {
|
||||
if (pa_streq(inhibit_auto_suspend_str, "always"))
|
||||
inhibit_auto_suspend = INHIBIT_AUTO_SUSPEND_ALWAYS;
|
||||
else if (pa_streq(inhibit_auto_suspend_str, "never"))
|
||||
inhibit_auto_suspend = INHIBIT_AUTO_SUSPEND_NEVER;
|
||||
else if (pa_streq(inhibit_auto_suspend_str, "only_with_non_monitor_sources"))
|
||||
inhibit_auto_suspend = INHIBIT_AUTO_SUSPEND_ONLY_WITH_NON_MONITOR_SOURCES;
|
||||
else {
|
||||
pa_log("Failed to parse the \"inhibit_auto_suspend\" parameter.");
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
||||
ss = s->sample_spec;
|
||||
pa_rtp_sample_spec_fixup(&ss);
|
||||
cm = s->channel_map;
|
||||
|
|
@ -377,6 +435,7 @@ int pa__init(pa_module*m) {
|
|||
pa_source_output_new_data_set_source(&data, s, false);
|
||||
pa_source_output_new_data_set_sample_spec(&data, &ss);
|
||||
pa_source_output_new_data_set_channel_map(&data, &cm);
|
||||
data.flags |= get_dont_inhibit_auto_suspend_flag(s, inhibit_auto_suspend);
|
||||
|
||||
pa_source_output_new(&o, m->core, &data);
|
||||
pa_source_output_new_data_done(&data);
|
||||
|
|
@ -388,6 +447,7 @@ int pa__init(pa_module*m) {
|
|||
|
||||
o->parent.process_msg = source_output_process_msg;
|
||||
o->push = source_output_push_cb;
|
||||
o->moving = source_output_moving_cb;
|
||||
o->kill = source_output_kill_cb;
|
||||
|
||||
pa_log_info("Configured source latency of %llu ms.",
|
||||
|
|
@ -440,6 +500,7 @@ int pa__init(pa_module*m) {
|
|||
pa_sap_send(&u->sap_context, 0);
|
||||
|
||||
u->sap_event = pa_core_rttime_new(m->core, pa_rtclock_now() + SAP_INTERVAL, sap_event_cb, u);
|
||||
u->inhibit_auto_suspend = inhibit_auto_suspend;
|
||||
|
||||
pa_source_output_put(u->source_output);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue