[v10,3/3] pipe-source: implement autosuspend option

Submitted by Raman Shishniou on March 20, 2018, 12:27 p.m.

Details

Message ID 1521548857-11194-3-git-send-email-rommer@ibuffed.com
State New
Headers show
Series "Series without cover letter" ( rev: 1 ) in PulseAudio

Not browsing as part of any series.

Commit Message

Raman Shishniou March 20, 2018, 12:27 p.m.
This patch implements the autosuspend option. Setting autosuspend to
false restores original pipe-source behaviour.
---
 src/modules/module-pipe-source.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

diff --git a/src/modules/module-pipe-source.c b/src/modules/module-pipe-source.c
index 4fd515b..b2dcb02 100644
--- a/src/modules/module-pipe-source.c
+++ b/src/modules/module-pipe-source.c
@@ -58,7 +58,8 @@  PA_MODULE_USAGE(
         "format=<sample format> "
         "rate=<sample rate> "
         "channels=<number of channels> "
-        "channel_map=<channel map>");
+        "channel_map=<channel map> "
+        "autosuspend=<bool>");
 
 #define DEFAULT_FILE_NAME "/tmp/music.input"
 #define DEFAULT_SOURCE_NAME "fifo_input"
@@ -108,6 +109,7 @@  static const char* const valid_modargs[] = {
     "rate",
     "channels",
     "channel_map",
+    "autosuspend",
     NULL
 };
 
@@ -364,6 +366,7 @@  int pa__init(pa_module *m) {
     pa_modargs *ma;
     struct pollfd *pollfd;
     pa_source_new_data data;
+    bool autosuspend;
 
     pa_assert(m);
 
@@ -409,7 +412,13 @@  int pa__init(pa_module *m) {
 
     u->writer_connected = true;
 
-    if ((u->fd = pa_open_cloexec(u->filename, O_RDONLY, 0)) < 0) {
+    autosuspend = true;
+    if (pa_modargs_get_value_boolean(ma, "autosuspend", &autosuspend) < 0) {
+        pa_log("Failed to parse autosuspend argument.");
+        goto fail;
+    }
+
+    if ((u->fd = pa_open_cloexec(u->filename, autosuspend ? O_RDONLY : O_RDWR, 0)) < 0) {
         pa_log("open('%s'): %s", u->filename, pa_cstrerror(errno));
         goto fail;
     }