Class LinuxSoundCard

java.lang.Object
oshi.hardware.common.AbstractSoundCard
oshi.hardware.platform.linux.LinuxSoundCard
All Implemented Interfaces:
SoundCard

@Immutable final class LinuxSoundCard extends AbstractSoundCard
Sound card data obtained via /proc/asound directory
  • Field Details

  • Constructor Details

    • LinuxSoundCard

      LinuxSoundCard(String kernelVersion, String name, String codec)
      Constructor for LinuxSoundCard.
      Parameters:
      kernelVersion - The version
      name - The name
      codec - The codec
  • Method Details

    • getCardFolders

      private static List<File> getCardFolders()
      Method to find all the card folders contained in the asound folder denoting the cards currently contained in our machine.
      Returns:
      : A list of files starting with 'card'
    • getSoundCardVersion

      private static String getSoundCardVersion()
      Reads the 'version' file in the asound folder that contains the complete name of the ALSA driver. Reads all the lines of the file and retrieves the first line.
      Returns:
      The complete name of the ALSA driver currently residing in our machine
    • getCardCodec

      private static String getCardCodec(File cardDir)
      Retrieves the codec of the sound card contained in the codec file. The name of the codec is always the first line of that file.
      Working
      This converts the codec file into key value pairs using the FileUtil class and then returns the value of the Codec key.
      Parameters:
      cardDir - The sound card directory
      Returns:
      The name of the codec
    • getCardName

      private static String getCardName(File file)
      Retrieves the name of the sound card by :
      1. Reading the id file and comparing each id with the card id present in the cards file
      2. If the id and the card name matches , then it assigns that name to cardName
      Parameters:
      file - The sound card File.
      Returns:
      The name of the sound card.
    • getSoundCards

      public static List<SoundCard> getSoundCards()
      public method used by AbstractHardwareAbstractionLayer to access the sound cards.
      Returns:
      List of LinuxSoundCard objects.