From 8c1e1212d66334bdf396c116c3e348bed9d1c9f6 Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Mon, 25 Oct 2004 15:58:35 +0000 Subject: [PATCH] ALSA mixer track label internationalization (#154054). Original commit message from CVS: Reviewd by: Ronald S. Bultje * ext/alsa/gstalsamixer.c: (gst_alsa_mixer_build_list): * ext/alsa/gstalsamixertrack.c: (gst_alsa_mixer_track_new): * ext/alsa/gstalsamixertrack.h: * po/POTFILES.in: ALSA mixer track label internationalization (#154054). --- ChangeLog | 10 ++++++++++ ext/alsa/gstalsamixer.c | 13 +++---------- ext/alsa/gstalsamixertrack.c | 43 ++++++++++++++++++++++++++++++++++++++++--- ext/alsa/gstalsamixertrack.h | 2 +- po/POTFILES.in | 1 + 5 files changed, 55 insertions(+), 14 deletions(-) diff --git a/ChangeLog b/ChangeLog index 22588c1..13a86ea 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2004-10-25 Takao Fujiwara + + Reviewd by: Ronald S. Bultje + + * ext/alsa/gstalsamixer.c: (gst_alsa_mixer_build_list): + * ext/alsa/gstalsamixertrack.c: (gst_alsa_mixer_track_new): + * ext/alsa/gstalsamixertrack.h: + * po/POTFILES.in: + ALSA mixer track label internationalization (#154054). + 2004-10-25 Ronald S. Bultje * ext/theora/theoradec.c: (theora_dec_chain): diff --git a/ext/alsa/gstalsamixer.c b/ext/alsa/gstalsamixer.c index 8cb8e7a..926e555 100644 --- a/ext/alsa/gstalsamixer.c +++ b/ext/alsa/gstalsamixer.c @@ -265,7 +265,6 @@ gst_alsa_mixer_build_list (GstAlsaMixer * mixer) /* build track list */ for (i = 0; i < count; i++) { GList *item; - gchar *name; gint channels = 0, samename = 0; gint flags = GST_MIXER_TRACK_OUTPUT; gboolean got_it = FALSE; @@ -286,16 +285,11 @@ gst_alsa_mixer_build_list (GstAlsaMixer * mixer) element))) samename++; } - if (samename == 0) - name = g_strdup (snd_mixer_selem_get_name (element)); - else - name = g_strdup_printf ("%s %d", snd_mixer_selem_get_name (element), - samename + 1); if (snd_mixer_selem_has_capture_volume (element)) { while (snd_mixer_selem_has_capture_channel (element, channels)) channels++; - track = gst_alsa_mixer_track_new (element, name, + track = gst_alsa_mixer_track_new (element, samename, i, channels, flags, GST_ALSA_MIXER_TRACK_CAPTURE); mixer->tracklist = g_list_append (mixer->tracklist, track); got_it = TRUE; @@ -312,7 +306,7 @@ gst_alsa_mixer_build_list (GstAlsaMixer * mixer) first = FALSE; flags |= GST_MIXER_TRACK_MASTER; } - track = gst_alsa_mixer_track_new (element, name, + track = gst_alsa_mixer_track_new (element, samename, i, channels, flags, GST_ALSA_MIXER_TRACK_PLAYBACK); mixer->tracklist = g_list_append (mixer->tracklist, track); got_it = TRUE; @@ -328,13 +322,12 @@ gst_alsa_mixer_build_list (GstAlsaMixer * mixer) if (flags == GST_MIXER_TRACK_OUTPUT && snd_mixer_selem_has_playback_switch (element)) { /* simple mute switch */ - track = gst_alsa_mixer_track_new (element, name, + track = gst_alsa_mixer_track_new (element, samename, i, 0, flags, GST_ALSA_MIXER_TRACK_PLAYBACK); mixer->tracklist = g_list_append (mixer->tracklist, track); } } - g_free (name); next: element = snd_mixer_elem_next (element); } diff --git a/ext/alsa/gstalsamixertrack.c b/ext/alsa/gstalsamixertrack.c index 83b7f28..77f5489 100644 --- a/ext/alsa/gstalsamixertrack.c +++ b/ext/alsa/gstalsamixertrack.c @@ -21,6 +21,8 @@ #include "config.h" #endif +#include + #include "gstalsamixertrack.h" static void gst_alsa_mixer_track_init (GstAlsaMixerTrack * alsa_track); @@ -69,17 +71,52 @@ gst_alsa_mixer_track_init (GstAlsaMixerTrack * alsa_track) GstMixerTrack * gst_alsa_mixer_track_new (snd_mixer_elem_t * element, - const gchar * label, - gint track_num, gint channels, gint flags, gint alsa_flags) + gint num, gint track_num, gint channels, gint flags, gint alsa_flags) { gint i; long min = 0, max = 0; + struct + { + gchar *orig, *trans; + } alsa_track_labels[] = { + { + "Master", _("Master")}, { + "Bass", _("Bass")}, { + "Treble", _("Treble")}, { + "PCM", _("PCM")}, { + "Synth", _("Synth")}, { + "Line", _("Line-in")}, { + "CD", _("CD")}, { + "Mic", _("Microphone")}, { + "PC Speaker", _("PC Speaker")}, { + "Playback", _("Playback")}, { + "Capture", _("Capture")}, { + NULL, NULL} + }; GstMixerTrack *track = g_object_new (GST_ALSA_MIXER_TRACK_TYPE, NULL); GstAlsaMixerTrack *alsa_track = (GstAlsaMixerTrack *) track; /* set basic information */ - track->label = g_strdup (label); + if (num == 0) + track->label = g_strdup (snd_mixer_selem_get_name (element)); + else + track->label = g_strdup_printf ("%s %d", + snd_mixer_selem_get_name (element), num + 1); + i = 0; + while (alsa_track_labels[i].orig != NULL) { + if (!g_utf8_collate (snd_mixer_selem_get_name (element), + alsa_track_labels[i].orig)) { + g_free (track->label); + if (num == 0) + track->label = g_strdup (alsa_track_labels[i].trans); + else + track->label = g_strdup_printf ("%s %d", + alsa_track_labels[i].trans, num); + break; + } + i++; + } track->num_channels = channels; track->flags = flags; alsa_track->element = element; diff --git a/ext/alsa/gstalsamixertrack.h b/ext/alsa/gstalsamixertrack.h index c1b7120..fe15382 100644 --- a/ext/alsa/gstalsamixertrack.h +++ b/ext/alsa/gstalsamixertrack.h @@ -51,7 +51,7 @@ struct _GstAlsaMixerTrackClass { GType gst_alsa_mixer_track_get_type (void); GstMixerTrack * gst_alsa_mixer_track_new (snd_mixer_elem_t * element, - const gchar * name, + gint num, gint track_num, gint channels, gint flags, diff --git a/po/POTFILES.in b/po/POTFILES.in index d2d2863..ef37835 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -1,3 +1,4 @@ +ext/alsa/gstalsamixertrack.c ext/audiofile/gstafsink.c ext/audiofile/gstafsrc.c ext/cdparanoia/gstcdparanoia.c -- 2.7.4