gst/interfaces.*: wrap mixer get_volume

Original commit message from CVS:
* gst/interfaces.defs:
* gst/interfaces.override:
wrap mixer get_volume
* examples/Makefile.am:
* examples/mixer.py:
add an example using it
This commit is contained in:
Thomas Vander Stichele 2007-01-17 06:27:38 +00:00
parent dd5042357a
commit 7e94773d0f
5 changed files with 67 additions and 2 deletions

View file

@ -1,3 +1,12 @@
2007-01-17 Thomas Vander Stichele <thomas at apestaart dot org>
* gst/interfaces.defs:
* gst/interfaces.override:
wrap mixer get_volume
* examples/Makefile.am:
* examples/mixer.py:
add an example using it
2007-01-17 Thomas Vander Stichele <thomas at apestaart dot org>
* configure.ac:

View file

@ -10,6 +10,7 @@ examples_DATA = \
fvumeter.py \
gst-discover \
gstfile.py \
mixer.py \
play.py \
pipeline-tester \
remuxer.py \

20
examples/mixer.py Normal file
View file

@ -0,0 +1,20 @@
# -*- Mode: Python -*-
# vi:si:et:sw=4:sts=4:ts=4
import sys
import gst
import gst.interfaces
a = gst.element_factory_make('alsasrc')
print a.set_state(gst.STATE_PLAYING)
print "Inputs:"
for t in a.list_tracks():
if t.flags & gst.interfaces.MIXER_TRACK_INPUT:
sys.stdout.write(t.label)
sys.stdout.write(': %d - %d' % (t.min_volume, t.max_volume))
sys.stdout.write(': %r' % (a.get_volume(t), ))
if t.flags & gst.interfaces.MIXER_TRACK_RECORD:
sys.stdout.write(' (selected)')
sys.stdout.write('\n')

View file

@ -244,10 +244,9 @@
(define-method get_volume
(of-object "GstMixer")
(c-name "gst_mixer_get_volume")
(return-type "none")
(return-type "tuple")
(parameters
'("GstMixerTrack*" "track")
'("gint*" "volumes")
)
)

View file

@ -161,3 +161,39 @@ _wrap_gst_mixer_options_get_values (PyGObject *self)
return py_list;
}
%%
override gst_mixer_get_volume kwargs
static PyObject *
_wrap_gst_mixer_get_volume (PyGObject *self, PyObject *args, PyObject *kwargs)
{
static char *kwlist[] = { "track", NULL };
PyGObject *track;
PyObject *py_tuple;
gint *volumes = NULL;
gint channels;
int i;
if (!PyArg_ParseTupleAndKeywords (args, kwargs, "O!:GstMixer.get_volume",
kwlist, &PyGstMixerTrack_Type, &track))
return NULL;
g_object_get (GST_MIXER_TRACK (track->obj), "num-channels", &channels,
NULL);
volumes = g_malloc (channels * sizeof (gint));
/* 0 channels will cause volume to be a NULL pointer, but we still want
* our (empty) tuple */
if (channels)
gst_mixer_get_volume (GST_MIXER (self->obj), GST_MIXER_TRACK (track->obj),
volumes);
py_tuple = PyTuple_New (channels);
for (i = 0; i < channels; ++i) {
PyTuple_SET_ITEM (py_tuple, i, PyInt_FromLong (volumes[i]));
}
g_free (volumes);
return py_tuple;
}