View Javadoc
1   /*
2    * Copyright 2020-2022 The OSHI Project Contributors
3    * SPDX-License-Identifier: MIT
4    */
5   package oshi.hardware.platform.unix.aix;
6   
7   import java.util.ArrayList;
8   import java.util.List;
9   import java.util.function.Supplier;
10  
11  import oshi.annotation.concurrent.Immutable;
12  import oshi.hardware.SoundCard;
13  import oshi.hardware.common.AbstractSoundCard;
14  import oshi.util.Constants;
15  import oshi.util.ParseUtil;
16  
17  /**
18   * AIX Sound Card.
19   */
20  @Immutable
21  final class AixSoundCard extends AbstractSoundCard {
22  
23      /**
24       * Constructor for AixSoundCard.
25       *
26       * @param kernelVersion The version
27       * @param name          The name
28       * @param codec         The codec
29       */
30      AixSoundCard(String kernelVersion, String name, String codec) {
31          super(kernelVersion, name, codec);
32      }
33  
34      /**
35       * Gets sound cards
36       *
37       * @param lscfg a memoized lscfg object
38       *
39       * @return sound cards
40       */
41      public static List<SoundCard> getSoundCards(Supplier<List<String>> lscfg) {
42          List<SoundCard> soundCards = new ArrayList<>();
43          for (String line : lscfg.get()) {
44              String s = line.trim();
45              if (s.startsWith("paud")) {
46                  String[] split = ParseUtil.whitespaces.split(s, 3);
47                  if (split.length == 3) {
48                      soundCards.add(new AixSoundCard(Constants.UNKNOWN, split[2], Constants.UNKNOWN));
49                  }
50              }
51          }
52          return soundCards;
53      }
54  }