LCOV - code coverage report
Current view: top level - gst-plugins-base/gst-libs/gst/interfaces - mixertrack.c (source / functions) Hit Total Coverage
Test: GStreamer Lines: 52 67 77.6 %
Date: 2011-03-25 Functions: 6 6 100.0 %
Branches: 9 17 52.9 %

           Branch data     Line data    Source code
       1                 :            : /* GStreamer Mixer
       2                 :            :  * Copyright (C) 2003 Ronald Bultje <rbultje@ronald.bitfreak.net>
       3                 :            :  *
       4                 :            :  * mixertrack.c: mixer track object design
       5                 :            :  *
       6                 :            :  * This library is free software; you can redistribute it and/or
       7                 :            :  * modify it under the terms of the GNU Library General Public
       8                 :            :  * License as published by the Free Software Foundation; either
       9                 :            :  * version 2 of the License, or (at your option) any later version.
      10                 :            :  *
      11                 :            :  * This library is distributed in the hope that it will be useful,
      12                 :            :  * but WITHOUT ANY WARRANTY; without even the implied warranty of
      13                 :            :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      14                 :            :  * Library General Public License for more details.
      15                 :            :  *
      16                 :            :  * You should have received a copy of the GNU Library General Public
      17                 :            :  * License along with this library; if not, write to the
      18                 :            :  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
      19                 :            :  * Boston, MA 02111-1307, USA.
      20                 :            :  */
      21                 :            : 
      22                 :            : /**
      23                 :            :  * SECTION:gstmixertrack
      24                 :            :  * @short_description: Basic mixer control object (volume slider, switch)
      25                 :            :  * @see_also: GstMixer, GstMixerOptions
      26                 :            :  *
      27                 :            :  * Basic mixer control object (note that it is a GObject and not a GstObject).
      28                 :            :  *
      29                 :            :  * A mixer track represents a single slider control of none, one or more
      30                 :            :  * channels. A mixer track with no channels is usually interpreted as a
      31                 :            :  * on/off switch control.
      32                 :            :  *
      33                 :            :  * Note the presence of both min_volume and max_volume fields. Applications
      34                 :            :  * must not assume that min_volume is 0 or max_volume is any particular
      35                 :            :  * value.
      36                 :            :  */
      37                 :            : 
      38                 :            : #ifdef HAVE_CONFIG_H
      39                 :            : #include "config.h"
      40                 :            : #endif
      41                 :            : 
      42                 :            : #include "mixertrack.h"
      43                 :            : #if 0
      44                 :            : enum
      45                 :            : {
      46                 :            :   /* FILL ME */
      47                 :            :   SIGNAL_VOLUME_CHANGED,
      48                 :            :   SIGNAL_RECORD_TOGGLED,
      49                 :            :   SIGNAL_MUTE_TOGGLED,
      50                 :            :   LAST_SIGNAL
      51                 :            : };
      52                 :            : static guint signals[LAST_SIGNAL] = { 0 };
      53                 :            : #endif
      54                 :            : 
      55                 :            : enum
      56                 :            : {
      57                 :            :   ARG_0,
      58                 :            :   ARG_LABEL,
      59                 :            :   ARG_UNTRANSLATED_LABEL,
      60                 :            :   ARG_INDEX,
      61                 :            :   ARG_MIN_VOLUME,
      62                 :            :   ARG_MAX_VOLUME,
      63                 :            :   ARG_FLAGS,
      64                 :            :   ARG_NUM_CHANNELS
      65                 :            : };
      66                 :            : 
      67                 :            : static void gst_mixer_track_class_init (GstMixerTrackClass * klass);
      68                 :            : static void gst_mixer_track_init (GstMixerTrack * mixer);
      69                 :            : static void gst_mixer_track_dispose (GObject * object);
      70                 :            : 
      71                 :            : static void gst_mixer_track_get_property (GObject * object, guint prop_id,
      72                 :            :     GValue * value, GParamSpec * pspec);
      73                 :            : static void gst_mixer_track_set_property (GObject * object, guint prop_id,
      74                 :            :     const GValue * value, GParamSpec * pspec);
      75                 :            : 
      76                 :            : static GObjectClass *parent_class = NULL;
      77                 :            : 
      78                 :            : GType
      79                 :        632 : gst_mixer_track_get_type (void)
      80                 :            : {
      81                 :            :   static GType gst_mixer_track_type = 0;
      82                 :            : 
      83         [ +  + ]:        632 :   if (!gst_mixer_track_type) {
      84                 :            :     static const GTypeInfo mixer_track_info = {
      85                 :            :       sizeof (GstMixerTrackClass),
      86                 :            :       NULL,
      87                 :            :       NULL,
      88                 :            :       (GClassInitFunc) gst_mixer_track_class_init,
      89                 :            :       NULL,
      90                 :            :       NULL,
      91                 :            :       sizeof (GstMixerTrack),
      92                 :            :       0,
      93                 :            :       (GInstanceInitFunc) gst_mixer_track_init,
      94                 :            :       NULL
      95                 :            :     };
      96                 :            : 
      97                 :         71 :     gst_mixer_track_type =
      98                 :         71 :         g_type_register_static (G_TYPE_OBJECT,
      99                 :            :         "GstMixerTrack", &mixer_track_info, 0);
     100                 :            :   }
     101                 :            : 
     102                 :        632 :   return gst_mixer_track_type;
     103                 :            : }
     104                 :            : 
     105                 :            : static void
     106                 :         69 : gst_mixer_track_class_init (GstMixerTrackClass * klass)
     107                 :            : {
     108                 :         69 :   GObjectClass *object_klass = G_OBJECT_CLASS (klass);
     109                 :            : 
     110                 :         69 :   parent_class = g_type_class_peek_parent (klass);
     111                 :            : 
     112                 :         69 :   object_klass->get_property = gst_mixer_track_get_property;
     113                 :         69 :   object_klass->set_property = gst_mixer_track_set_property;
     114                 :            : 
     115                 :         69 :   g_object_class_install_property (object_klass, ARG_LABEL,
     116                 :            :       g_param_spec_string ("label", "Track label",
     117                 :            :           "The label assigned to the track (may be translated)", NULL,
     118                 :            :           G_PARAM_READABLE | G_PARAM_STATIC_STRINGS | G_PARAM_STATIC_STRINGS));
     119                 :            : 
     120                 :            :   /**
     121                 :            :    * GstMixerTrack:untranslated-label
     122                 :            :    *
     123                 :            :    * The untranslated label of the mixer track, if available. Mixer track
     124                 :            :    * implementations must set this at construct time. Applications may find
     125                 :            :    * this useful to determine icons for various kind of tracks. However,
     126                 :            :    * applications mustn't make any assumptions about the naming of tracks,
     127                 :            :    * the untranslated labels are purely informational and may change.
     128                 :            :    *
     129                 :            :    * Since: 0.10.13
     130                 :            :    **/
     131                 :         69 :   g_object_class_install_property (object_klass, ARG_UNTRANSLATED_LABEL,
     132                 :            :       g_param_spec_string ("untranslated-label", "Untranslated track label",
     133                 :            :           "The untranslated label assigned to the track (since 0.10.13)",
     134                 :            :           NULL,
     135                 :            :           G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
     136                 :            : 
     137                 :            :   /**
     138                 :            :    * GstMixerTrack:index
     139                 :            :    *
     140                 :            :    * Index of the mixer track, if available. Mixer track implementations
     141                 :            :    * must set this at construct time. This can be used to discern between
     142                 :            :    * multiple tracks with identical labels.
     143                 :            :    *
     144                 :            :    * Since: 0.10.21
     145                 :            :    */
     146                 :         69 :   g_object_class_install_property (object_klass, ARG_INDEX,
     147                 :            :       g_param_spec_uint ("index", "Index",
     148                 :            :           "Track index", 0, G_MAXUINT,
     149                 :            :           0, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
     150                 :            : 
     151                 :         69 :   g_object_class_install_property (object_klass, ARG_MIN_VOLUME,
     152                 :            :       g_param_spec_int ("min-volume", "Minimum volume level",
     153                 :            :           "The minimum possible volume level", G_MININT, G_MAXINT,
     154                 :            :           0, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
     155                 :            : 
     156                 :         69 :   g_object_class_install_property (object_klass, ARG_MAX_VOLUME,
     157                 :            :       g_param_spec_int ("max-volume", "Maximum volume level",
     158                 :            :           "The maximum possible volume level", G_MININT, G_MAXINT,
     159                 :            :           0, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
     160                 :            : 
     161                 :         69 :   g_object_class_install_property (object_klass, ARG_FLAGS,
     162                 :            :       g_param_spec_uint ("flags", "Flags",
     163                 :            :           "Flags indicating the type of mixer track",
     164                 :            :           0, G_MAXUINT, 0, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
     165                 :            : 
     166                 :         69 :   g_object_class_install_property (object_klass, ARG_NUM_CHANNELS,
     167                 :            :       g_param_spec_int ("num-channels", "Number of channels",
     168                 :            :           "The number of channels contained within the track",
     169                 :            :           0, G_MAXINT, 0, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
     170                 :            : 
     171                 :            : #if 0
     172                 :            :   signals[SIGNAL_RECORD_TOGGLED] =
     173                 :            :       g_signal_new ("record_toggled", G_TYPE_FROM_CLASS (klass),
     174                 :            :       G_SIGNAL_RUN_LAST,
     175                 :            :       G_STRUCT_OFFSET (GstMixerTrackClass,
     176                 :            :           record_toggled),
     177                 :            :       NULL, NULL, g_cclosure_marshal_VOID__BOOLEAN,
     178                 :            :       G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
     179                 :            :   signals[SIGNAL_MUTE_TOGGLED] =
     180                 :            :       g_signal_new ("mute_toggled", G_TYPE_FROM_CLASS (klass),
     181                 :            :       G_SIGNAL_RUN_LAST,
     182                 :            :       G_STRUCT_OFFSET (GstMixerTrackClass,
     183                 :            :           mute_toggled),
     184                 :            :       NULL, NULL, g_cclosure_marshal_VOID__BOOLEAN,
     185                 :            :       G_TYPE_NONE, 1, G_TYPE_BOOLEAN);
     186                 :            :   signals[SIGNAL_VOLUME_CHANGED] =
     187                 :            :       g_signal_new ("volume_changed", G_TYPE_FROM_CLASS (klass),
     188                 :            :       G_SIGNAL_RUN_LAST,
     189                 :            :       G_STRUCT_OFFSET (GstMixerTrackClass,
     190                 :            :           volume_changed),
     191                 :            :       NULL, NULL, g_cclosure_marshal_VOID__POINTER,
     192                 :            :       G_TYPE_NONE, 1, G_TYPE_POINTER);
     193                 :            : #endif
     194                 :            : 
     195                 :         69 :   object_klass->dispose = gst_mixer_track_dispose;
     196                 :         69 : }
     197                 :            : 
     198                 :            : static void
     199                 :        101 : gst_mixer_track_init (GstMixerTrack * mixer_track)
     200                 :            : {
     201                 :        101 :   mixer_track->label = NULL;
     202                 :        101 :   mixer_track->min_volume = mixer_track->max_volume = 0;
     203                 :        101 :   mixer_track->flags = 0;
     204                 :        101 :   mixer_track->num_channels = 0;
     205                 :        101 : }
     206                 :            : 
     207                 :            : /* FIXME 0.11: move these as members into the mixer track structure */
     208                 :            : #define MIXER_TRACK_OBJECT_DATA_KEY_UNTRANSLATED_LABEL "gst-mixer-track-ulabel"
     209                 :            : #define MIXER_TRACK_OBJECT_DATA_KEY_INDEX "index"
     210                 :            : 
     211                 :            : static void
     212                 :         40 : gst_mixer_track_get_property (GObject * object, guint prop_id, GValue * value,
     213                 :            :     GParamSpec * pspec)
     214                 :            : {
     215                 :            :   GstMixerTrack *mixer_track;
     216                 :            : 
     217                 :         40 :   mixer_track = GST_MIXER_TRACK (object);
     218                 :            : 
     219   [ +  +  -  -  :         40 :   switch (prop_id) {
             -  -  -  - ]
     220                 :            :     case ARG_LABEL:
     221                 :         20 :       g_value_set_string (value, mixer_track->label);
     222                 :         20 :       break;
     223                 :            :     case ARG_UNTRANSLATED_LABEL:
     224                 :         20 :       g_value_set_string (value,
     225                 :         20 :           (const gchar *) g_object_get_data (G_OBJECT (mixer_track),
     226                 :            :               MIXER_TRACK_OBJECT_DATA_KEY_UNTRANSLATED_LABEL));
     227                 :         20 :       break;
     228                 :            :     case ARG_INDEX:
     229                 :          0 :       g_value_set_uint (value,
     230                 :          0 :           GPOINTER_TO_INT (g_object_get_data (G_OBJECT (mixer_track),
     231                 :            :                   MIXER_TRACK_OBJECT_DATA_KEY_INDEX)));
     232                 :          0 :       break;
     233                 :            :     case ARG_MIN_VOLUME:
     234                 :          0 :       g_value_set_int (value, mixer_track->min_volume);
     235                 :          0 :       break;
     236                 :            :     case ARG_MAX_VOLUME:
     237                 :          0 :       g_value_set_int (value, mixer_track->max_volume);
     238                 :          0 :       break;
     239                 :            :     case ARG_FLAGS:
     240                 :          0 :       g_value_set_uint (value, (guint32) mixer_track->flags);
     241                 :          0 :       break;
     242                 :            :     case ARG_NUM_CHANNELS:
     243                 :          0 :       g_value_set_int (value, mixer_track->num_channels);
     244                 :          0 :       break;
     245                 :            :     default:
     246                 :          0 :       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
     247                 :          0 :       break;
     248                 :            :   }
     249                 :         40 : }
     250                 :            : 
     251                 :            : static void
     252                 :        202 : gst_mixer_track_set_property (GObject * object, guint prop_id,
     253                 :            :     const GValue * value, GParamSpec * pspec)
     254                 :            : {
     255                 :            :   GstMixerTrack *mixer_track;
     256                 :            : 
     257                 :        202 :   mixer_track = GST_MIXER_TRACK (object);
     258                 :            : 
     259      [ +  +  - ]:        202 :   switch (prop_id) {
     260                 :            :     case ARG_UNTRANSLATED_LABEL:
     261                 :        101 :       g_object_set_data_full (G_OBJECT (mixer_track),
     262                 :            :           MIXER_TRACK_OBJECT_DATA_KEY_UNTRANSLATED_LABEL,
     263                 :        101 :           g_value_dup_string (value), (GDestroyNotify) g_free);
     264                 :        101 :       break;
     265                 :            :     case ARG_INDEX:
     266                 :        101 :       g_object_set_data (G_OBJECT (mixer_track),
     267                 :            :           MIXER_TRACK_OBJECT_DATA_KEY_INDEX,
     268                 :        101 :           GINT_TO_POINTER (g_value_get_uint (value)));
     269                 :        101 :       break;
     270                 :            :     default:
     271                 :          0 :       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
     272                 :          0 :       break;
     273                 :            :   }
     274                 :        202 : }
     275                 :            : 
     276                 :            : static void
     277                 :        101 : gst_mixer_track_dispose (GObject * object)
     278                 :            : {
     279                 :        101 :   GstMixerTrack *channel = GST_MIXER_TRACK (object);
     280                 :            : 
     281         [ +  + ]:        101 :   if (channel->label) {
     282                 :         99 :     g_free (channel->label);
     283                 :         99 :     channel->label = NULL;
     284                 :            :   }
     285                 :            : 
     286         [ +  - ]:        101 :   if (parent_class->dispose)
     287                 :        101 :     parent_class->dispose (object);
     288                 :        101 : }

Generated by: LCOV version 1.9