ext/alsa/gstalsamixer.c: Setting mixer interface type to HARDWARE.
authorJulien Moutte <julien@moutte.net>
Thu, 15 Jan 2004 15:50:10 +0000 (15:50 +0000)
committerJulien Moutte <julien@moutte.net>
Thu, 15 Jan 2004 15:50:10 +0000 (15:50 +0000)
Original commit message from CVS:
2004-01-15  Julien MOUTTE <julien@moutte.net>

* ext/alsa/gstalsamixer.c: (gst_alsa_mixer_interface_init): Setting
mixer interface type to HARDWARE.
* gst-libs/gst/mixer/mixer.c: (gst_mixer_class_init): Adding a default
type to SOFTWARE.
* gst-libs/gst/mixer/mixer.h: Adding mixer interface type and macro.
* gst-libs/gst/mixer/mixertrack.h: Adding mixertrack flag SOFTWARE.
* gst/volume/gstvolume.c: (gst_volume_interface_supported),
(gst_volume_interface_init), (gst_volume_list_tracks),
(gst_volume_set_volume), (gst_volume_get_volume),
(gst_volume_set_mute), (gst_volume_mixer_init),
(gst_volume_dispose), (gst_volume_get_type), (volume_class_init),
(volume_init): Implementing mixer interface.
* gst/volume/gstvolume.h: Adding tracklist for mixer interface.
* sys/oss/gstosselement.c: (gst_osselement_get_type),
(gst_osselement_change_state): Removing some trailing commas in
structures.
* sys/oss/gstossmixer.c: (gst_ossmixer_interface_init): Setting mixer
interface type to HARDWARE.
* sys/v4l/gstv4lcolorbalance.c:
(gst_v4l_color_balance_interface_init): Setting colorbalance interface
type to HARDWARE.
* sys/v4l2/gstv4l2colorbalance.c:
(gst_v4l2_color_balance_interface_init): Setting colorbalance
interface type to HARDWARE.
* sys/xvimage/xvimagesink.c: (gst_xvimagesink_chain): use exactly the
same code than ximagesink for event handling.

12 files changed:
ChangeLog
ext/alsa/gstalsamixer.c
gst-libs/gst/interfaces/mixer.c
gst-libs/gst/interfaces/mixer.h
gst-libs/gst/interfaces/mixertrack.h
gst-libs/gst/mixer/mixer.c
gst-libs/gst/mixer/mixer.h
gst-libs/gst/mixer/mixertrack.h
gst/volume/gstvolume.c
gst/volume/gstvolume.h
sys/v4l/gstv4lcolorbalance.c
sys/xvimage/xvimagesink.c

index 7c4084d35005c4aa12007369fbea9de3fc13bc22..c5dbb53d7e95fbb4063ea686dc6bcd1c058225e8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,32 @@
+2004-01-15  Julien MOUTTE <julien@moutte.net>
+
+       * ext/alsa/gstalsamixer.c: (gst_alsa_mixer_interface_init): Setting
+       mixer interface type to HARDWARE.
+       * gst-libs/gst/mixer/mixer.c: (gst_mixer_class_init): Adding a default
+       type to SOFTWARE.
+       * gst-libs/gst/mixer/mixer.h: Adding mixer interface type and macro.
+       * gst-libs/gst/mixer/mixertrack.h: Adding mixertrack flag SOFTWARE.
+       * gst/volume/gstvolume.c: (gst_volume_interface_supported),
+       (gst_volume_interface_init), (gst_volume_list_tracks),
+       (gst_volume_set_volume), (gst_volume_get_volume),
+       (gst_volume_set_mute), (gst_volume_mixer_init),
+       (gst_volume_dispose), (gst_volume_get_type), (volume_class_init),
+       (volume_init): Implementing mixer interface.
+       * gst/volume/gstvolume.h: Adding tracklist for mixer interface.
+       * sys/oss/gstosselement.c: (gst_osselement_get_type),
+       (gst_osselement_change_state): Removing some trailing commas in
+       structures.
+       * sys/oss/gstossmixer.c: (gst_ossmixer_interface_init): Setting mixer
+       interface type to HARDWARE.
+       * sys/v4l/gstv4lcolorbalance.c:
+       (gst_v4l_color_balance_interface_init): Setting colorbalance interface
+       type to HARDWARE.
+       * sys/v4l2/gstv4l2colorbalance.c:
+       (gst_v4l2_color_balance_interface_init): Setting colorbalance
+       interface type to HARDWARE.
+       * sys/xvimage/xvimagesink.c: (gst_xvimagesink_chain): use exactly the
+       same code than ximagesink for event handling.
+
 2004-01-15  Ronald Bultje  <rbultje@ronald.bitfreak.net>
 
        * ext/snapshot/Makefile.am:
