Commit 4aa8b0ca authored by Tim-Philipp Müller's avatar Tim-Philipp Müller
Browse files

gst-libs/gst/interfaces/mixertrack.c: API: add "untranslated-label" property...

gst-libs/gst/interfaces/mixertrack.c: API: add "untranslated-label" property which should be set by implementations a...

Original commit message from CVS:
* gst-libs/gst/interfaces/mixertrack.c:
(gst_mixer_track_class_init), (gst_mixer_track_get_property),
(gst_mixer_track_set_property):
API: add "untranslated-label" property which should be set by
implementations at construct time (#414645).
* ext/alsa/gstalsamixeroptions.c: (gst_alsa_mixer_options_new):
* ext/alsa/gstalsamixertrack.c: (gst_alsa_mixer_track_new):
Set "untranslated-label" when constructing mixer track objects.
* tests/check/elements/alsa.c: (GST_START_TEST), (alsa_suite):
Unit test to check the above.
parent a1c38065
2007-03-07 Tim-Philipp Müller <tim at centricular dot net>
* gst-libs/gst/interfaces/mixertrack.c:
(gst_mixer_track_class_init), (gst_mixer_track_get_property),
(gst_mixer_track_set_property):
API: add "untranslated-label" property which should be set by
implementations at construct time (#414645).
* ext/alsa/gstalsamixeroptions.c: (gst_alsa_mixer_options_new):
* ext/alsa/gstalsamixertrack.c: (gst_alsa_mixer_track_new):
Set "untranslated-label" when constructing mixer track objects.
* tests/check/elements/alsa.c: (GST_START_TEST), (alsa_suite):
Unit test to check the above.
2007-03-07 Wim Taymans <wim@fluendo.com>
 
* ext/ogg/gstoggdemux.c: (gst_ogg_demux_read_chain):
......@@ -69,14 +69,22 @@ gst_alsa_mixer_options_init (GstAlsaMixerOptions * alsa_opts)
GstMixerOptions *
gst_alsa_mixer_options_new (snd_mixer_elem_t * element, gint track_num)
{
GstMixerOptions *opts = g_object_new (GST_ALSA_MIXER_OPTIONS_TYPE, NULL);
GstAlsaMixerOptions *alsa_opts = (GstAlsaMixerOptions *) opts;
GstMixerTrack *track = (GstMixerTrack *) opts;
GstMixerOptions *opts;
GstAlsaMixerOptions *alsa_opts;
GstMixerTrack *track;
const gchar *label;
gint num, i;
gchar str[256];
label = snd_mixer_selem_get_name (element);
opts = g_object_new (GST_ALSA_MIXER_OPTIONS_TYPE,
"untranslated-label", label, NULL);
alsa_opts = (GstAlsaMixerOptions *) opts;
track = (GstMixerTrack *) opts;
/* set basic information */
track->label = g_strdup (snd_mixer_selem_get_name (element));
track->label = g_strdup (label); /* FIXME: translate this? */
track->num_channels = 0;
track->flags = 0;
alsa_opts->element = element;
......
......@@ -145,7 +145,9 @@ gst_alsa_mixer_track_new (snd_mixer_elem_t * element,
GST_LOG ("[%s] num=%d,track_num=%d,flags=0x%08x,sw=%s,shared_mute_track=%p",
name, num, track_num, flags, (sw) ? "true" : "false", shared_mute_track);
track = (GstMixerTrack *) g_object_new (GST_ALSA_MIXER_TRACK_TYPE, NULL);
track = (GstMixerTrack *) g_object_new (GST_ALSA_MIXER_TRACK_TYPE,
"untranslated-label", name, NULL);
alsa_track = (GstAlsaMixerTrack *) track;
GST_LOG ("[%s] created new mixer track %p", name, track);
......
......@@ -38,6 +38,7 @@ enum
{
ARG_0,
ARG_LABEL,
ARG_UNTRANSLATED_LABEL,
ARG_MIN_VOLUME,
ARG_MAX_VOLUME,
ARG_FLAGS,
......@@ -50,6 +51,8 @@ static void gst_mixer_track_dispose (GObject * object);
static void gst_mixer_track_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec);
static void gst_mixer_track_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec);
static GObjectClass *parent_class = NULL;
static guint signals[LAST_SIGNAL] = { 0 };
......@@ -89,10 +92,28 @@ gst_mixer_track_class_init (GstMixerTrackClass * klass)
parent_class = g_type_class_peek_parent (klass);
object_klass->get_property = gst_mixer_track_get_property;
object_klass->set_property = gst_mixer_track_set_property;
g_object_class_install_property (object_klass, ARG_LABEL,
g_param_spec_string ("label", "Track label",
"The label assigned to the track", NULL, G_PARAM_READABLE));
"The label assigned to the track (may be translated)", NULL,
G_PARAM_READABLE));
/**
* GstMixerTrack:untranslated-label
*
* The untranslated label of the mixer track, if available. Mixer track
* implementations must set this at construct time. Applications may find
* this useful to determine icons for various kind of tracks. However,
* applications mustn't make any assumptions about the naming of tracks,
* the untranslated labels are purely informational and may change.
*
* Since: 0.10.13
**/
g_object_class_install_property (object_klass, ARG_UNTRANSLATED_LABEL,
g_param_spec_string ("untranslated-label", "Untranslated track label",
"The untranslated label assigned to the track (since 0.10.13)",
NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY));
g_object_class_install_property (object_klass, ARG_MIN_VOLUME,
g_param_spec_int ("min_volume", "Minimum volume level",
......@@ -148,6 +169,9 @@ gst_mixer_track_init (GstMixerTrack * mixer_track)
mixer_track->num_channels = 0;
}
/* FIXME 0.11: move this as a member into the mixer track structure */
#define MIXER_TRACK_OBJECT_DATA_KEY_UNTRANSLATED_LABEL "gst-mixer-track-ulabel"
static void
gst_mixer_track_get_property (GObject * object, guint prop_id, GValue * value,
GParamSpec * pspec)
......@@ -160,6 +184,11 @@ gst_mixer_track_get_property (GObject * object, guint prop_id, GValue * value,
case ARG_LABEL:
g_value_set_string (value, mixer_track->label);
break;
case ARG_UNTRANSLATED_LABEL:
g_value_set_string (value,
(const gchar *) g_object_get_data (G_OBJECT (mixer_track),
MIXER_TRACK_OBJECT_DATA_KEY_UNTRANSLATED_LABEL));
break;
case ARG_MIN_VOLUME:
g_value_set_int (value, mixer_track->min_volume);
break;
......@@ -178,6 +207,26 @@ gst_mixer_track_get_property (GObject * object, guint prop_id, GValue * value,
}
}
static void
gst_mixer_track_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec)
{
GstMixerTrack *mixer_track;
mixer_track = GST_MIXER_TRACK (object);
switch (prop_id) {
case ARG_UNTRANSLATED_LABEL:
g_object_set_data_full (G_OBJECT (mixer_track),
MIXER_TRACK_OBJECT_DATA_KEY_UNTRANSLATED_LABEL,
g_value_dup_string (value), (GDestroyNotify) g_free);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gst_mixer_track_dispose (GObject * object)
{
......
......@@ -24,6 +24,7 @@
#include <gst/check/gstcheck.h>
#include <gst/interfaces/propertyprobe.h>
#include <gst/interfaces/mixer.h>
/* just a simple test that runs device probing on
* an alsasrc, alsasink and alsamixer instance */
......@@ -48,14 +49,16 @@ GST_START_TEST (test_device_property_probe)
arr = gst_property_probe_probe_and_get_values_name (probe, "device");
if (arr) {
for (i = 0; i < arr->n_values; ++i) {
const gchar *device;
GValue *val;
val = g_value_array_get_nth (arr, i);
fail_unless (val != NULL);
fail_unless (G_VALUE_HOLDS_STRING (val));
GST_LOG_OBJECT (element, "device[%d] = %s", i,
g_value_get_string (val));
device = g_value_get_string (val);
fail_unless (device != NULL);
GST_LOG_OBJECT (element, "device[%d] = %s", i, device);
}
g_value_array_free (arr);
} else {
......@@ -68,7 +71,50 @@ GST_START_TEST (test_device_property_probe)
GST_END_TEST;
Suite *
GST_START_TEST (test_alsa_mixer_track)
{
GstStateChangeReturn state_ret;
GstElement *mixer;
GList *tracks, *l;
mixer = gst_element_factory_make ("alsamixer", "alsamixer");
fail_unless (mixer != NULL, "Failed to create 'alsamixer' element!");
state_ret = gst_element_set_state (mixer, GST_STATE_READY);
if (state_ret != GST_STATE_CHANGE_SUCCESS)
return;
GST_LOG ("opened alsamixer");
fail_unless (GST_IS_MIXER (mixer), "is not a GstMixer?!");
tracks = (GList *) gst_mixer_list_tracks (GST_MIXER (mixer));
for (l = tracks; l != NULL; l = l->next) {
GstMixerTrack *track;
gchar *ulabel = NULL, *label = NULL;
track = GST_MIXER_TRACK (l->data);
g_object_get (track, "label", &label, "untranslated-label", &ulabel, NULL);
fail_unless (label == NULL || g_utf8_validate (label, -1, NULL));
if (ulabel != NULL) {
gchar *p;
for (p = ulabel; p != NULL && *p != '\0'; ++p) {
fail_unless (g_ascii_isprint (*p),
"untranslated label '%s' not printable ASCII", ulabel);
}
}
GST_DEBUG ("%s: %s", GST_STR_NULL (ulabel), GST_STR_NULL (label));
g_free (label);
g_free (ulabel);
}
fail_unless_equals_int (gst_element_set_state (mixer, GST_STATE_NULL),
GST_STATE_CHANGE_SUCCESS);
}
GST_END_TEST;
static Suite *
alsa_suite (void)
{
Suite *s = suite_create ("alsa");
......@@ -76,23 +122,9 @@ alsa_suite (void)
suite_add_tcase (s, tc_chain);
tcase_add_test (tc_chain, test_device_property_probe);
tcase_add_test (tc_chain, test_alsa_mixer_track);
return s;
}
int
main (int argc, char **argv)
{
int nf;
Suite *s = alsa_suite ();
SRunner *sr = srunner_create (s);
gst_check_init (&argc, &argv);
srunner_run_all (sr, CK_NORMAL);
nf = srunner_ntests_failed (sr);
srunner_free (sr);
return nf;
}
GST_CHECK_MAIN (alsa)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment