# Path: resources/lib/model/audiodevice.py
# class AudioDevice:
#     def __init__(self):
#         self.original_name = None
#         self.card = None
#         self.device = None
#         self.subdevice = None
#         self.stream = None
#         self.id = None
#         self.name = None
#         self.subname = None
#         self.cls = None
#         self.subcls = None
#         self.subdevices_count = None
#         self.subdevices_avail = None
#         self.handler = ''
# 
#     def get_name(self):
#         if self.original_name == self.id:
#             return '%s - %s' % (self.id, self.name)
#         else:
#             return '%s - %s' % (self.id, self.original_name)


import os
import re
import xbmc
from resources.lib.model.audiodevice import AudioDevice
                for device in self.get_card_info(curr_idx, curr_id, curr_name):
                    self.devices.append(device)

    def get_card_info(self, idx, audio_id, audio_name):
        card_info_dir = os.path.abspath(os.path.join('/proc/asound/', 'card%s' % idx))
        subdevices = [x for x in next(os.walk(card_info_dir))]

        subdevices_info = []

        for subdevice in subdevices[1]:
            card_info_file = os.path.join(subdevices[0], subdevice, 'info')
            if not os.path.isfile(card_info_file):
                return
            with open(card_info_file) as f:
                card_info = f.readlines()
                f.close()

            device = AudioDevice()
            device.original_name = audio_name

            for entry in card_info:
                entry = entry.replace('\n', '')
                entry = entry.strip()
                components = entry.split(':')
                # components[0] is the key, [1] the value
                setattr(device, components[0].strip(), components[1].strip())

            device.handler = 'hw:%s,%s' % (device.card, device.device)

            if device.stream is None or device.stream == 'PLAYBACK':

# Path: resources/lib/model/audiodevice.py
# class AudioDevice:
#     def __init__(self):
#         self.original_name = None
#         self.card = None
#         self.device = None
#         self.subdevice = None
#         self.stream = None
#         self.id = None
#         self.name = None
#         self.subname = None
#         self.cls = None
#         self.subcls = None
#         self.subdevices_count = None
#         self.subdevices_avail = None
#         self.handler = ''
# 
#     def get_name(self):
#         if self.original_name == self.id:
#             return '%s - %s' % (self.id, self.name)
#         else:
#             return '%s - %s' % (self.id, self.original_name)


# Path: resources/lib/util/audiomanager.py
import os
import re
import xbmc
from resources.lib.model.audiodevice import AudioDevice

                for device in self.get_card_info(curr_idx, curr_id, curr_name):
                    self.devices.append(device)

    def get_card_info(self, idx, audio_id, audio_name):
        card_info_dir = os.path.abspath(os.path.join('/proc/asound/', 'card%s' % idx))
        subdevices = [x for x in next(os.walk(card_info_dir))]

        subdevices_info = []

        for subdevice in subdevices[1]:
            card_info_file = os.path.join(subdevices[0], subdevice, 'info')
            if not os.path.isfile(card_info_file):
                return
            with open(card_info_file) as f:
                card_info = f.readlines()
                f.close()

            device = AudioDevice()
            device.original_name = audio_name

            for entry in card_info:
                entry = entry.replace('\n', '')
                entry = entry.strip()
                components = entry.split(':')
                # components[0] is the key, [1] the value
                setattr(device, components[0].strip(), components[1].strip())

            device.handler = 'hw:%s,%s' % (device.card, device.device)

            if device.stream is None or device.stream == 'PLAYBACK':

                subdevices_info.append(device)