Author: lslezak
Date: Fri Apr 25 13:13:14 2008
New Revision: 47064
URL: http://svn.opensuse.org/viewcvs/yast?rev=47064&view=rev
Log:
- do not write 'index' option, write 'slots' option of 'snd' driver
to define the order of the configured soundcards (bnc#381695)
- 2.16.9
Modified:
trunk/sound/VERSION
trunk/sound/package/yast2-sound.changes
trunk/sound/sound/src/Sound.ycp
trunk/sound/sound/src/read_routines.ycp
trunk/sound/sound/src/routines.ycp
trunk/sound/sound/src/write_routines.ycp
Modified: trunk/sound/VERSION
URL: http://svn.opensuse.org/viewcvs/yast/trunk/sound/VERSION?rev=47064&r1=47063&r2=47064&view=diff
==============================================================================
--- trunk/sound/VERSION (original)
+++ trunk/sound/VERSION Fri Apr 25 13:13:14 2008
@@ -1 +1 @@
-2.16.8
+2.16.9
Modified: trunk/sound/package/yast2-sound.changes
URL: http://svn.opensuse.org/viewcvs/yast/trunk/sound/package/yast2-sound.changes?rev=47064&r1=47063&r2=47064&view=diff
==============================================================================
--- trunk/sound/package/yast2-sound.changes (original)
+++ trunk/sound/package/yast2-sound.changes Fri Apr 25 13:13:14 2008
@@ -1,4 +1,11 @@
-------------------------------------------------------------------
+Fri Apr 25 08:54:59 CEST 2008 - lslezak@suse.cz
+
+- do not write 'index' option, write 'slots' option of 'snd' driver
+ to define the order of the configured soundcards (bnc#381695)
+- 2.16.9
+
+-------------------------------------------------------------------
Mon Apr 14 12:46:08 CEST 2008 - lslezak@suse.cz
- updated the sound card database, added "snd-oxygen" driver to
Modified: trunk/sound/sound/src/Sound.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/sound/sound/src/Sound.ycp?rev=47064&r1=47063&r2=47064&view=diff
==============================================================================
--- trunk/sound/sound/src/Sound.ycp (original)
+++ trunk/sound/sound/src/Sound.ycp Fri Apr 25 13:13:14 2008
@@ -630,11 +630,6 @@
map sound_db =$[];
if (db_cards == nil || db_cards == $[])
{
- if (use_ui)
- {
- string message = _("Loading the sound card database...");
- UI::OpenDialog(`opt(`decorated), `Label(message));
- }
textdomain "sound_db";
y2debug("Reading card database");
sound_db = (map)eval(SCR::Read (.target.yast2, "sndcards.ycp"));
@@ -647,10 +642,6 @@
db_vendors = sound_db ["vendors"]:$[];
textdomain "sound";
- if (use_ui)
- {
- UI::CloseDialog();
- }
}
}
@@ -1115,8 +1106,8 @@
y2debug("only_default: %1", only_default);
- // don't add the default options, but always add 'index' and 'enable'
- if (!only_default || opname == "index" || opname == "enable")
+ // don't add the default options
+ if (!only_default || opname == "index")
{
res = add (res, opname, value);
}
@@ -1137,6 +1128,10 @@
list mods = toset (maplist (map e, modules_conf,``(e["module"]:"off")));
maplist (string modname, (list<string>) mods, ``{
map opts = CollectOptions(modname);
+
+ // ignore "index" options
+ opts = remove(opts, "index");
+
string optstr = "";
maplist(string k, string v, (map) opts, ``{
optstr = optstr+ sformat(" %1=%2", k, v);
Modified: trunk/sound/sound/src/read_routines.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/sound/sound/src/read_routines.ycp?rev=47064&r1=47063&r2=47064&view=diff
==============================================================================
--- trunk/sound/sound/src/read_routines.ycp (original)
+++ trunk/sound/sound/src/read_routines.ycp Fri Apr 25 13:13:14 2008
@@ -19,6 +19,7 @@
import "Sound";
import "HWConfig";
import "Confirm";
+ import "String";
include "sound/routines.ycp";// for is_snd_alias()
@@ -80,6 +81,64 @@
return result;
}
+ // sort module aliases according to snd slots option
+ list<string> sort_aliases(path config_path, path alias_path, list<string> aliases)
+ {
+ // read 'snd' options
+ map snd_opts = (map)SCR::Read(add(config_path, "snd"));
+ y2milestone("snd optionss: %1", snd_opts);
+
+ list<string> slots_option = splitstring(snd_opts["slots"]:"", ",");
+ slots_option = maplist(string slotopt, slots_option,
+ {
+ return String::CutBlanks(slotopt);
+ }
+ );
+
+ // alias -> driver mapping
+ map alias_mapping = $[];
+
+ // read aliases
+ foreach(string a, aliases,
+ {
+ y2milestone("Reading alias %1", a);
+ string modname = (string)SCR::Read(add(alias_path, a));
+ alias_mapping = add(alias_mapping, a, modname);
+ }
+ );
+
+ // driver -> [ aliases ]
+ map driver_mapping = $[];
+
+ // create a reverse mapping
+ foreach(string alias, string driver, alias_mapping,
+ {
+ list<string> a_list = driver_mapping[driver]:[];
+ a_list = add(a_list, alias);
+
+ driver_mapping[driver] = a_list;
+ }
+ );
+
+ y2milestone("Driver mapping: %1", driver_mapping);
+
+ list<string> sorted_aliases = [];
+
+ // sort aliases
+ foreach(string slot, slots_option,
+ {
+ list<string> aliases = driver_mapping[slot]:[];
+
+ sorted_aliases = add(sorted_aliases, aliases[0]:"");
+
+ aliases = remove(aliases, 0);
+ driver_mapping[slot] = aliases;
+ }
+ );
+
+ return sorted_aliases;
+ }
+
/**
* reads already saved info from given file
@@ -126,9 +185,15 @@
det_cards = (list<map>)SCR::Read(.probe.sound);
}
- y2debug("Detected cards: %1", det_cards);
+ y2milestone("Detected cards: %1", det_cards);
+
+ // sort the aliases according to the slots option
+ aliases = sort_aliases(mod_options, mod_alias, aliases);
+
+ y2milestone("Sorted aliases acording to slots: %1", aliases);
foreach (string a, aliases, ``{
+ y2milestone("Reading alias %1", a);
position = position + 1;
string modname = (string) SCR::Read (add (mod_alias, a));
@@ -166,6 +231,9 @@
model = read_card_name_from_alsa (position);
}
+ // add index option
+ options["index"] = tostring(position);
+
map entry = $[
"alias" : a,
"module" : modname,
Modified: trunk/sound/sound/src/routines.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/sound/sound/src/routines.ycp?rev=47064&r1=47063&r2=47064&view=diff
==============================================================================
--- trunk/sound/sound/src/routines.ycp (original)
+++ trunk/sound/sound/src/routines.ycp Fri Apr 25 13:13:14 2008
@@ -258,15 +258,11 @@
entry = add(entry, "options", opts);
return entry;
}
- // check existence of 'common' parameters: 'enable' and 'index'
+ // check existence of 'common' parameters: 'index'
string modname = entry["module"]:"";
foreach (string key, string value, (map) SCR::Read (
topath (sformat(".modinfo.kernel.drivers.sound.%1", modname))), ``{
- if (key == "enable")
- {
- opts [key] = "1";
- }
if (key == "index")
{
opts [key] = sformat ("%1",card_id);
Modified: trunk/sound/sound/src/write_routines.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/sound/sound/src/write_routines.ycp?rev=47064&r1=47063&r2=47064&view=diff
==============================================================================
--- trunk/sound/sound/src/write_routines.ycp (original)
+++ trunk/sound/sound/src/write_routines.ycp Fri Apr 25 13:13:14 2008
@@ -100,6 +100,42 @@
return ret;
}
+ // write 'option snd slots=' to the config
+ void WriteSlotsOption(map slots)
+ {
+ // get the indices
+ list<integer> keys = [];
+
+ foreach(integer key, string val, slots,
+ {
+ keys = add(keys, key);
+ }
+ );
+
+ keys = sort(keys);
+
+ y2milestone("Sorted keys: %1", keys);
+
+ list<string> drivers = [];
+
+ foreach(integer k, keys,
+ {
+ string drv = slots[k]:"";
+
+ if (drv != "")
+ {
+ drivers = add(drivers, drv);
+ }
+ }
+ );
+
+ string slot_option = mergestring(drivers, ",");
+ y2milestone("Writing slots option: %1", slot_option);
+
+ // write 'snd' options
+ SCR::Write( add(.modprobe_sound.options, "snd"), $[ "slots" : slot_option ]);
+ }
+
/**
* saves modules options. this function has to collect parameters that use
* different cards that use single module and create a coma separated list of values
@@ -138,10 +174,41 @@
}
);
+ map slots = $[];
+
foreach(string modname, mods, ``{
map res = Sound::CollectOptions(modname);
+
+ // remove "index" option, do not write it
+ string index = res["index"]:"";
+ res = remove(res, "index");
+
+ // remove old "enable" option if it's present
+ res = remove(res, "enable");
+
+ list<string> indices = splitstring(index, ",");
+
+ foreach(string idx, indices,
+ {
+ integer i = tointeger(idx);
+
+ if (i != nil && i >= 0)
+ {
+ y2debug("adding %1 : %2", i, modname);
+ slots = add(slots, i, modname);
+ }
+ }
+ );
+
+ // at first remove the current options (writing empty options leaves the old options untouched)
+ SCR::Write( add (mod_options, modname ), nil);
+
SCR::Write( add (mod_options, modname ), res);
});
+
+ y2milestone("Collected slots: %1", slots);
+
+ WriteSlotsOption(slots);
}
/**
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org