summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiguel Freitas <miguelfreitas@users.sourceforge.net>2002-12-24 13:36:21 +0000
committerMiguel Freitas <miguelfreitas@users.sourceforge.net>2002-12-24 13:36:21 +0000
commit359d8d8860cc1748a0f0e18bc791c80392cf7e48 (patch)
treeacc328be46f2feafae984b4e7b05458ec1c631d1
parent375a1697687a45a70f83e400bd113028846813a1 (diff)
downloadxine-lib-359d8d8860cc1748a0f0e18bc791c80392cf7e48.tar.gz
xine-lib-359d8d8860cc1748a0f0e18bc791c80392cf7e48.tar.bz2
trying to add support for audio post plugins. that must be easier than
video because audio frames have no methods... Michael please double check if i did something wrong! :) CVS patchset: 3664 CVS date: 2002/12/24 13:36:21
-rw-r--r--src/xine-engine/post.c90
-rw-r--r--src/xine-engine/post.h22
2 files changed, 109 insertions, 3 deletions
diff --git a/src/xine-engine/post.c b/src/xine-engine/post.c
index 40cb30aab..337cba023 100644
--- a/src/xine-engine/post.c
+++ b/src/xine-engine/post.c
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: post.c,v 1.2 2002/12/03 21:59:46 mroi Exp $
+ * $Id: post.c,v 1.3 2002/12/24 13:36:21 miguelfreitas Exp $
*/
/*
@@ -25,7 +25,7 @@
*/
#include "post.h"
-
+#include <stdarg.h>
/* dummy intercept functions that just pass the call on to the original port */
static uint32_t post_video_get_capabilities(xine_video_port_t *port_gen) {
@@ -166,3 +166,89 @@ void post_restore_video_frame(vo_frame_t *frame, post_video_port_t *port) {
frame->displayed = port->original_frame.displayed;
frame->dispose = port->original_frame.dispose;
}
+
+/* dummy intercept functions that just pass the call on to the original port */
+static uint32_t post_audio_get_capabilities(xine_audio_port_t *port_gen) {
+ post_audio_port_t *port = (post_audio_port_t *)port_gen;
+ return port->original_port->get_capabilities(port->original_port);
+}
+
+static int post_audio_get_property(xine_audio_port_t *port_gen, int property) {
+ post_audio_port_t *port = (post_audio_port_t *)port_gen;
+ return port->original_port->get_property(port->original_port, property);
+}
+
+static int post_audio_set_property(xine_audio_port_t *port_gen, int property, int value) {
+ post_audio_port_t *port = (post_audio_port_t *)port_gen;
+ return port->original_port->set_property(port->original_port, property, value);
+}
+
+static int post_audio_open(xine_audio_port_t *port_gen, xine_stream_t *stream,
+ uint32_t bits, uint32_t rate, int mode) {
+ post_audio_port_t *port = (post_audio_port_t *)port_gen;
+ return port->original_port->open(port->original_port, stream, bits, rate, mode);
+}
+
+static audio_buffer_t * post_audio_get_buffer(xine_audio_port_t *port_gen) {
+ post_audio_port_t *port = (post_audio_port_t *)port_gen;
+ return port->original_port->get_buffer(port->original_port);
+}
+
+static void post_audio_put_buffer(xine_audio_port_t *port_gen, audio_buffer_t *buf,
+ xine_stream_t *stream) {
+ post_audio_port_t *port = (post_audio_port_t *)port_gen;
+ return port->original_port->put_buffer(port->original_port, buf, stream);
+}
+
+static void post_audio_close(xine_audio_port_t *port_gen, xine_stream_t *stream) {
+ post_audio_port_t *port = (post_audio_port_t *)port_gen;
+ return port->original_port->close(port->original_port, stream);
+}
+
+static void post_audio_exit(xine_audio_port_t *port_gen) {
+ post_audio_port_t *port = (post_audio_port_t *)port_gen;
+ return port->original_port->exit(port->original_port);
+}
+
+static int post_audio_control (xine_audio_port_t *port_gen, int cmd, ...) {
+ post_audio_port_t *port = (post_audio_port_t *)port_gen;
+ va_list args;
+ void *arg;
+ int rval;
+
+ va_start(args, cmd);
+ arg = va_arg(args, void*);
+ rval = port->original_port->control(port->original_port, cmd, arg);
+ va_end(args);
+
+ return rval;
+}
+
+static void post_audio_flush(xine_audio_port_t *port_gen) {
+ post_audio_port_t *port = (post_audio_port_t *)port_gen;
+ return port->original_port->flush(port->original_port);
+}
+
+post_audio_port_t *post_intercept_audio_port(xine_audio_port_t *original) {
+ post_audio_port_t *post_port = (post_audio_port_t *)malloc(sizeof(post_audio_port_t));
+
+ if (!post_port)
+ return NULL;
+
+ post_port->port.open = post_audio_open;
+ post_port->port.get_buffer = post_audio_get_buffer;
+ post_port->port.put_buffer = post_audio_put_buffer;
+ post_port->port.close = post_audio_close;
+ post_port->port.exit = post_audio_exit;
+ post_port->port.get_capabilities = post_audio_get_capabilities;
+ post_port->port.get_property = post_audio_get_property;
+ post_port->port.set_property = post_audio_set_property;
+ post_port->port.control = post_audio_control;
+ post_port->port.flush = post_audio_flush;
+ post_port->port.driver = original->driver;
+
+
+ post_port->original_port = original;
+
+ return post_port;
+}
diff --git a/src/xine-engine/post.h b/src/xine-engine/post.h
index 156347dc0..115e96a22 100644
--- a/src/xine-engine/post.h
+++ b/src/xine-engine/post.h
@@ -17,7 +17,7 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: post.h,v 1.2 2002/12/03 21:59:46 mroi Exp $
+ * $Id: post.h,v 1.3 2002/12/24 13:36:21 miguelfreitas Exp $
*
* post plugin definitions
*
@@ -28,6 +28,7 @@
#include "xine.h"
#include "video_out.h"
+#include "audio_out.h"
#include "xineutils.h"
#define POST_PLUGIN_IFACE_VERSION 1
@@ -130,4 +131,23 @@ post_video_port_t *post_intercept_video_port(xine_video_port_t *port);
void post_intercept_video_frame(vo_frame_t *frame, post_video_port_t *port);
void post_restore_video_frame(vo_frame_t *frame, post_video_port_t *port);
+/* helper structure for intercepting audio port calls */
+typedef struct post_audio_port_s post_audio_port_t;
+struct post_audio_port_s {
+
+ /* the new public port with replaced function pointers */
+ xine_audio_port_t port;
+
+ /* the original port to call its functions from inside yours */
+ xine_audio_port_t *original_port;
+
+ /* backward reference so that you have access to the post plugin
+ * when the call only gives you the port */
+ xine_post_t *post;
+};
+
+/* use this to create a new, trivially decorated audio port in which
+ * port functions can be replaced with own implementations */
+post_audio_port_t *post_intercept_audio_port(xine_audio_port_t *port);
+
#endif