sys/oss/gstossmixerelement.*: Added mixer element like alsamixer.
authorAndy Wingo <wingo@pobox.com>
Tue, 23 Aug 2005 13:53:17 +0000 (13:53 +0000)
committerAndy Wingo <wingo@pobox.com>
Tue, 23 Aug 2005 13:53:17 +0000 (13:53 +0000)
Original commit message from CVS:
2005-08-23  Andy Wingo  <wingo@pobox.com>

* sys/oss/gstossmixerelement.h:
* sys/oss/gstossmixerelement.c: Added mixer element like
alsamixer.

* sys/oss/Makefile.am:
* sys/oss/gstossaudio.c: Register the ossmixer element.

ChangeLog
sys/oss/Makefile.am
sys/oss/gstossaudio.c
sys/oss/gstossmixer.c
sys/oss/gstossmixerelement.c [new file with mode: 0644]
sys/oss/gstossmixerelement.h [new file with mode: 0644]

index 73bb477..9d3395b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
 2005-08-23  Andy Wingo  <wingo@pobox.com>
 
+       * sys/oss/gstossmixerelement.h:
+       * sys/oss/gstossmixerelement.c: Added mixer element like
+       alsamixer.
+
+       * sys/oss/Makefile.am: 
+       * sys/oss/gstossaudio.c: Register the ossmixer element.
+       
        * sys/oss/gstossmixer.h:
        * sys/oss/gstossmixer.c: Refactored to be more like alsamixer.
 
index d4fc239..9c797cf 100644 (file)
@@ -1,10 +1,11 @@
 plugin_LTLIBRARIES = libgstossaudio.la
 
-libgstossaudio_la_SOURCES = gstossaudio.c      \
-                           gstosshelper.c      \
-                           gstossmixer.c       \
-                           gstossmixertrack.c  \
-                           gstosssink.c        \
+libgstossaudio_la_SOURCES = gstossaudio.c       \
+                           gstosshelper.c       \
+                           gstossmixer.c        \
+                           gstossmixerelement.c \
+                           gstossmixertrack.c   \
+                           gstosssink.c         \
                            gstosssrc.c
 
 #                          gstossdmabuffer.c
@@ -15,11 +16,12 @@ libgstossaudio_la_LIBADD = $(GST_PLUGINS_BASE_LIBS) \
                -lgstaudio-@GST_MAJORMINOR@
 libgstossaudio_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) 
 
-noinst_HEADERS = gstosssink.h    \
-               gstosssrc.h       \
-                gstosshelper.h   \
-               gstossdmabuffer.h \
-               gstossmixer.h     \
+noinst_HEADERS = gstosssink.h       \
+               gstosssrc.h          \
+                gstosshelper.h      \
+               gstossdmabuffer.h    \
+               gstossmixer.h        \
+               gstossmixerelement.h \
                gstossmixertrack.h
 
 # noinst_PROGRAMS = #oss_probe
index 219a036..500cea6 100644 (file)
@@ -23,6 +23,7 @@
 
 #include "gst/gst-i18n-plugin.h"
 
+#include "gstossmixerelement.h"
 #include "gstosssink.h"
 #include "gstosssrc.h"
 
