Module: Yast::SoundRoutinesInclude
- Defined in:
- ../../src/include/sound/routines.rb
Instance Method Summary (collapse)
-
- (Hash) add_alias(entry, card_id)
adds alias to save_info entry.
-
- (Object) add_common_options(entry, card_id)
adds common options for module.
-
- (Array) alsa_oss(number)
Simply returns list with ALSA OSS/Free emulation modules.
- - (Object) CDpopup(headline, question, cdroms)
-
- (String) check_module(save_entry, card_id)
Checks whether the module has been successfully loaded.
- - (Object) detect_cdrom
-
- (Array) filter_configured(save_info, cards)
filters out already configured cards.
-
- (Boolean) FontsInstalled
checks whether SoundFonts have already been installed.
-
- (String) get_card_label(card)
for a given card detected by libhd this function creates a label.
-
- (Array) get_card_names(key, keys)
returns cards manufactured by given vendor (ALSA only) or driver.
-
- (Hash) get_module(card)
Looks up in the database for the module.
-
- (Array) get_module_names
returns list of all available sound modules (OSS only).
-
- (Hash) get_module_params(modname)
returns the 'params' section from sndcards.yml of the given module.
-
- (Object) get_running_cards
Returns list of already running cards (oss is nasty hacked, because it's not trivial to check this) @return [Array].
-
- (Object) get_vol_settings
-
get_vol_settings * creates a list of stored values of volume and mute for each channel * of each card.
-
-
- (String) hardware_name(hardware_entry)
common function to extract 'name' of hardware.
-
- (Boolean) HasFonts(save_entry)
return true if the sound card supports SoundFonts.
- - (Object) initialize_sound_routines(include_target)
-
- (Object) InstallFonts(symlink, dontask)
this small wizard will install SoundFonts for soundblaster live/awe @param [String] symlink is path to default.sf2 that is to be created @param [Boolean] dontask if true, skip the first messagebox @return [void].
-
- (Boolean) is_snd_alias(_alias)
returns true if given string is valid sound alias (snd-card-1 .. snd-card-16).
-
- (String) isa_uniq
unique key for non-pci/pnp cards or virtual cards.
-
- (Array) itemize_list(l, default_value)
Itemize list for selection box.
- - (Object) layout_id
-
- (String) mount_device(device)
Mount specified device.
-
- (Boolean) need_nm256_opl3sa2_warn(sound_cards)
does this machine need a nm256/opl3sa warning?.
-
- (void) nm256_opl3sa2_warn(sound_cards)
shows warning message when both nm265 and opl3sa2 cards are present.
-
- (Object) nm256hack(modname)
show a warning popup for nm256 snd cards if needed @param [String] modname string module name @return [Boolean] continue/abort.
-
- (Hash) read_rc_vars
reads variables listed in 'vars' from rc.config.
-
- (Array) recalc_save_entries(save_info)
removes entries from save_info listed by indices in id_list.
-
- (Hash) restore_mod_params(params, values)
inserts values to already set options.
-
- (Boolean) SaveUniqueKeys(configured, unconfigured)
saves uniq keys to .probe.status.
-
- (Fixnum) search_card_id(name)
Used for searching.
-
- (Boolean) set_vol_settings(vol_settings)
stores values generated by get_vol_settings.
-
- (Object) Thinkpad600E_cs4236_hack(card_id)
Hack for Thinkpad 600E notebook - it need cs4236 module instead of cs4610.
- - (Object) umount_device(mount_point)
-
- (void) unmute(devices, card_id)
umnute channel 'devide' of the 'card_id'-th sound card.
Instance Method Details
- (Hash) add_alias(entry, card_id)
adds alias to save_info entry
241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 |
# File '../../src/include/sound/routines.rb', line 241 def add_alias(entry, card_id) entry = deep_copy(entry) if !Sound.use_alsa return Builtins.add( entry, "alias", Builtins.sformat("sound-slot-%1", card_id) ) else return Builtins.add( entry, "alias", Builtins.sformat("snd-card-%1", card_id) ) end end |
- (Object) add_common_options(entry, card_id)
adds common options for module. for alsa it is 'snd_index=$card_id' @param [Hash] entry card config @param [Fixnum] card_id card id @return [Hash] modified save_entry
262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 |
# File '../../src/include/sound/routines.rb', line 262 def (entry, card_id) entry = deep_copy(entry) Builtins.y2milestone( "add_common_options: card: %1, entry: %2", card_id, entry ) opts = Ops.get_map(entry, "options", {}) if !Sound.use_alsa parms = Convert.convert( get_module_params(Ops.get_string(entry, "module", "")), :from => "map", :to => "map <string, any>" ) if Builtins.size(parms) != 0 enab = Builtins.filter(parms) { |name, e| name == "snd_enable" } if Builtins.size(enab) != 0 opts = Builtins.add(opts, "snd_enable", "1") end end entry = Builtins.add(entry, "options", opts) return deep_copy(entry) end # check existence of 'common' parameters: 'index' modname = Ops.get_string(entry, "module", "") Builtins.foreach( Convert.convert( SCR.Read( Builtins.topath( Builtins.sformat(".modinfo.kernel.drivers.sound.%1", modname) ) ), :from => "any", :to => "map <string, string>" ) ) do |key, value| Ops.set(opts, key, Builtins.sformat("%1", card_id)) if key == "index" end Ops.set(entry, "options", opts) deep_copy(entry) end |
- (Array) alsa_oss(number)
Simply returns list with ALSA OSS/Free emulation modules
309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 |
# File '../../src/include/sound/routines.rb', line 309 def alsa_oss(number) return [] if !Sound.use_alsa modules = [] i = 0 while Ops.less_than(i, number) modules = Builtins.add( modules, { "alias" => Builtins.sformat("sound-slot-%1", i), "module" => Builtins.sformat("snd-card-%1", i) } ) i = Ops.add(i, 1) end deep_copy(modules) end |
- (Object) CDpopup(headline, question, cdroms)
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File '../../src/include/sound/routines.rb', line 65 def CDpopup(headline, question, cdroms) cdroms = deep_copy(cdroms) items = [] Builtins.foreach(cdroms) do |cd| dev = Ops.get_string(cd, "dev_name", "/dev/cdrom") model = Ops.get_locale(cd, "model", _("Unknown CD-ROM Device")) items = Builtins.add( items, Item(Id(dev), Builtins.sformat("%1 (%2)", model, dev)) ) end = PushButton( Id(:ok), Opt(:default, :key_F10), Label.ContinueButton ) = PushButton(Id(:cancel), Opt(:key_F9), Label.CancelButton) = HBox( HStretch(), HWeight(1, ), HSpacing(2), HWeight(1, ), HStretch() ) content = VBox( Heading(headline), VSpacing(0.2), Left(Label(question)), VSpacing(0.2), Left(ComboBox(Id(:device), _("CD-ROM &Device"), items)), VSpacing(0.2), ) UI.OpenDialog(Opt(:decorated), content) ret = UI.UserInput device = Convert.to_string(UI.QueryWidget(Id(:device), :Value)) UI.CloseDialog { "ui" => ret, "dev_name" => device } end |
- (String) check_module(save_entry, card_id)
Checks whether the module has been successfully loaded
822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 |
# File '../../src/include/sound/routines.rb', line 822 def check_module(save_entry, card_id) save_entry = deep_copy(save_entry) pm = Convert.to_map(SCR.Read(path(".proc.modules"))) modname = Ops.get_string(save_entry, "module", "off") l = Builtins.splitstring(modname, "-") mod_name = Builtins.mergestring(l, "_") if !Builtins.haskey(pm, modname) && !Builtins.haskey(pm, mod_name) || Ops.less_or_equal(Builtins.size(get_running_cards), card_id) # add debug info to the y2log Builtins.y2milestone("modules: %1", pm) Builtins.y2milestone("modname: %1", modname) Builtins.y2milestone("mod_name: %1", mod_name) Builtins.y2milestone("get_running_cards: %1", get_running_cards) Builtins.y2milestone("card_id: %1", card_id) Builtins.y2milestone( "/proc cards: %1", SCR.Read(path(".target.string"), "/proc/asound/cards") ) # label to error popup, %1 is module name return Builtins.sformat( _( "The kernel module %1 for sound support\n" + "could not be loaded. This can be caused by incorrect\n" + "module parameters, including invalid IO or IRQ parameters." ), modname ) end "" end |
- (Object) detect_cdrom
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File '../../src/include/sound/routines.rb', line 38 def detect_cdrom ret = [] cdroms = Convert.convert( SCR.Read(path(".probe.cdrom")), :from => "any", :to => "list <map>" ) Builtins.foreach(cdroms) do |cd| ret = Builtins.add( ret, { "model" => Ops.get_locale( cd, "model", _("Unknown CD-ROM device") ), "dev_name" => Ops.get_string(cd, "dev_name", "/dev/cdrom") } ) end if cdroms != nil Builtins.y2milestone("Detected CD-ROM devices: %1", ret) deep_copy(ret) end |
- (Array) filter_configured(save_info, cards)
filters out already configured cards
560 561 562 563 564 565 566 567 568 569 570 571 |
# File '../../src/include/sound/routines.rb', line 560 def filter_configured(save_info, cards) save_info = deep_copy(save_info) cards = deep_copy(cards) Builtins.filter(cards) do |det_card| uniq = Ops.get_string(det_card, "unique_key", "") retval = true Builtins.foreach(save_info) do |saved_card| retval = false if Ops.get_string(saved_card, "unique_key", "") == uniq end retval end end |
- (Boolean) FontsInstalled
checks whether SoundFonts have already been installed
900 901 902 903 904 905 |
# File '../../src/include/sound/routines.rb', line 900 def FontsInstalled Ops.greater_or_equal( SCR.Read(path(".target.size"), "/usr/share/sfbank/creative"), 0 ) end |
- (String) get_card_label(card)
for a given card detected by libhd this function creates a label
576 577 578 579 580 581 582 583 584 585 586 587 |
# File '../../src/include/sound/routines.rb', line 576 def get_card_label(card) card = deep_copy(card) lab = Builtins.splitstring(hardware_name(card), "\n") Builtins.y2debug("Card label: %1", lab) return "" if Builtins.size(lab) == 0 if Builtins.size(lab) == 1 || Ops.get_string(lab, 1, "") == "" return Ops.get_string(lab, 0, "") end Ops.get_string(lab, 1, "") end |
- (Array) get_card_names(key, keys)
returns cards manufactured by given vendor (ALSA only) or driver
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 |
# File '../../src/include/sound/routines.rb', line 142 def get_card_names(key, keys) Sound.LoadDatabase(true) if key == "all" || key == "" if @all_card_names == [] || @all_card_names == nil # use card names from db_cards (they contain the vendor name) all_card_names_list = Builtins.maplist( Convert.convert( Sound.db_cards, :from => "map", :to => "map <integer, list>" ) ) { |k, v| v } @all_card_names = Builtins.sort( Convert.convert( Builtins.flatten(all_card_names_list), :from => "list", :to => "list <string>" ) ) end return deep_copy(@all_card_names) end if keys == "vendors" # names from db_vendors (vendor name not included - not necessary) return Builtins.sort(Ops.get_list(Sound.db_vendors, key, [])) else return [Builtins.sformat("Sound card (%1)", key)] if !Sound.use_alsa mods = Builtins.mapmap( Convert.convert( Sound.db_module_index, :from => "map", :to => "map <integer, string>" ) ) { |k, v| { v => k } } index = Ops.get_integer(mods, key, 0) cards = Builtins.sort(Ops.get_list(Sound.db_cards, index, [])) if cards == [] cards = [Ops.get_string(Sound.db_modules, [key, "description"], "")] end return deep_copy(cards) end end |
- (Hash) get_module(card)
Looks up in the database for the module
720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 |
# File '../../src/include/sound/routines.rb', line 720 def get_module(card) card = deep_copy(card) Sound.LoadDatabase(true) bus = Ops.get_string(card, "bus", "") offset = Builtins.tolower(bus) == "isa" ? 131072 : 65536 vendor_id = Ops.subtract(Ops.get_integer(card, "vendor_id", 0), offset) device_id = Ops.subtract(Ops.get_integer(card, "device_id", 0), offset) m1 = Ops.get_map(Sound.db_indices, vendor_id, {}) Builtins.y2warning("vendor_id (%1) not found...", vendor_id) if m1 == {} m2 = Ops.get_integer(m1, device_id, -1) Builtins.y2warning("device_id (%1) not found", device_id) if m2 == -1 modname = "" if Builtins.haskey(Sound.db_module_index, m2) modname = Ops.get_string(Sound.db_module_index, m2, "") else Builtins.y2warning("Missing driver name in DB for card: %1", card) # driver for the sound card is not known # use value from hwinfo if present modname = Ops.get_string(card, ["drivers", 0, "modules", 0, 0], "") # convert module name - hwinfo might use _ in module name prefix (e.g. snd_via82xx) modname = Builtins.mergestring(Builtins.splitstring(modname, "_"), "-") if modname != "" Builtins.y2warning("Using driver provided by hwinfo: %1", modname) else Builtins.y2internal("Module for the card is unknown") # TODO: manual configuration is needed end end # ppc hack - use snd-aoa instead of snd-powermac (#217300) if modname == "snd-powermac" && layout_id Builtins.y2milestone( "Card '%1': Using snd-aoa driver instead of snd-powermac", Ops.get_string(card, "model", "") ) modname = "snd-aoa" end ret = Ops.get_map(Sound.db_modules, modname, {}) if !Builtins.haskey(ret, "name") # we must supply the 'name' key with the module name ret = Builtins.add(ret, "name", modname) end Builtins.y2milestone( "card: '%1', using module %2", Ops.get_string(card, "model", ""), modname ) deep_copy(ret) end |
- (Array) get_module_names
returns list of all available sound modules (OSS only)
330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 |
# File '../../src/include/sound/routines.rb', line 330 def get_module_names if @all_module_items == [] || @all_module_items == nil if Sound.use_alsa Sound.LoadDatabase(true) mods = Builtins.maplist( Convert.convert( Sound.db_modules, :from => "map", :to => "map <string, map <string, any>>" ) ) do |k, v| Item( Id(k), Builtins.sformat( _("%1 (%2)"), Ops.get_string(v, "description", k), k ) ) end mods = Builtins.sort(mods) do |a, b| Ops.less_than(Ops.get_string(a, 1, ""), Ops.get_string(b, 1, "")) end # item for all sound card models in sound card driver list mods = Builtins.prepend(mods, Item(Id("all"), _("All"))) @all_module_items = deep_copy(mods) else ret = SCR.Dir(path(".modinfo.kernel.sound.oss")) ret = Builtins.filter(ret) { |mod| mod != "sound" } ret = Builtins.add(ret, "emu10k1") ret = Builtins.add(ret, "cs4281") ret_t = Builtins.maplist(ret) do |e| modinfo = Convert.to_map( SCR.Read(Builtins.add(path(".modinfo.kernel.sound.oss"), e)) ) descr = Ops.get_string(modinfo, "module_description", "") Item(Id(e), descr != "" && descr != "<none>" ? descr : e) end ret_t = Builtins.sort(ret_t) do |a, b| Ops.less_than(Ops.get_string(a, 1, ""), Ops.get_string(b, 1, "")) end @all_module_items = deep_copy(ret_t) end end deep_copy(@all_module_items) end |
- (Hash) get_module_params(modname)
returns the 'params' section from sndcards.yml of the given module
211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 |
# File '../../src/include/sound/routines.rb', line 211 def get_module_params(modname) if !Sound.use_alsa params = Convert.convert( SCR.Read( Builtins.topath( Builtins.sformat(".modinfo.kernel.drivers.sound.%1", modname) ) ), :from => "any", :to => "map <string, string>" ) params = Builtins.filter(params) do |k, v| !Builtins.contains( ["module_author", "module_description", "module_filename"], k ) end return Builtins.mapmap(params) do |name, desc| { name => { "name" => name, "descr" => [desc], "type" => "string" } } end end Sound.LoadDatabase(true) Ops.get_map(Sound.db_modules, [modname, "params"], {}) end |
- (Object) get_running_cards
Returns list of already running cards (oss is nasty hacked, because it's not trivial to check this) @return [Array]
192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 |
# File '../../src/include/sound/routines.rb', line 192 def get_running_cards # return empty list in autoyast config mode return [] if Mode.config return [1, 2, 3, 4, 5] if !Sound.use_alsa proot = path(".audio.alsa.cards") cards = SCR.Dir(proot) Builtins.maplist(cards) do |c| { "number" => Builtins.tointeger(c), "name" => SCR.Read(Builtins.add(Builtins.add(proot, c), "name")) } end end |
- (Object) get_vol_settings
-
get_vol_settings
-
creates a list of stored values of volume and mute for each channel
-
of each card.
-
example: [ [ [“PCM”, 32, false], [“Master”, 100, true]], [ [.…], .…. ] ]
-
@return list as above
387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 |
# File '../../src/include/sound/routines.rb', line 387 def get_vol_settings return [] if !Sound.use_alsa Sound.LoadDatabase(true) bound = Builtins.size(SCR.Dir(path(".audio.alsa.cards"))) i = 0 retlist = [] while Ops.less_than(i, bound) volumelist = [] modname = Ops.get_string(Sound.modules_conf, [i, "module"], "snd-dummy") chans = Ops.get_list(Sound.db_modules, [modname, "mixer_elements"], []) if chans == [] if Builtins.contains( SCR.Dir(path(".audio.alsa.cards")), Builtins.sformat("%1", i) ) chans = SCR.Dir( Builtins.topath( Builtins.sformat(".audio.alsa.cards.%1.channels", i) ) ) else chans = [] end end Builtins.foreach(chans) do |e| pth1 = Builtins.topath( Builtins.sformat(".audio.alsa.cards.%1.channels.%2.volume", i, e) ) pth2 = Builtins.topath( Builtins.sformat(".audio.alsa.cards.%1.channels.%2.mute", i, e) ) volumelist = Builtins.add( volumelist, [e, SCR.Read(pth1), SCR.Read(pth2)] ) end retlist = Builtins.add(retlist, volumelist) i = Ops.add(i, 1) end deep_copy(retlist) end |
- (String) hardware_name(hardware_entry)
common function to extract 'name' of hardware
524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 |
# File '../../src/include/sound/routines.rb', line 524 def hardware_name(hardware_entry) hardware_entry = deep_copy(hardware_entry) Builtins.y2debug("hardware_entry: %1", hardware_entry) sub_vendor = Ops.get_string(hardware_entry, "sub_vendor", "") sub_device = Ops.get_string(hardware_entry, "sub_device", "") vendor = Ops.get_string(hardware_entry, "vendor", "") device = Ops.get_string(hardware_entry, "device", "") if sub_vendor != "" && sub_device != "" return Ops.add(Ops.add(sub_vendor, "\n"), sub_device) elsif vendor == "" && device == "" model = Ops.get_string(hardware_entry, "model", "") module_desc = Ops.get_string( hardware_entry, ["module", "description"], "" ) return Ops.add( Ops.greater_than(Builtins.size(model), 0) && Ops.greater_than(Builtins.size(module_desc), 0) ? Ops.add(Ops.add(model, " - "), module_desc) : model, module_desc ) else return Ops.add(Ops.add(vendor, vendor != "" ? "\n" : ""), device) end end |
- (Boolean) HasFonts(save_entry)
return true if the sound card supports SoundFonts
911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 |
# File '../../src/include/sound/routines.rb', line 911 def HasFonts(save_entry) save_entry = deep_copy(save_entry) if Mode.config # don't install SoundFonts during autoinstallation config return false end if Builtins.contains( ["snd-emu10k1", "snd-sbawe", "emu10k1"], Ops.get_string(save_entry, "module", "") ) return true end false end |
- (Object) initialize_sound_routines(include_target)
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File '../../src/include/sound/routines.rb', line 19 def initialize_sound_routines(include_target) Yast.import "UI" Yast.import "Directory" Yast.import "Mode" Yast.import "Popup" Yast.import "Sound" Yast.import "Label" Yast.import "Arch" textdomain "sound" # list of all card models (generated only once and cached) @all_card_names = [] # list of all sound modules (table items) @all_module_items = [] end |
- (Object) InstallFonts(symlink, dontask)
this small wizard will install SoundFonts for soundblaster live/awe @param [String] symlink is path to default.sf2 that is to be created @param [Boolean] dontask if true, skip the first messagebox @return [void]
932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 |
# File '../../src/include/sound/routines.rb', line 932 def InstallFonts(symlink, dontask) answer = false # step 1: want install? if dontask answer = true else answer = Popup.YesNoHeadline( Ops.get_string(Sound.STRINGS, "soundFontTitle", ""), Ops.get_string(Sound.STRINGS, "soundFontQuestion", "") ) end return if !answer while true detected_cds = detect_cdrom cdrom_device = "" if Builtins.size(detected_cds) == 0 # no CD device present, exit return # one CD device present, use it elsif Builtins.size(detected_cds) == 1 # step 2: insert CD if !Popup.ContinueCancelHeadline( Ops.get_string(Sound.STRINGS, "soundFontTitle", ""), Ops.get_string(Sound.STRINGS, "soundFontAppeal", "") ) return end cdrom_device = Ops.get_string( detected_cds, [0, "dev_name"], "/dev/cdrom" ) else # step 2: ask for a CD device ui = CDpopup( Ops.get_string(Sound.STRINGS, "soundFontTitle", ""), Ops.get_string(Sound.STRINGS, "soundFontAppeal", ""), detected_cds ) return if Ops.get_symbol(ui, "ui", :unknown) != :ok cdrom_device = Ops.get_string(ui, "dev_name", "/dev/cdrom") end Builtins.y2milestone("Using cdrom device: %1", cdrom_device) mpoint = mount_device(cdrom_device) Builtins.y2milestone("Device mounted: %1", mpoint) # number of found SoundFont files cnt = 0 if mpoint != nil # step3: do something res = Convert.to_map( SCR.Execute( path(".target.bash_output"), Ops.add(Ops.add(Directory.ybindir, "/copyfonts "), mpoint), {} ) ) Builtins.y2milestone("copyfonts output: %1", res) cnt = Builtins.tointeger(Ops.get_string(res, "stdout", "0")) Builtins.y2milestone("Device unmounted: %1", umount_device(mpoint)) # restart ALSA after SoundFont copy cmd = Ops.add(Directory.bindir, "/alsadrivers reload") Builtins.y2milestone("Executing: %1", cmd) SCR.Execute(path(".target.bash"), cmd) end # step4: if Ops.greater_than(cnt, 0) Popup.Message( Builtins.sformat( Ops.get_string(Sound.STRINGS, "soundFontFinal", ""), cnt, "/usr/share/sfbank/creative" ) ) return else if !Popup.YesNoHeadline( Ops.get_string(Sound.STRINGS, "soundFontNotFound", ""), Ops.get_string(Sound.STRINGS, "soundFontRetry", "") ) return end end end nil end |
- (Boolean) is_snd_alias(_alias)
returns true if given string is valid sound alias (snd-card-1 .. snd-card-16)
593 594 595 596 597 598 599 |
# File '../../src/include/sound/routines.rb', line 593 def is_snd_alias(_alias) if Sound.use_alsa return Builtins.regexpmatch(_alias, "^snd-card-[0-9]*$") else return Builtins.regexpmatch(_alias, "^sound-slot-[0-9]*$") end end |
- (String) isa_uniq
unique key for non-pci/pnp cards or virtual cards
603 604 605 |
# File '../../src/include/sound/routines.rb', line 603 def isa_uniq "uniq.unknown_key" end |
- (Array) itemize_list(l, default_value)
Itemize list for selection box
661 662 663 664 665 666 667 668 669 670 671 672 673 674 |
# File '../../src/include/sound/routines.rb', line 661 def itemize_list(l, default_value) l = deep_copy(l) i = 0 itemized_list = [] s = Builtins.size(l) while Ops.less_than(i, s) itemized_list = Builtins.add( itemized_list, Item(Id(i), Ops.get_string(l, i, ""), i == default_value) ) i = Ops.add(i, 1) end deep_copy(itemized_list) end |
- (Object) layout_id
690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 |
# File '../../src/include/sound/routines.rb', line 690 def layout_id ret = false if Arch.board_mac out = Convert.to_map( SCR.Execute( path(".target.bash_output"), "/usr/bin/find /proc/device-tree -name layout-id" ) ) if Ops.get_integer(out, "exit", -1) == 0 && Ops.greater_than( Builtins.size(Ops.get_string(out, "stdout", "")), 0 ) Builtins.y2milestone( "Layout-id property detected: %1", Ops.get_string(out, "stdout", "") ) ret = true end end ret end |
- (String) mount_device(device)
Mount specified device
119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File '../../src/include/sound/routines.rb', line 119 def mount_device(device) tmpdir = Convert.to_string(SCR.Read(path(".target.tmpdir"))) mpoint = Ops.add(tmpdir, "/mount") # create mount point directory SCR.Execute(path(".target.mkdir"), mpoint) # mount device result = Convert.to_boolean( SCR.Execute(path(".target.mount"), [device, mpoint], "-o ro") ) result == true ? mpoint : nil end |
- (Boolean) need_nm256_opl3sa2_warn(sound_cards)
does this machine need a nm256/opl3sa warning?
1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 |
# File '../../src/include/sound/routines.rb', line 1037 def need_nm256_opl3sa2_warn(sound_cards) sound_cards = deep_copy(sound_cards) mods = Builtins.maplist( Convert.convert( sound_cards, :from => "list", :to => "list <map <string, any>>" ) ) { |card| Ops.get_string(card, "module", "") } if Builtins.contains(mods, "snd-nm256") && Builtins.contains(mods, "snd-opl3sa2") return true end false end |
- (void) nm256_opl3sa2_warn(sound_cards)
This method returns an undefined value.
shows warning message when both nm265 and opl3sa2 cards are present
1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 |
# File '../../src/include/sound/routines.rb', line 1056 def nm256_opl3sa2_warn(sound_cards) sound_cards = deep_copy(sound_cards) s1 = Builtins.filter( Convert.convert( sound_cards, :from => "list", :to => "list <map <string, any>>" ) ) { |e| Ops.get_string(e, "module", "") == "snd-nm256" } s2 = Builtins.filter( Convert.convert( sound_cards, :from => "list", :to => "list <map <string, any>>" ) ) { |e| Ops.get_string(e, "module", "") == "snd-opl3sa2" } if Ops.greater_than(Builtins.size(s1), 0) && Ops.greater_than(Builtins.size(s2), 0) name1 = Ops.get_string(s1, [0, "model"], "") name2 = Ops.get_string(s2, [0, "model"], "") Popup.LongText( "", RichText( Ops.add( Ops.add( "<p>", Builtins.sformat( Ops.get_string(Sound.STRINGS, "opl3sa_nm256_warn", ""), name1, name2 ) ), "</p>" ) ), 50, 12 ) end nil end |
- (Object) nm256hack(modname)
show a warning popup for nm256 snd cards if needed @param [String] modname string module name @return [Boolean] continue/abort
681 682 683 684 685 686 687 688 |
# File '../../src/include/sound/routines.rb', line 681 def nm256hack(modname) if modname == "snd-nm256" # special warning message for in a special case warn_text = Ops.get_string(Sound.STRINGS, "nm256hackWarning", "") return Popup.YesNo(warn_text) end true end |
- (Hash) read_rc_vars
reads variables listed in 'vars' from rc.config
609 610 611 |
# File '../../src/include/sound/routines.rb', line 609 def read_rc_vars { "LOAD_ALSA_SEQ" => SCR.Read(path(".sysconfig.sound.LOAD_SEQUENCER")) } end |
- (Array) recalc_save_entries(save_info)
removes entries from save_info listed by indices in id_list
1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 |
# File '../../src/include/sound/routines.rb', line 1160 def recalc_save_entries(save_info) save_info = deep_copy(save_info) pos = 0 Builtins.maplist(save_info) do |card| opts = Ops.get_map(card, "options", {}) card = add_alias(card, pos) card = (card, pos) pos = Ops.add(pos, 1) deep_copy(card) end end |
- (Hash) restore_mod_params(params, values)
inserts values to already set options
860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 |
# File '../../src/include/sound/routines.rb', line 860 def restore_mod_params(params, values) params = deep_copy(params) values = deep_copy(values) ret = Builtins.mapmap( Convert.convert( params, :from => "map", :to => "map <string, map <string, any>>" ) ) do |parname, parmap| parmap = Builtins.add( parmap, "value", Ops.get_string(values, parname, "") ) { parname => parmap } end = ["index", "enable"] # add option from values map which are not contained in parms map Builtins.foreach( Convert.convert(values, :from => "map", :to => "map <string, string>") ) do |key, value| if !Builtins.haskey(params, key) && !Builtins.contains(, key) ret = Builtins.add(ret, key, { "value" => value }) Builtins.y2milestone("Added extra option: %1='%2'", key, value) end end Builtins.y2milestone("ret: %1", ret) deep_copy(ret) end |
- (Boolean) SaveUniqueKeys(configured, unconfigured)
saves uniq keys to .probe.status
617 618 619 620 621 622 623 624 625 626 627 628 629 |
# File '../../src/include/sound/routines.rb', line 617 def SaveUniqueKeys(configured, unconfigured) configured = deep_copy(configured) unconfigured = deep_copy(unconfigured) Builtins.maplist( Convert.convert(configured, :from => "list", :to => "list <string>") ) { |uk| SCR.Write(path(".probe.status.configured"), uk, :yes) } Builtins.maplist( Convert.convert(unconfigured, :from => "list", :to => "list <string>") ) { |uk| SCR.Write(path(".probe.status.configured"), uk, :no) } true end |
- (Fixnum) search_card_id(name)
Used for searching. returns index of the card in the database identified by name (more exactly: returns index of first name matching the given substring)
638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 |
# File '../../src/include/sound/routines.rb', line 638 def search_card_id(name) all_cards = get_card_names("all", "vendors") pos = 0 len = Builtins.size(name) name = Builtins.tolower(name) bound = Builtins.size(all_cards) while Ops.less_than(pos, bound) if Builtins.substring( Builtins.tolower(Ops.get_string(all_cards, pos, "")), 0, len ) == name return pos end pos = Ops.add(pos, 1) end -1 end |
- (Boolean) set_vol_settings(vol_settings)
stores values generated by get_vol_settings
436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 |
# File '../../src/include/sound/routines.rb', line 436 def set_vol_settings(vol_settings) vol_settings = deep_copy(vol_settings) return true if !Sound.use_alsa # during autoinstallation, vol_settings list looks different... :-( vol_settings = Builtins.maplist(vol_settings) do |it| if it == nil next {} else next deep_copy(it) end end if Mode.autoinst( ) if vol_settings.is_a?(Array) && vol_settings.first.is_a?(Array) && vol_settings.first.first.is_a?(Hash) Builtins.y2milestone("AutoYast data detected, converting...") # convert # [ # [ $["mute":false, "name":"Master", "volume":96], ... ] # [ ... ] # ] # to # [ # [ ["PCM", 32, false], ["Master", 100, true]], # [ [....], ..... ] # ] cnv_vol_settings = Builtins.maplist( Convert.convert( vol_settings, :from => "list", :to => "list <list <map>>" ) ) { |card_setting| Builtins.maplist(card_setting) do |channel_config| [ Ops.get_string(channel_config, "name", ""), Ops.get_integer(channel_config, "volume", 0), Ops.get_boolean(channel_config, "mute", true) ] end } Builtins.y2milestone( "Volume settings converted: %1 -> %2", vol_settings, cnv_vol_settings ) vol_settings = deep_copy(cnv_vol_settings) end item = Ops.get(vol_settings, 0) if Ops.is_map?(item) vol_settings = Builtins.maplist( Convert.convert(vol_settings, :from => "list", :to => "list <map>") ) { |onecard| Builtins.maplist(onecard) do |ch, vol| [ch, vol] end } end i = 0 Builtins.foreach( Convert.convert( vol_settings, :from => "list", :to => "list <list <list>>" ) ) do |channels| Builtins.foreach(channels) do |channel| name = Ops.get_string(channel, 0, "Master") pth1 = Builtins.topath( Builtins.sformat(".audio.alsa.cards.%1.channels.%2.volume", i, name) ) pth2 = Builtins.topath( Builtins.sformat(".audio.alsa.cards.%1.channels.%2.mute", i, name) ) SCR.Write(pth1, Ops.get_integer(channel, 1, 0)) SCR.Write(pth2, Ops.get_boolean(channel, 2, false)) end i = Ops.add(i, 1) end SCR.Execute(path(".audio.alsa.store"), "") true end |
- (Object) Thinkpad600E_cs4236_hack(card_id)
Hack for Thinkpad 600E notebook - it need cs4236 module instead of cs4610
1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 |
# File '../../src/include/sound/routines.rb', line 1102 def Thinkpad600E_cs4236_hack(card_id) card = deep_copy(Sound.save_entry) modname = "snd-cs4236" Builtins.foreach(Sound.detected_cards) do |c| if Ops.get_string(c, "unique_key", "") == Ops.get_string(card, "unique_key", "") # 1. is it right card? -> check subsystem + subvendor id if Ops.get_integer(c, "sub_device_id", 0) == 69648 && Ops.get_integer(c, "sub_vendor_id", 0) == 69652 && Ops.get_string(card, "module", "") != modname # popup question: different module has to be choosed if !Popup.YesNo( _( "It seems that you have a Thinkpad 600E laptop.\n" + "On this laptop, the CS4236 driver should be used\n" + "although the CS46xx chip is detected.\n" + "Attempt to probe the configuration of CS4236 driver?\n" + "\n" + "Warning: The probe procedure can take some time and\n" + "could make your system unstable.\n" ) ) next end ret = Sound.ProbeOldChip("cs4236") if ret != "" returned = Builtins.splitstring(ret, "\n") ret = Ops.get_string(returned, 0, "") = {} Builtins.foreach(Builtins.splitstring(ret, " ")) do |o| op = Builtins.splitstring(o, "=") if Builtins.size(op) == 2 = Builtins.add( , Ops.get_string(op, 0, ""), Ops.get_string(op, 1, "") ) end end Ops.set(card, "options", ) Ops.set(card, "module", modname) Sound.save_entry = Builtins.eval(card) # TODO save the card to unconfigured cards??? end end end end nil end |
- (Object) umount_device(mount_point)
134 135 136 |
# File '../../src/include/sound/routines.rb', line 134 def umount_device(mount_point) Convert.to_boolean(SCR.Execute(path(".target.umount"), mount_point)) end |
- (void) unmute(devices, card_id)
This method returns an undefined value.
umnute channel 'devide' of the 'card_id'-th sound card. alsa only
786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 |
# File '../../src/include/sound/routines.rb', line 786 def unmute(devices, card_id) devices = deep_copy(devices) return if Mode.config avail = SCR.Dir( Builtins.topath( Builtins.sformat(".audio.alsa.cards.%1.channels", card_id) ) ) avail = [] if avail == nil || Builtins.size(avail) == 0 Builtins.foreach( Convert.convert(devices, :from => "list", :to => "list <string>") ) do |dev| if Builtins.contains(avail, dev) SCR.Write( Builtins.topath( Builtins.sformat( ".audio.alsa.cards.%1.channels.%2.mute", card_id, dev ) ), false ) end end nil end |