Hello,

Below is a patch that I made to add an "enable/disable" handler to the
FIFO output mechanism. In this way the FIFO itself will only be
created/accessed/deleted when the output mechanism is actually
enabled.

This is useful for more complex FIFO piping where you can't have the
FIFO being held on to for extended periods of time.

Yay first submission!

Signed,
Austen

>From 3b940202bf293b73baa178a2d7b6cfb518a4dbae Mon Sep 17 00:00:00 2001
From: Austen Dicken <cvp...@gmail.com>
Date: Thu, 9 Aug 2012 18:03:00 -0500
Subject: [output_fifo]: only access files when output is enabled

This patch moves the FIFO creation/deletion logic from
the init/finish methods to the enable/disable methods.
This ensures that the FIFOs are not being held on to
when the output is disabled.
---
 src/output/fifo_output_plugin.c |   29 ++++++++++++++++++++++-------
 1 files changed, 22 insertions(+), 7 deletions(-)

diff --git a/src/output/fifo_output_plugin.c b/src/output/fifo_output_plugin.c
index 022be0b..691d900 100644
--- a/src/output/fifo_output_plugin.c
+++ b/src/output/fifo_output_plugin.c
@@ -203,12 +203,6 @@ fifo_output_init(const struct config_param *param,
                return NULL;
        }

-       if (!fifo_open(fd, error_r)) {
-               ao_base_finish(&fd->base);
-               fifo_data_free(fd);
-               return NULL;
-       }
-
        return &fd->base;
 }

@@ -217,12 +211,31 @@ fifo_output_finish(struct audio_output *ao)
 {
        struct fifo_data *fd = (struct fifo_data *)ao;

-       fifo_close(fd);
        ao_base_finish(&fd->base);
        fifo_data_free(fd);
 }

 static bool
+fifo_output_enable(void *data, GError **error)
+{
+       struct fifo_data *fd = (struct fifo_data *)data;
+
+       if (!fifo_open(fd, error)) {
+               return false;
+       }
+
+       return true;
+}
+
+static void
+fifo_output_disable(struct audio_output *ao)
+{
+       struct fifo_data *fd = (struct fifo_data *)ao;
+
+       fifo_close(fd);
+}
+
+static bool
 fifo_output_open(struct audio_output *ao, struct audio_format *audio_format,
                 G_GNUC_UNUSED GError **error)
 {
@@ -307,6 +320,8 @@ const struct audio_output_plugin fifo_output_plugin = {
        .name = "fifo",
        .init = fifo_output_init,
        .finish = fifo_output_finish,
+       .enable = fifo_output_enable,
+       .disable = fifo_output_disable,
        .open = fifo_output_open,
        .close = fifo_output_close,
        .delay = fifo_output_delay,
-- 
1.7.8.6

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Musicpd-dev-team mailing list
Musicpd-dev-team@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/musicpd-dev-team

Reply via email to