2001-12-22 23:27:17 +00:00
|
|
|
/* -*- c-basic-offset: 2 -*-
|
|
|
|
* GStreamer
|
|
|
|
* Copyright (C) 1999-2001 Erik Walthinsen <omega@cse.ogi.edu>
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2003-06-29 19:46:12 +00:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
2001-12-22 23:27:17 +00:00
|
|
|
#include <string.h>
|
|
|
|
#include <gst/gst.h>
|
2001-12-23 12:18:18 +00:00
|
|
|
#include <gst/audio/audio.h>
|
2002-04-28 16:07:41 +00:00
|
|
|
#include <gst/control/control.h>
|
ext/alsa/gstalsamixer.c: Setting mixer interface type to HARDWARE.
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.
2004-01-15 15:50:10 +00:00
|
|
|
#include <gst/mixer/mixer.h>
|
2001-12-22 23:27:17 +00:00
|
|
|
#include "gstvolume.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static GstElementDetails volume_details = {
|
|
|
|
"Volume",
|
2003-11-16 22:02:21 +00:00
|
|
|
"Filter/Effect/Audio",
|
2001-12-22 23:27:17 +00:00
|
|
|
"Set volume on audio/raw streams",
|
|
|
|
"Andy Wingo <apwingo@eos.ncsu.edu>",
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/* Filter signals and args */
|
|
|
|
enum {
|
|
|
|
/* FILL ME */
|
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
ARG_0,
|
|
|
|
ARG_SILENT,
|
2002-04-28 16:07:41 +00:00
|
|
|
ARG_MUTE,
|
2001-12-22 23:27:17 +00:00
|
|
|
ARG_VOLUME
|
|
|
|
};
|
|
|
|
|
2003-12-22 01:47:09 +00:00
|
|
|
static GstStaticPadTemplate volume_sink_factory =
|
|
|
|
GST_STATIC_PAD_TEMPLATE (
|
2002-04-28 16:07:41 +00:00
|
|
|
"sink",
|
|
|
|
GST_PAD_SINK,
|
|
|
|
GST_PAD_ALWAYS,
|
2003-12-22 01:47:09 +00:00
|
|
|
GST_STATIC_CAPS (
|
2003-12-22 21:06:03 +00:00
|
|
|
"audio/x-raw-float, "
|
|
|
|
"rate = (int) [ 1, MAX ], "
|
|
|
|
"channels = (int) [ 1, MAX ], "
|
|
|
|
"endianness = (int) BYTE_ORDER, "
|
|
|
|
"width = (int) 32, "
|
|
|
|
"buffer-frames = (int) [ 1, MAX]; "
|
|
|
|
"audio/x-raw-int, "
|
|
|
|
"channels = (int) [ 1, MAX ], "
|
|
|
|
"rate = (int) [ 1, MAX ], "
|
|
|
|
"endianness = (int) BYTE_ORDER, "
|
|
|
|
"width = (int) 16, "
|
|
|
|
"depth = (int) 16, "
|
|
|
|
"signed = (bool) TRUE"
|
2002-04-28 16:07:41 +00:00
|
|
|
)
|
|
|
|
);
|
|
|
|
|
2003-12-22 01:47:09 +00:00
|
|
|
static GstStaticPadTemplate volume_src_factory =
|
|
|
|
GST_STATIC_PAD_TEMPLATE (
|
2002-04-28 16:07:41 +00:00
|
|
|
"src",
|
|
|
|
GST_PAD_SRC,
|
|
|
|
GST_PAD_ALWAYS,
|
2003-12-22 01:47:09 +00:00
|
|
|
GST_STATIC_CAPS (
|
2003-12-22 21:06:03 +00:00
|
|
|
"audio/x-raw-float, "
|
|
|
|
"rate = (int) [ 1, MAX ], "
|
|
|
|
"channels = (int) [ 1, MAX ], "
|
|
|
|
"endianness = (int) BYTE_ORDER, "
|
|
|
|
"width = (int) 32, "
|
|
|
|
"buffer-frames = (int) [ 1, MAX]; "
|
|
|
|
"audio/x-raw-int, "
|
|
|
|
"channels = (int) [ 1, MAX ], "
|
|
|
|
"rate = (int) [ 1, MAX ], "
|
|
|
|
"endianness = (int) BYTE_ORDER, "
|
|
|
|
"width = (int) 16, "
|
|
|
|
"depth = (int) 16, "
|
|
|
|
"signed = (bool) TRUE"
|
2002-04-28 16:07:41 +00:00
|
|
|
)
|
|
|
|
);
|
2001-12-22 23:27:17 +00:00
|
|
|
|
2003-10-31 20:03:29 +00:00
|
|
|
static void volume_base_init (gpointer g_class);
|
|
|
|
static void volume_class_init (GstVolumeClass *klass);
|
2001-12-22 23:27:17 +00:00
|
|
|
static void volume_init (GstVolume *filter);
|
|
|
|
|
|
|
|
static void volume_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec);
|
2002-04-28 16:07:41 +00:00
|
|
|
static void volume_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec);
|
|
|
|
static void volume_update_volume (const GValue *value, gpointer data);
|
|
|
|
static void volume_update_mute (const GValue *value, gpointer data);
|
2001-12-22 23:27:17 +00:00
|
|
|
|
2003-12-22 21:06:03 +00:00
|
|
|
static gboolean volume_parse_caps (GstVolume *filter, GstStructure *structure);
|
2001-12-22 23:27:17 +00:00
|
|
|
|
2003-10-08 16:08:22 +00:00
|
|
|
static void volume_chain_float (GstPad *pad, GstData *_data);
|
|
|
|
static void volume_chain_int16 (GstPad *pad, GstData *_data);
|
2001-12-22 23:27:17 +00:00
|
|
|
|
ext/alsa/gstalsamixer.c: Setting mixer interface type to HARDWARE.
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.
2004-01-15 15:50:10 +00:00
|
|
|
static void gst_volume_interface_init (GstImplementsInterfaceClass *klass);
|
|
|
|
static void gst_volume_mixer_init (GstMixerClass *iface);
|
|
|
|
|
2001-12-22 23:27:17 +00:00
|
|
|
static GstElementClass *parent_class = NULL;
|
2002-03-19 04:10:06 +00:00
|
|
|
/*static guint gst_filter_signals[LAST_SIGNAL] = { 0 }; */
|
2001-12-22 23:27:17 +00:00
|
|
|
|
ext/alsa/gstalsamixer.c: Setting mixer interface type to HARDWARE.
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.
2004-01-15 15:50:10 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2003-01-10 13:38:32 +00:00
|
|
|
static GstPadLinkReturn
|
2003-12-22 21:06:03 +00:00
|
|
|
volume_connect (GstPad *pad, const GstCaps *caps)
|
2001-12-22 23:27:17 +00:00
|
|
|
{
|
2002-02-17 02:06:04 +00:00
|
|
|
GstVolume *filter;
|
2002-02-19 05:59:06 +00:00
|
|
|
GstPad *otherpad;
|
2002-05-29 18:56:23 +00:00
|
|
|
gint rate;
|
2004-01-02 07:25:10 +00:00
|
|
|
GstPadLinkReturn link_ret;
|
2003-12-22 21:06:03 +00:00
|
|
|
GstStructure *structure;
|
2001-12-22 23:27:17 +00:00
|
|
|
|
2002-02-17 02:06:04 +00:00
|
|
|
filter = GST_VOLUME (gst_pad_get_parent (pad));
|
2003-01-10 10:22:25 +00:00
|
|
|
g_return_val_if_fail (GST_IS_VOLUME (filter), GST_PAD_LINK_REFUSED);
|
2002-02-19 05:59:06 +00:00
|
|
|
otherpad = (pad == filter->srcpad ? filter->sinkpad : filter->srcpad);
|
2004-01-02 07:25:10 +00:00
|
|
|
|
2003-12-22 21:06:03 +00:00
|
|
|
structure = gst_caps_get_structure (caps, 0);
|
2004-01-02 07:25:10 +00:00
|
|
|
gst_structure_get_int (structure, "rate", &rate);
|
2002-02-19 05:59:06 +00:00
|
|
|
|
2004-01-02 07:25:10 +00:00
|
|
|
link_ret = gst_pad_try_set_caps (otherpad, caps);
|
|
|
|
if (GST_PAD_LINK_FAILED (link_ret)){
|
|
|
|
return link_ret;
|
|
|
|
}
|
|
|
|
|
2003-12-22 21:06:03 +00:00
|
|
|
if (!volume_parse_caps (filter, structure))
|
|
|
|
return GST_PAD_LINK_REFUSED;
|
|
|
|
|
2004-01-02 07:25:10 +00:00
|
|
|
gst_dpman_set_rate(filter->dpman, rate);
|
|
|
|
|
|
|
|
return GST_PAD_LINK_OK;
|
2001-12-22 23:27:17 +00:00
|
|
|
}
|
|
|
|
|
2002-02-17 02:06:04 +00:00
|
|
|
static gboolean
|
2003-12-22 21:06:03 +00:00
|
|
|
volume_parse_caps (GstVolume *filter, GstStructure *structure)
|
2001-12-22 23:27:17 +00:00
|
|
|
{
|
2003-07-06 20:49:52 +00:00
|
|
|
const gchar *mimetype;
|
2001-12-22 23:27:17 +00:00
|
|
|
|
2002-04-28 16:07:41 +00:00
|
|
|
g_return_val_if_fail(filter!=NULL,FALSE);
|
2003-12-22 21:06:03 +00:00
|
|
|
g_return_val_if_fail(structure!=NULL,FALSE);
|
|
|
|
|
|
|
|
mimetype = gst_structure_get_name (structure);
|
2001-12-22 23:27:17 +00:00
|
|
|
|
2003-07-06 20:49:52 +00:00
|
|
|
if (strcmp(mimetype, "audio/x-raw-int")==0) {
|
2002-04-28 16:07:41 +00:00
|
|
|
gst_pad_set_chain_function(filter->sinkpad,volume_chain_int16);
|
|
|
|
return TRUE;
|
2001-12-22 23:27:17 +00:00
|
|
|
}
|
2002-04-28 16:07:41 +00:00
|
|
|
|
2003-07-06 20:49:52 +00:00
|
|
|
if (strcmp(mimetype, "audio/x-raw-float")==0) {
|
2002-04-28 16:07:41 +00:00
|
|
|
gst_pad_set_chain_function(filter->sinkpad,volume_chain_float);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
2001-12-22 23:27:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
GType
|
|
|
|
gst_volume_get_type(void) {
|
|
|
|
static GType volume_type = 0;
|
|
|
|
|
|
|
|
if (!volume_type) {
|
|
|
|
static const GTypeInfo volume_info = {
|
2003-10-31 20:03:29 +00:00
|
|
|
sizeof(GstVolumeClass),
|
|
|
|
volume_base_init,
|
2001-12-22 23:27:17 +00:00
|
|
|
NULL,
|
|
|
|
(GClassInitFunc)volume_class_init,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
sizeof(GstVolume),
|
|
|
|
0,
|
ext/alsa/gstalsamixer.c: Setting mixer interface type to HARDWARE.
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.
2004-01-15 15:50:10 +00:00
|
|
|
(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
|
2001-12-22 23:27:17 +00:00
|
|
|
};
|
ext/alsa/gstalsamixer.c: Setting mixer interface type to HARDWARE.
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.
2004-01-15 15:50:10 +00:00
|
|
|
|
2001-12-22 23:27:17 +00:00
|
|
|
volume_type = g_type_register_static(GST_TYPE_ELEMENT, "GstVolume", &volume_info, 0);
|
ext/alsa/gstalsamixer.c: Setting mixer interface type to HARDWARE.
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.
2004-01-15 15:50:10 +00:00
|
|
|
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);
|
2001-12-22 23:27:17 +00:00
|
|
|
}
|
|
|
|
return volume_type;
|
|
|
|
}
|
2003-10-31 20:03:29 +00:00
|
|
|
static void
|
|
|
|
volume_base_init (gpointer g_class)
|
|
|
|
{
|
|
|
|
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
|
|
|
|
|
2003-12-22 21:06:03 +00:00
|
|
|
gst_element_class_add_pad_template (element_class,
|
|
|
|
gst_static_pad_template_get (&volume_src_factory));
|
|
|
|
gst_element_class_add_pad_template (element_class,
|
|
|
|
gst_static_pad_template_get (&volume_sink_factory));
|
2003-10-31 20:03:29 +00:00
|
|
|
gst_element_class_set_details (element_class, &volume_details);
|
|
|
|
}
|
2001-12-22 23:27:17 +00:00
|
|
|
static void
|
|
|
|
volume_class_init (GstVolumeClass *klass)
|
|
|
|
{
|
|
|
|
GObjectClass *gobject_class;
|
|
|
|
GstElementClass *gstelement_class;
|
|
|
|
|
|
|
|
gobject_class = (GObjectClass*)klass;
|
|
|
|
gstelement_class = (GstElementClass*)klass;
|
|
|
|
|
|
|
|
parent_class = g_type_class_ref(GST_TYPE_ELEMENT);
|
|
|
|
|
2002-04-28 16:07:41 +00:00
|
|
|
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_MUTE,
|
|
|
|
g_param_spec_boolean("mute","mute","mute",
|
2001-12-22 23:27:17 +00:00
|
|
|
FALSE,G_PARAM_READWRITE));
|
|
|
|
|
|
|
|
g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_VOLUME,
|
|
|
|
g_param_spec_float("volume","volume","volume",
|
2002-05-05 15:42:48 +00:00
|
|
|
0.0,4.0,1.0,G_PARAM_READWRITE));
|
2001-12-22 23:27:17 +00:00
|
|
|
|
|
|
|
gobject_class->set_property = volume_set_property;
|
|
|
|
gobject_class->get_property = volume_get_property;
|
ext/alsa/gstalsamixer.c: Setting mixer interface type to HARDWARE.
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.
2004-01-15 15:50:10 +00:00
|
|
|
gobject_class->dispose = gst_volume_dispose;
|
2001-12-22 23:27:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
volume_init (GstVolume *filter)
|
|
|
|
{
|
ext/alsa/gstalsamixer.c: Setting mixer interface type to HARDWARE.
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.
2004-01-15 15:50:10 +00:00
|
|
|
GstMixerTrack *track = NULL;
|
|
|
|
|
|
|
|
filter->sinkpad = gst_pad_new_from_template (
|
|
|
|
gst_static_pad_template_get (&volume_sink_factory), "sink");
|
2003-12-24 03:31:06 +00:00
|
|
|
gst_pad_set_getcaps_function (filter->sinkpad, gst_pad_proxy_getcaps);
|
ext/alsa/gstalsamixer.c: Setting mixer interface type to HARDWARE.
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.
2004-01-15 15:50:10 +00:00
|
|
|
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");
|
2003-12-24 03:31:06 +00:00
|
|
|
gst_pad_set_getcaps_function (filter->srcpad, gst_pad_proxy_getcaps);
|
2003-01-10 10:22:25 +00:00
|
|
|
gst_pad_set_link_function(filter->srcpad,volume_connect);
|
2001-12-22 23:27:17 +00:00
|
|
|
|
ext/alsa/gstalsamixer.c: Setting mixer interface type to HARDWARE.
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.
2004-01-15 15:50:10 +00:00
|
|
|
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);
|
|
|
|
|
2002-04-28 16:07:41 +00:00
|
|
|
filter->mute = FALSE;
|
2001-12-22 23:27:17 +00:00
|
|
|
filter->volume_i = 8192;
|
|
|
|
filter->volume_f = 1.0;
|
2002-05-27 04:29:30 +00:00
|
|
|
filter->real_vol_i = 8192;
|
|
|
|
filter->real_vol_f = 1.0;
|
ext/alsa/gstalsamixer.c: Setting mixer interface type to HARDWARE.
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.
2004-01-15 15:50:10 +00:00
|
|
|
filter->tracklist = NULL;
|
2002-04-28 16:07:41 +00:00
|
|
|
|
|
|
|
filter->dpman = gst_dpman_new ("volume_dpman", GST_ELEMENT(filter));
|
|
|
|
gst_dpman_add_required_dparam_callback (
|
|
|
|
filter->dpman,
|
|
|
|
g_param_spec_int("mute","Mute","Mute the audio",
|
|
|
|
0, 1, 0, G_PARAM_READWRITE),
|
|
|
|
"int",
|
|
|
|
volume_update_mute,
|
|
|
|
filter
|
|
|
|
);
|
|
|
|
gst_dpman_add_required_dparam_callback (
|
|
|
|
filter->dpman,
|
|
|
|
g_param_spec_float("volume","Volume","Volume of the audio",
|
2002-05-05 15:42:48 +00:00
|
|
|
0.0, 4.0, 1.0, G_PARAM_READWRITE),
|
2002-04-28 16:07:41 +00:00
|
|
|
"scalar",
|
|
|
|
volume_update_volume,
|
|
|
|
filter
|
|
|
|
);
|
ext/alsa/gstalsamixer.c: Setting mixer interface type to HARDWARE.
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.
2004-01-15 15:50:10 +00:00
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
2001-12-22 23:27:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2003-10-08 16:08:22 +00:00
|
|
|
volume_chain_float (GstPad *pad, GstData *_data)
|
2001-12-22 23:27:17 +00:00
|
|
|
{
|
2003-10-08 16:08:22 +00:00
|
|
|
GstBuffer *buf = GST_BUFFER (_data);
|
2001-12-22 23:27:17 +00:00
|
|
|
GstVolume *filter;
|
2002-04-28 16:07:41 +00:00
|
|
|
GstBuffer *out_buf;
|
|
|
|
gfloat *data;
|
2002-05-29 18:56:23 +00:00
|
|
|
gint i, num_samples;
|
2002-04-28 16:07:41 +00:00
|
|
|
|
2001-12-22 23:27:17 +00:00
|
|
|
g_return_if_fail(GST_IS_PAD(pad));
|
|
|
|
g_return_if_fail(buf != NULL);
|
|
|
|
|
|
|
|
filter = GST_VOLUME(GST_OBJECT_PARENT (pad));
|
|
|
|
g_return_if_fail(GST_IS_VOLUME(filter));
|
2002-04-28 16:07:41 +00:00
|
|
|
|
2002-07-25 18:59:41 +00:00
|
|
|
out_buf = gst_buffer_copy_on_write (buf);
|
2002-04-28 16:07:41 +00:00
|
|
|
|
|
|
|
data = (gfloat *)GST_BUFFER_DATA(out_buf);
|
|
|
|
num_samples = GST_BUFFER_SIZE(out_buf)/sizeof(gfloat);
|
2002-05-29 18:56:23 +00:00
|
|
|
GST_DPMAN_PREPROCESS(filter->dpman, num_samples, GST_BUFFER_TIMESTAMP(out_buf));
|
2002-04-28 16:07:41 +00:00
|
|
|
i = 0;
|
|
|
|
|
2002-05-29 18:56:23 +00:00
|
|
|
while(GST_DPMAN_PROCESS(filter->dpman, i)) {
|
2002-04-28 16:07:41 +00:00
|
|
|
data[i++] *= filter->real_vol_f;
|
|
|
|
}
|
2001-12-22 23:27:17 +00:00
|
|
|
|
2003-10-08 16:08:22 +00:00
|
|
|
gst_pad_push(filter->srcpad,GST_DATA (out_buf));
|
2002-04-02 16:43:08 +00:00
|
|
|
|
2002-04-28 16:07:41 +00:00
|
|
|
}
|
2001-12-22 23:27:17 +00:00
|
|
|
|
2002-04-28 16:07:41 +00:00
|
|
|
static void
|
2003-10-08 16:08:22 +00:00
|
|
|
volume_chain_int16 (GstPad *pad, GstData *_data)
|
2002-04-28 16:07:41 +00:00
|
|
|
{
|
2003-10-08 16:08:22 +00:00
|
|
|
GstBuffer *buf = GST_BUFFER (_data);
|
2002-04-28 16:07:41 +00:00
|
|
|
GstVolume *filter;
|
|
|
|
GstBuffer *out_buf;
|
|
|
|
gint16 *data;
|
2002-05-29 18:56:23 +00:00
|
|
|
gint i, num_samples;
|
2002-04-28 16:07:41 +00:00
|
|
|
|
|
|
|
g_return_if_fail(GST_IS_PAD(pad));
|
|
|
|
g_return_if_fail(buf != NULL);
|
|
|
|
|
|
|
|
filter = GST_VOLUME(GST_OBJECT_PARENT (pad));
|
|
|
|
g_return_if_fail(GST_IS_VOLUME(filter));
|
|
|
|
|
2002-07-25 21:46:17 +00:00
|
|
|
out_buf = gst_buffer_copy_on_write (buf);
|
2002-04-28 16:07:41 +00:00
|
|
|
|
2002-09-12 16:13:08 +00:00
|
|
|
data = (gint16 *) GST_BUFFER_DATA (out_buf);
|
|
|
|
g_assert (data);
|
2002-04-28 16:07:41 +00:00
|
|
|
num_samples = GST_BUFFER_SIZE(out_buf)/sizeof(gint16);
|
2002-05-29 18:56:23 +00:00
|
|
|
GST_DPMAN_PREPROCESS(filter->dpman, num_samples, GST_BUFFER_TIMESTAMP(out_buf));
|
2002-04-28 16:07:41 +00:00
|
|
|
i = 0;
|
2002-05-29 18:56:23 +00:00
|
|
|
|
|
|
|
while(GST_DPMAN_PROCESS(filter->dpman, i)) {
|
|
|
|
/* only clamp if the gain is greater than 1.0 */
|
|
|
|
if (filter->real_vol_i > 8192){
|
|
|
|
while (i < GST_DPMAN_NEXT_UPDATE_FRAME(filter->dpman)){
|
|
|
|
data[i] = (gint16)CLAMP(filter->real_vol_i * (gint)data[i] / 8192, -32768, 32767);
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
while (i < GST_DPMAN_NEXT_UPDATE_FRAME(filter->dpman)){
|
|
|
|
data[i] = (gint16)(filter->real_vol_i * (gint)data[i] / 8192);
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
}
|
2001-12-22 23:27:17 +00:00
|
|
|
}
|
2002-05-29 18:56:23 +00:00
|
|
|
|
2003-10-08 16:08:22 +00:00
|
|
|
gst_pad_push(filter->srcpad,GST_DATA (out_buf));
|
2002-04-28 16:07:41 +00:00
|
|
|
|
2001-12-22 23:27:17 +00:00
|
|
|
}
|
|
|
|
|
2002-04-28 16:07:41 +00:00
|
|
|
static void
|
|
|
|
volume_update_mute(const GValue *value, gpointer data)
|
|
|
|
{
|
|
|
|
GstVolume *filter = (GstVolume*)data;
|
|
|
|
g_return_if_fail(GST_IS_VOLUME(filter));
|
2001-12-22 23:27:17 +00:00
|
|
|
|
2002-04-28 16:07:41 +00:00
|
|
|
if (G_VALUE_HOLDS_BOOLEAN(value)){
|
|
|
|
filter->mute = g_value_get_boolean(value);
|
|
|
|
}
|
|
|
|
else if (G_VALUE_HOLDS_INT(value)){
|
|
|
|
filter->mute = (g_value_get_int(value) == 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
2001-12-22 23:27:17 +00:00
|
|
|
|
2002-04-28 16:07:41 +00:00
|
|
|
static void
|
|
|
|
volume_update_volume(const GValue *value, gpointer data)
|
|
|
|
{
|
|
|
|
GstVolume *filter = (GstVolume*)data;
|
|
|
|
g_return_if_fail(GST_IS_VOLUME(filter));
|
|
|
|
|
|
|
|
filter->volume_f = g_value_get_float (value);
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
2001-12-22 23:27:17 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
volume_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GstVolume *filter;
|
|
|
|
|
|
|
|
/* it's not null if we got it, but it might not be ours */
|
|
|
|
g_return_if_fail(GST_IS_VOLUME(object));
|
|
|
|
filter = GST_VOLUME(object);
|
|
|
|
|
|
|
|
switch (prop_id)
|
|
|
|
{
|
2002-04-28 16:07:41 +00:00
|
|
|
case ARG_MUTE:
|
|
|
|
gst_dpman_bypass_dparam(filter->dpman, "mute");
|
|
|
|
volume_update_mute(value, filter);
|
2001-12-22 23:27:17 +00:00
|
|
|
break;
|
|
|
|
case ARG_VOLUME:
|
2002-04-28 16:07:41 +00:00
|
|
|
gst_dpman_bypass_dparam(filter->dpman, "volume");
|
|
|
|
volume_update_volume(value, filter);
|
2001-12-22 23:27:17 +00:00
|
|
|
break;
|
|
|
|
default:
|
2002-04-02 16:43:08 +00:00
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
2001-12-22 23:27:17 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
volume_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GstVolume *filter;
|
|
|
|
|
|
|
|
/* it's not null if we got it, but it might not be ours */
|
|
|
|
g_return_if_fail(GST_IS_VOLUME(object));
|
|
|
|
filter = GST_VOLUME(object);
|
|
|
|
|
|
|
|
switch (prop_id) {
|
2002-04-28 16:07:41 +00:00
|
|
|
case ARG_MUTE:
|
|
|
|
g_value_set_boolean (value, filter->mute);
|
2001-12-22 23:27:17 +00:00
|
|
|
break;
|
|
|
|
case ARG_VOLUME:
|
|
|
|
g_value_set_float (value, filter->volume_f);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
2003-10-31 20:03:29 +00:00
|
|
|
plugin_init (GstPlugin *plugin)
|
2001-12-22 23:27:17 +00:00
|
|
|
{
|
2002-08-11 12:20:43 +00:00
|
|
|
gst_control_init(NULL,NULL);
|
2003-10-31 20:03:29 +00:00
|
|
|
|
|
|
|
return gst_element_register (plugin, "volume", GST_RANK_PRIMARY, GST_TYPE_VOLUME);
|
2001-12-22 23:27:17 +00:00
|
|
|
}
|
|
|
|
|
2003-10-31 20:03:29 +00:00
|
|
|
GST_PLUGIN_DEFINE (
|
2001-12-22 23:27:17 +00:00
|
|
|
GST_VERSION_MAJOR,
|
|
|
|
GST_VERSION_MINOR,
|
|
|
|
"volume",
|
2003-10-31 20:03:29 +00:00
|
|
|
"element for controlling audio volume",
|
|
|
|
plugin_init,
|
|
|
|
VERSION,
|
|
|
|
GST_LICENSE,
|
|
|
|
GST_PACKAGE,
|
|
|
|
GST_ORIGIN
|
|
|
|
)
|