index a9d71bf03bfe98144c030d4b29b5d86292557514..e218e398312b46d4127004957fb0a91c18ec6c49 100644 (file)
@@ -188,6 +188,8 @@ gst_alsa_interface_init (GstImplementsInterfaceClass *klass)
 static void
 gst_alsa_mixer_interface_init (GstMixerClass *klass)
 {
+  GST_MIXER_TYPE (klass) = GST_MIXER_HARDWARE;
+  
   /* set up the interface hooks */
   klass->list_tracks = gst_alsa_mixer_list_tracks;
   klass->set_volume = gst_alsa_mixer_set_volume;
index cbdfdad4a746f87172f6ec820fc73afc0c965dc0..7412ca288f5cd3ecd06f18e241569971e59779a4 100644 (file)
@@ -96,6 +96,8 @@ gst_mixer_class_init (GstMixerClass *klass)
     initialized = TRUE;
   }
 
+  klass->mixer_type = GST_MIXER_SOFTWARE;
+  
   /* default virtual functions */
   klass->list_tracks = NULL;
   klass->set_volume = NULL;
index cfc168754d87eb1295546bcf4f7dffef17b88ef6..3af55ab771a32ffcb997da448dc43b5a25313e53 100644 (file)
@@ -40,11 +40,21 @@ G_BEGIN_DECLS
 #define GST_MIXER_GET_CLASS(inst) \
   (G_TYPE_INSTANCE_GET_INTERFACE ((inst), GST_TYPE_MIXER, GstMixerClass))
 
+#define GST_MIXER_TYPE(klass) (klass->mixer_type)
+
 typedef struct _GstMixer GstMixer;
 
+typedef enum
+{
+  GST_MIXER_HARDWARE,
+  GST_MIXER_SOFTWARE
+} GstMixerType;
+
 typedef struct _GstMixerClass {
   GTypeInterface klass;
 
+  GstMixerType mixer_type;
+  
   /* virtual functions */
   const GList *  (* list_tracks)   (GstMixer      *mixer);
 
index 94304cf2553a8a3f812fb01530cd1c2f8aba2ba3..0e05d9cba0ac97d0a7410d34767534e2222a5236 100644 (file)
@@ -60,7 +60,8 @@ typedef enum {
   GST_MIXER_TRACK_OUTPUT = (1<<1),
   GST_MIXER_TRACK_MUTE   = (1<<2),
   GST_MIXER_TRACK_RECORD = (1<<3),
-  GST_MIXER_TRACK_MASTER = (1<<4)
+  GST_MIXER_TRACK_MASTER = (1<<4),
+  GST_MIXER_TRACK_SOFTWARE = (1<<5)
 } GstMixerTrackFlags;
 
 #define GST_MIXER_TRACK_HAS_FLAG(channel, flag) \
index cbdfdad4a746f87172f6ec820fc73afc0c965dc0..7412ca288f5cd3ecd06f18e241569971e59779a4 100644 (file)
@@ -96,6 +96,8 @@ gst_mixer_class_init (GstMixerClass *klass)
     initialized = TRUE;
   }
 
