mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-23 18:21:04 +00:00
wrap mixer set_volume, use tuple to match get_volume
Original commit message from CVS: * examples/mixer.py: * gst/interfaces.override: wrap mixer set_volume, use tuple to match get_volume
This commit is contained in:
parent
10fe9ba7f4
commit
7a27ebbd79
3 changed files with 65 additions and 3 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
2007-01-17 Thomas Vander Stichele <thomas at apestaart dot org>
|
||||||
|
|
||||||
|
* examples/mixer.py:
|
||||||
|
* gst/interfaces.override:
|
||||||
|
wrap mixer set_volume, use tuple to match get_volume
|
||||||
|
|
||||||
2007-01-17 Thomas Vander Stichele <thomas at apestaart dot org>
|
2007-01-17 Thomas Vander Stichele <thomas at apestaart dot org>
|
||||||
|
|
||||||
* gst/pygstexception.c: (element_not_found_error_init),
|
* gst/pygstexception.c: (element_not_found_error_init),
|
||||||
|
|
|
@ -6,15 +6,26 @@ import sys
|
||||||
import gst
|
import gst
|
||||||
import gst.interfaces
|
import gst.interfaces
|
||||||
|
|
||||||
a = gst.element_factory_make('alsasrc')
|
pipeline = "alsasrc"
|
||||||
print a.set_state(gst.STATE_PLAYING)
|
if sys.argv[1:]:
|
||||||
|
pipeline = " ".join(sys.argv[1:])
|
||||||
|
a = gst.element_factory_make(pipeline)
|
||||||
|
print dir(a)
|
||||||
|
|
||||||
|
res = a.set_state(gst.STATE_PAUSED)
|
||||||
|
if res != gst.STATE_CHANGE_SUCCESS:
|
||||||
|
print "Could not set pipeline %s to PAUSED" % pipeline
|
||||||
|
|
||||||
print "Inputs:"
|
print "Inputs:"
|
||||||
for t in a.list_tracks():
|
for t in a.list_tracks():
|
||||||
if t.flags & gst.interfaces.MIXER_TRACK_INPUT:
|
if t.flags & gst.interfaces.MIXER_TRACK_INPUT:
|
||||||
sys.stdout.write(t.label)
|
sys.stdout.write(t.label)
|
||||||
sys.stdout.write(': %d - %d' % (t.min_volume, t.max_volume))
|
sys.stdout.write(': %d - %d' % (t.min_volume, t.max_volume))
|
||||||
sys.stdout.write(': %r' % (a.get_volume(t), ))
|
volumes = a.get_volume(t)
|
||||||
|
sys.stdout.write(': %r' % (volumes, ))
|
||||||
|
if t.props.num_channels > 0:
|
||||||
|
a.set_volume(t, volumes=volumes)
|
||||||
if t.flags & gst.interfaces.MIXER_TRACK_RECORD:
|
if t.flags & gst.interfaces.MIXER_TRACK_RECORD:
|
||||||
sys.stdout.write(' (selected)')
|
sys.stdout.write(' (selected)')
|
||||||
sys.stdout.write('\n')
|
sys.stdout.write('\n')
|
||||||
|
|
||||||
|
|
|
@ -162,6 +162,51 @@ _wrap_gst_mixer_options_get_values (PyGObject *self)
|
||||||
return py_list;
|
return py_list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
%%
|
||||||
|
override gst_mixer_set_volume kwargs
|
||||||
|
static PyObject *
|
||||||
|
_wrap_gst_mixer_set_volume (PyGObject *self, PyObject *args, PyObject *kwargs)
|
||||||
|
{
|
||||||
|
static char *kwlist[] = { "track", "volumes", NULL };
|
||||||
|
PyGObject *track;
|
||||||
|
PyObject *py_tuple;
|
||||||
|
gint *volumes = NULL;
|
||||||
|
gint channels;
|
||||||
|
int i;
|
||||||
|
PyObject *ret;
|
||||||
|
|
||||||
|
if (!PyArg_ParseTupleAndKeywords (args, kwargs, "O!O:GstMixer.set_volume",
|
||||||
|
kwlist, &PyGstMixerTrack_Type, &track, &py_tuple))
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
g_object_get (GST_MIXER_TRACK (track->obj), "num-channels", &channels,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
if (channels != PyTuple_Size (py_tuple)) {
|
||||||
|
PyErr_Format (PyExc_TypeError,
|
||||||
|
"Track channel count %d != volume tuple size %d",
|
||||||
|
channels, PyTuple_Size (py_tuple));
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
Py_INCREF(Py_None);
|
||||||
|
ret = Py_None;
|
||||||
|
|
||||||
|
if (channels == 0)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
volumes = g_malloc (channels * sizeof (gint));
|
||||||
|
for (i = 0; i < channels; ++i) {
|
||||||
|
volumes[i] = PyInt_AsLong (PyTuple_GET_ITEM (py_tuple, i));
|
||||||
|
}
|
||||||
|
gst_mixer_set_volume (GST_MIXER (self->obj), GST_MIXER_TRACK (track->obj),
|
||||||
|
volumes);
|
||||||
|
|
||||||
|
g_free (volumes);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
%%
|
%%
|
||||||
override gst_mixer_get_volume kwargs
|
override gst_mixer_get_volume kwargs
|
||||||
static PyObject *
|
static PyObject *
|
||||||
|
|
Loading…
Reference in a new issue