marlin r1341 - trunk/marlin



Author: iain
Date: Sat Dec  6 22:46:24 2008
New Revision: 1341
URL: http://svn.gnome.org/viewvc/marlin?rev=1341&view=rev

Log:
Start work for there to be a single jack client throughout the whole
system


Modified:
   trunk/marlin/marlin-program.c
   trunk/marlin/marlin-program.h

Modified: trunk/marlin/marlin-program.c
==============================================================================
--- trunk/marlin/marlin-program.c	(original)
+++ trunk/marlin/marlin-program.c	Sat Dec  6 22:46:24 2008
@@ -25,9 +25,13 @@
 #include <marlin/marlin-program.h>
 #include <marlin/marlin-marshal.h>
 
+#include <marlin/marlin-jack-play.h>
+#include <marlin/marlin-jack-record.h>
+
 enum {
 	NEW_VIEW,
 	CLIPBOARD_CHANGED,
+	JACK_OWNER_CHANGED,
 	LAST_SIGNAL
 };
 
@@ -40,6 +44,13 @@
 struct _MarlinProgramPrivate {
 	MarlinSample *clipboard;
 	char *clipboard_src;
+
+	jack_client_t *client;
+	guint current_owner; /* The current owner of jack */
+	guint owner_count; /* The number of owners */
+
+	MarlinJackPlay *player;
+	MarlinJackRecord *recorder;
 };
 
 static void
@@ -100,12 +111,25 @@
 						   NULL, NULL,
 						   g_cclosure_marshal_VOID__VOID,
 						   G_TYPE_NONE, 0);
+	signals[JACK_OWNER_CHANGED] = g_signal_new ("jack-owner-changed",
+						    G_TYPE_FROM_CLASS (klass),
+						    G_SIGNAL_RUN_FIRST |
+						    G_SIGNAL_NO_RECURSE,
+						    G_STRUCT_OFFSET (MarlinProgramClass, jack_owner_changed),
+						    NULL, NULL,
+						    g_cclosure_marshal_VOID__UINT,
+						    G_TYPE_NONE, 1,
+						    G_TYPE_UINT);
 }
 
 static void
 marlin_program_init (MarlinProgram *program)
 {
-	program->priv = GET_PRIVATE (program);
+	MarlinProgramPrivate *priv;
+
+	priv = program->priv = GET_PRIVATE (program);
+	priv->current_owner = MARLIN_PROGRAM_JACK_UNOWNED;
+	priv->owner_count = 0;
 }
 
 /**
@@ -250,3 +274,43 @@
 {
 	g_signal_emit (G_OBJECT (program), signals[NEW_VIEW], 0, sample);
 }
+
+/**
+ * marlin_program_request_jack_owner_id
+ */
+guint
+marlin_program_request_jack_owner_id (MarlinProgram *program)
+{
+	MarlinProgramPrivate *priv = program->priv;
+
+	return (++priv->owner_count);
+}
+
+void
+marlin_program_acquire_jack (MarlinProgram *program,
+			     guint          owner_id)
+{
+	MarlinProgramPrivate *priv = program->priv;
+
+	if (owner_id == priv->current_owner) {
+		return;
+	}
+
+	priv->current_owner = owner_id;
+	g_signal_emit (program, signals[JACK_OWNER_CHANGED], 0, owner_id);
+}
+
+void
+marlin_program_release_jack (MarlinProgram *program,
+			     guint          owner_id)
+{
+	MarlinProgramPrivate *priv = program->priv;
+
+	if (owner_id != priv->current_owner) {
+		return;
+	}
+
+	priv->current_owner = MARLIN_PROGRAM_JACK_UNOWNED;
+	g_signal_emit (program, signals[JACK_OWNER_CHANGED], 0,
+		       MARLIN_PROGRAM_JACK_UNOWNED);
+}

Modified: trunk/marlin/marlin-program.h
==============================================================================
--- trunk/marlin/marlin-program.h	(original)
+++ trunk/marlin/marlin-program.h	Sat Dec  6 22:46:24 2008
@@ -31,6 +31,8 @@
 #define MARLIN_PROGRAM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MARLIN_PROGRAM_TYPE, MarlinProgram))
 #define MARLIN_PROGRAM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MARLIN_PROGRAM_TYPE, MarlinProgramClass))
 
+#define MARLIN_PROGRAM_JACK_UNOWNED 0
+
 typedef struct _MarlinProgramPrivate MarlinProgramPrivate;
 typedef struct _MarlinProgram {
 	GObject parent;
@@ -44,6 +46,8 @@
 	void (*new_view) (MarlinProgram *program,
 			  MarlinSample *sample);
 	void (*clipboard_changed) (MarlinProgram *program);
+	void (*jack_owner_changed) (MarlinProgram *program,
+				    int            owner_id);
 } MarlinProgramClass;
 
 GType marlin_program_get_type (void);
@@ -60,4 +64,6 @@
 void marlin_program_request_new_view (MarlinProgram *program,
 				      MarlinSample *sample);
 
+int marlin_program_get_jack_owner_id (MarlinProgram *program);
+
 #endif



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]