+  klass->mixer_type = GST_MIXER_SOFTWARE;
+  
   /* default virtual functions */
   klass->list_tracks = NULL;
   klass->set_volume = NULL;
index cfc168754d87eb1295546bcf4f7dffef17b88ef6..3af55ab771a32ffcb997da448dc43b5a25313e53 100644 (file)
@@ -40,11 +40,21 @@ G_BEGIN_DECLS
 #define GST_MIXER_GET_CLASS(inst) \
   (G_TYPE_INSTANCE_GET_INTERFACE ((inst), GST_TYPE_MIXER, GstMixerClass))
 
+#define GST_MIXER_TYPE(klass) (klass->mixer_type)
+
 typedef struct _GstMixer GstMixer;
 
+typedef enum
+{
+  GST_MIXER_HARDWARE,
+  GST_MIXER_SOFTWARE
+} GstMixerType;
+
 typedef struct _GstMixerClass {
   GTypeInterface klass;
 
+  GstMixerType mixer_type;
+  
   /* virtual functions */
   const GList *  (* list_tracks)   (GstMixer      *mixer);
 
index 94304cf2553a8a3f812fb01530cd1c2f8aba2ba3..0e05d9cba0ac97d0a7410d34767534e2222a5236 100644 (file)
@@ -60,7 +60,8 @@ typedef enum {
   GST_MIXER_TRACK_OUTPUT = (1<<1),
   GST_MIXER_TRACK_MUTE   = (1<<2),
   GST_MIXER_TRACK_RECORD = (1<<3),
-  GST_MIXER_TRACK_MASTER = (1<<4)
+  GST_MIXER_TRACK_MASTER = (1<<4),
+  GST_MIXER_TRACK_SOFTWARE = (1<<5)
 } GstMixerTrackFlags;
 
 #define GST_MIXER_TRACK_HAS_FLAG(channel, flag) \
index 4dbbaab4d31da05913070f109529851237ce9604..e3e25ea6d6451e895f79782abed06dd4468bec7a 100644 (file)
@@ -25,6 +25,7 @@
 #include <gst/gst.h>
 #include <gst/audio/audio.h>
 #include <gst/control/control.h>
+#include <gst/mixer/mixer.h>
 #include "gstvolume.h"
 
 
@@ -108,9 +109,125 @@ static gboolean           volume_parse_caps          (GstVolume *filter, GstStructure *st
 static void            volume_chain_float         (GstPad *pad, GstData *_data);
 static void            volume_chain_int16         (GstPad *pad, GstData *_data);
 
+static void gst_volume_interface_init (GstImplementsInterfaceClass *klass);
+static void gst_volume_mixer_init (GstMixerClass *iface);
+
 static GstElementClass *parent_class = NULL;
 /*static guint gst_filter_signals[LAST_SIGNAL] = { 0 }; */
 
+static gboolean
+gst_volume_interface_supported (GstImplementsInterface *iface, GType type)
+{
+  g_assert (type == GST_TYPE_MIXER);
+  return TRUE;
+}
+
+static void
+gst_volume_interface_init (GstImplementsInterfaceClass *klass)
+{
+  klass->supported = gst_volume_interface_supported;
+}
+
+static const GList *
+gst_volume_list_tracks (GstMixer *mixer)
+{
+  GstVolume *filter = GST_VOLUME (mixer);
+  
+  g_return_val_if_fail (filter != NULL, NULL);
+  g_return_val_if_fail (GST_IS_VOLUME (filter), NULL);
+  
+  return filter->tracklist;
+}
+
+static void
+gst_volume_set_volume (GstMixer *mixer, GstMixerTrack *track,
+                       gint *volumes)
+{
+  GstVolume *filter = GST_VOLUME (mixer);
+  
+  g_return_if_fail (filter != NULL);
+  g_return_if_fail (GST_IS_VOLUME (filter));
+  
+  gst_dpman_bypass_dparam (filter->dpman, "volume");
+  
+  filter->volume_f       = (gfloat) volumes[0] / 10;
+  filter->volume_i       = filter->volume_f * 8192;
+  
+  if (filter->mute) {
+    filter->real_vol_f = 0.0;
+    filter->real_vol_i = 0;
+  }
+  else {
+    filter->real_vol_f = filter->volume_f;
+    filter->real_vol_i = filter->volume_i;
+  }
+}
+
+static void
+gst_volume_get_volume (GstMixer *mixer, GstMixerTrack *track,
+                       gint *volumes)
+{
+  GstVolume *filter = GST_VOLUME (mixer);
+  
+  g_return_if_fail (filter != NULL);
+  g_return_if_fail (GST_IS_VOLUME (filter));
+  
+  volumes[0] = (gint) filter->volume_f * 10;
+}
+
+static void
+gst_volume_set_mute (GstMixer *mixer, GstMixerTrack *track,
+                     gboolean mute)
+{
+  GstVolume *filter = GST_VOLUME (mixer);
+  
+  g_return_if_fail (filter != NULL);
+  g_return_if_fail (GST_IS_VOLUME (filter));
+  
+  gst_dpman_bypass_dparam (filter->dpman, "volume");
+  
+  filter->mute = mute;
+  
+  if (filter->mute) {
+    filter->real_vol_f = 0.0;
+    filter->real_vol_i = 0;
+  }
+  else {
+    filter->real_vol_f = filter->volume_f;
+    filter->real_vol_i = filter->volume_i;
+  }
+}
+
+static void
+gst_volume_mixer_init (GstMixerClass *klass)
+{
+  GST_MIXER_TYPE (klass) = GST_MIXER_SOFTWARE;
+  
+  /* default virtual functions */
+  klass->list_tracks = gst_volume_list_tracks;
+  klass->set_volume = gst_volume_set_volume;
+  klass->get_volume = gst_volume_get_volume;
+  klass->set_mute = gst_volume_set_mute;
+}
+
+static void
+gst_volume_dispose (GObject *object)
+{
+  GstVolume *volume;
+
+  volume = GST_VOLUME (object);
+  
+  if (volume->tracklist)
+    {
+      if (volume->tracklist->data)
+        g_object_unref (volume->tracklist->data);
+      g_list_free (volume->tracklist);
+      volume->tracklist = NULL;
+    }
+    
+  G_OBJECT_CLASS (parent_class)->dispose (object);
+}
+
 static GstPadLinkReturn
 volume_connect (GstPad *pad, const GstCaps *caps)
 {
@@ -178,9 +295,26 @@ gst_volume_get_type(void) {
       NULL,
       sizeof(GstVolume),
       0,
-      (GInstanceInitFunc)volume_init,
+      (GInstanceInitFunc)volume_init
+    };
+    static const GInterfaceInfo voliface_info = {
+      (GInterfaceInitFunc) gst_volume_interface_init,
+      NULL,
+      NULL
+    };
+    static const GInterfaceInfo volmixer_info = {
+      (GInterfaceInitFunc) gst_volume_mixer_init,
+      NULL,
+      NULL
     };
+    
     volume_type = g_type_register_static(GST_TYPE_ELEMENT, "GstVolume", &volume_info, 0);
+    g_type_add_interface_static (volume_type,
+                                 GST_TYPE_IMPLEMENTS_INTERFACE,
+                                 &voliface_info);
+    g_type_add_interface_static (volume_type,
+                                 GST_TYPE_MIXER,
+                                 &volmixer_info);
   }
   return volume_type;
 }
@@ -216,28 +350,35 @@ volume_class_init (GstVolumeClass *klass)
   
   gobject_class->set_property = volume_set_property;
   gobject_class->get_property = volume_get_property;
+  gobject_class->dispose = gst_volume_dispose;
 }
 
 static void
 volume_init (GstVolume *filter)
 {
-  filter->sinkpad = gst_pad_new_from_template(
-      gst_static_pad_template_get (&volume_sink_factory),"sink");
+  GstMixerTrack *track = NULL;
+  
+  filter->sinkpad = gst_pad_new_from_template (
+      gst_static_pad_template_get (&volume_sink_factory), "sink");
   gst_pad_set_getcaps_function (filter->sinkpad, gst_pad_proxy_getcaps);
-  gst_pad_set_link_function(filter->sinkpad,volume_connect);
-  filter->srcpad = gst_pad_new_from_template(
-      gst_static_pad_template_get (&volume_src_factory),"src");
+  gst_pad_set_link_function (filter->sinkpad, volume_connect);
+  
+  filter->srcpad = gst_pad_new_from_template (
+      gst_static_pad_template_get (&volume_src_factory), "src");
   gst_pad_set_getcaps_function (filter->srcpad, gst_pad_proxy_getcaps);
   gst_pad_set_link_function(filter->srcpad,volume_connect);
   
-  gst_element_add_pad(GST_ELEMENT(filter),filter->sinkpad);
-  gst_element_add_pad(GST_ELEMENT(filter),filter->srcpad);
-  gst_pad_set_chain_function(filter->sinkpad,volume_chain_int16);
+  gst_element_add_pad (GST_ELEMENT (filter), filter->sinkpad);
+  gst_element_add_pad (GST_ELEMENT (filter), filter->srcpad);
+  
+  gst_pad_set_chain_function (filter->sinkpad, volume_chain_int16);
+  
   filter->mute = FALSE;
   filter->volume_i = 8192;
   filter->volume_f = 1.0;
   filter->real_vol_i = 8192;
   filter->real_vol_f = 1.0;
+  filter->tracklist = NULL;
 
   filter->dpman = gst_dpman_new ("volume_dpman", GST_ELEMENT(filter));
   gst_dpman_add_required_dparam_callback (
@@ -256,7 +397,18 @@ volume_init (GstVolume *filter)
     volume_update_volume, 
     filter
   );
-
+  
+  track = g_object_new (GST_TYPE_MIXER_TRACK, NULL);
+  
+  if (GST_IS_MIXER_TRACK (track))
+    {
+      track->label = g_strdup ("volume");
+      track->num_channels = 1;
+      track->min_volume = 0;
+      track->max_volume = 40;
+      track->flags = GST_MIXER_TRACK_SOFTWARE;
+      filter->tracklist = g_list_append (filter->tracklist, track);
+    }
 }
 
 static void
