FileDocCategorySizeDatePackage
AlsaCardsParser.javaAPI DocAndroid 5.1 API3906Thu Mar 12 22:22:08 GMT 2015android.alsa

AlsaCardsParser

public class AlsaCardsParser extends Object
hide
Retrieves information from an ALSA "cards" file.

Fields Summary
private static final String
TAG
private static LineTokenizer
tokenizer_
private Vector
cardRecords_
Constructors Summary
public AlsaCardsParser()

Methods Summary
public voidLog()

      int numCardRecs = getNumCardRecords();
      for (int index = 0; index < numCardRecs; ++index) {
          Slog.w(TAG, "usb:" + getCardRecordAt(index).textFormat());
      }
    
public android.alsa.AlsaCardsParser$AlsaCardRecordgetCardRecordAt(int index)

          return cardRecords_.get(index);
      
public intgetNumCardRecords()

          return cardRecords_.size();
      
public voidscan()


       
          cardRecords_.clear();
          final String cardsFilePath = "/proc/asound/cards";
          File cardsFile = new File(cardsFilePath);
          try {
              FileReader reader = new FileReader(cardsFile);
              BufferedReader bufferedReader = new BufferedReader(reader);
              String line = "";
              while ((line = bufferedReader.readLine()) != null) {
                  AlsaCardRecord cardRecord = new AlsaCardRecord();
                  cardRecord.parse(line, 0);
                  cardRecord.parse(line = bufferedReader.readLine(), 1);
                  cardRecords_.add(cardRecord);
              }
              reader.close();
          } catch (FileNotFoundException e) {
              e.printStackTrace();
          } catch (IOException e) {
              e.printStackTrace();
          }