@@ -33,8 +34,8 @@ GST_DEBUG_CATEGORY (oss_debug);
 static gboolean
 plugin_init (GstPlugin * plugin)
 {
-  if (                          /*!gst_element_register (plugin, "ossmixer", GST_RANK_PRIMARY,
-                                   GST_TYPE_OSSELEMENT) || */
+  if (!gst_element_register (plugin, "ossmixer", GST_RANK_NONE,
+          GST_TYPE_OSS_MIXER_ELEMENT) ||
       !gst_element_register (plugin, "osssrc", GST_RANK_PRIMARY,
           GST_TYPE_OSS_SRC) ||
       !gst_element_register (plugin, "osssink", GST_RANK_SECONDARY,
index 1e97256..e199414 100644 (file)
@@ -143,6 +143,7 @@ gst_ossmixer_new (const char *device, GstOssMixerDirection dir)
 
   ret->device = g_strdup (device);
   ret->dir = dir;
+  ret->mixer_fd = -1;
 
   if (!gst_ossmixer_open (ret))
     goto error;
diff --git a/sys/oss/gstossmixerelement.c b/sys/oss/gstossmixerelement.c
new file mode 100644 (file)
index 0000000..28232d6
--- /dev/null
@@ -0,0 +1,92 @@
+/* OSS mixer interface element.
+ * Copyright (C) 2005 Andrew Vander Wingo <wingo@pobox.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "gstossmixerelement.h"
+
+
+static GstElementDetails gst_oss_mixer_element_details =
+GST_ELEMENT_DETAILS ("OSS Mixer",
+    "Generic/Audio",
+    "Control sound input and output levels with OSS",
+    "Andrew Vander Wingo <wingo@pobox.com>");
+
+
+GST_BOILERPLATE_WITH_INTERFACE (GstOssMixerElement, gst_oss_mixer_element,
+    GstElement, GST_TYPE_ELEMENT, GstMixer, GST_TYPE_MIXER,
+    gst_oss_mixer_element);
+
+GST_IMPLEMENT_OSS_MIXER_METHODS (GstOssMixerElement, gst_oss_mixer_element);
+
+static GstElementStateReturn gst_oss_mixer_element_change_state (GstElement *
+    element);
+
+static void
+gst_oss_mixer_element_base_init (gpointer klass)
+{
+  gst_element_class_set_details (GST_ELEMENT_CLASS (klass),
+      &gst_oss_mixer_element_details);
+}
+
+static void
+gst_oss_mixer_element_class_init (GstOssMixerElementClass * klass)
+{
+  GstElementClass *element_class;
+
+  element_class = (GstElementClass *) klass;
+
+  element_class->change_state = gst_oss_mixer_element_change_state;
+}
+
+static void
+gst_oss_mixer_element_init (GstOssMixerElement * this)
+{
+  this->mixer = NULL;
+}
+
+static GstElementStateReturn
+gst_oss_mixer_element_change_state (GstElement * element)
+{
+  GstOssMixerElement *this = GST_OSS_MIXER_ELEMENT (element);
+
+  switch (GST_STATE_TRANSITION (element)) {
+    case GST_STATE_NULL_TO_READY:
+      if (!this->mixer) {
+        this->mixer = gst_ossmixer_new ("/dev/mixer", GST_OSS_MIXER_ALL);
+      }
+      break;
+    case GST_STATE_READY_TO_NULL:
+      if (this->mixer) {
+        gst_ossmixer_free (this->mixer);
+        this->mixer = NULL;
+      }
+      break;
+    default:
+      break;
+  }
+
+  if (GST_ELEMENT_CLASS (parent_class)->change_state)
+    return GST_ELEMENT_CLASS (parent_class)->change_state (element);
+
+  return GST_STATE_SUCCESS;
+}
diff --git a/sys/oss/gstossmixerelement.h b/sys/oss/gstossmixerelement.h
new file mode 100644 (file)
index 0000000..8755c51
--- /dev/null
@@ -0,0 +1,58 @@
+/* OSS mixer interface element.
+ * Copyright (C) 2005 Andrew Vander Wingo <wingo@pobox.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the Free
+ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+
+#ifndef __GST_OSS_MIXER_ELEMENT_H__
+#define __GST_OSS_MIXER_ELEMENT_H__
+
+
+#include "gstossmixer.h"
+
+
+G_BEGIN_DECLS
+
+
+#define GST_OSS_MIXER_ELEMENT(obj)             (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_OSS_MIXER_ELEMENT,GstOssMixerElement))
+#define GST_OSS_MIXER_ELEMENT_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_OSS_MIXER_ELEMENT,GstOssMixerElementClass))
+#define GST_IS_OSS_MIXER_ELEMENT(obj)          (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_OSS_MIXER_ELEMENT))
+#define GST_IS_OSS_MIXER_ELEMENT_CLASS(obj)    (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_OSS_MIXER_ELEMENT))
+#define GST_TYPE_OSS_MIXER_ELEMENT             (gst_oss_mixer_element_get_type())
+
+
+typedef struct _GstOssMixerElement GstOssMixerElement;
+typedef struct _GstOssMixerElementClass GstOssMixerElementClass;
+
+
+struct _GstOssMixerElement {
+  GstElement           parent;
+
+  GstOssMixer          *mixer;
+};
+
+struct _GstOssMixerElementClass {
+  GstElementClass      parent;
+};
+
+
+GType          gst_oss_mixer_element_get_type          (void);
+
+
+G_END_DECLS
+
+
+#endif /* __GST_OSS_MIXER_ELEMENT_H__ */