index ed0468f77b7627255e27ea498993f8d2063f0bfb..5bfdb4e547b7bc229c26c54116a09db9467130ab 100644 (file)
@@ -61,6 +61,8 @@ struct _GstVolume {
   gboolean mute;
   gint   volume_i, real_vol_i;
   gfloat volume_f, real_vol_f;
+  
+  GList *tracklist;
 };
 
 struct _GstVolumeClass {
index 6e2346cd2dffa0ad5566b42fee495fbe5d205808..05555590f72fa66e686bb1edeba6cec81175da22 100644 (file)
@@ -87,6 +87,8 @@ gst_v4l_color_balance_channel_init (GstV4lColorBalanceChannel *channel)
 void
 gst_v4l_color_balance_interface_init (GstColorBalanceClass *klass)
 {
+  GST_COLOR_BALANCE_TYPE (klass) = GST_COLOR_BALANCE_HARDWARE;
+  
   /* default virtual functions */
   klass->list_channels = gst_v4l_color_balance_list_channels;
   klass->set_value = gst_v4l_color_balance_set_value;
index 337d209ea6259685e19a55f69d43d71c27769d22..e774417ee123619337dbdef16c33db93659b09a9 100644 (file)
@@ -921,9 +921,7 @@ gst_xvimagesink_chain (GstPad *pad, GstData *data)
     
   if (GST_IS_EVENT (data))
     {
-      GstEvent *event = GST_EVENT (data);
-      
-      gst_pad_event_default (pad, event);
+      gst_pad_event_default (pad, GST_EVENT (data));
       return;
     }