// File: fulhax[P]ncpamixer/src/pa.cpp
// Function: Pa::update_card(pa_card_info const*)
void Pa::update_card(const pa_card_info *info)
{
    std::lock_guard<std::mutex> lk(inputMtx);
    PaCard *p;

    if (PA_CARDS.count(info->index) == 0) {
        p = new PaCard;
        PA_CARDS[info->index] = p;
        p->monitor_index = info->index;
        p->monitor_stream = nullptr;
    } else {
        p = reinterpret_cast<PaCard *>(PA_CARDS[info->index]);
    }

    p->index = info->index;
    p->channels = 0;
    p->volume = 0;
    p->mute = false;
    p->updateProfiles(info->profiles, info->n_profiles);
    p->active_attribute = nullptr;

    if (info->active_profile != nullptr) {
        for (uint32_t i = 0; i < p->attributes.size(); i++) {
            if (strcmp(p->attributes[i]->name, info->active_profile->name) == 0) {
                p->active_attribute = p->attributes[i];
                break;
            }
        }
    }

    const char *description;
    description = pa_proplist_gets(info->proplist, PA_PROP_DEVICE_DESCRIPTION);

    if (description) {
        snprintf(p->name, sizeof(p->name), "%s", description);
    } else {
        snprintf(p->name, sizeof(p->name), "%s", info->name);
    }

    notify_update();
}

// Assembly:
subq $0x78, %rsp
movq %rdi, 0x70(%rsp)
movq %rsi, 0x68(%rsp)
movq 0x70(%rsp), %rsi
movq %rsi, 0x30(%rsp)
addq $0x100, %rsi            # imm = 0x100
leaq 0x60(%rsp), %rdi
callq 0xd180
movq 0x30(%rsp), %rdi
addq $0xc8, %rdi
movq 0x68(%rsp), %rsi
callq 0xd3b0
movq %rax, 0x38(%rsp)
jmp 0xc236
movq 0x38(%rsp), %rax
cmpq $0x0, %rax
jne 0xc2f9
movl $0x278, %edi            # imm = 0x278
callq 0x76a0
movq %rax, 0x28(%rsp)
jmp 0xc256
movq 0x28(%rsp), %rdi
callq 0x95e0
jmp 0xc262
movq 0x30(%rsp), %rdi
movq 0x28(%rsp), %rax
movq %rax, 0x58(%rsp)
movq 0x58(%rsp), %rax
movq %rax, 0x18(%rsp)
addq $0xc8, %rdi
movq 0x68(%rsp), %rsi
callq 0xd410
movq %rax, 0x20(%rsp)
jmp 0xc293
movq 0x20(%rsp), %rax
movq 0x18(%rsp), %rcx
movq %rcx, (%rax)
movq 0x68(%rsp), %rax
movl (%rax), %ecx
movq 0x58(%rsp), %rax
movl %ecx, 0x21c(%rax)
movq 0x58(%rsp), %rax
movq $0x0, 0x220(%rax)
jmp 0xc323
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x50(%rsp)
movl %eax, 0x4c(%rsp)
jmp 0xc4c2
movq 0x28(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x50(%rsp)
movl %eax, 0x4c(%rsp)
movl $0x278, %esi            # imm = 0x278
callq 0x76c0
jmp 0xc4c2
movq 0x30(%rsp), %rdi
addq $0xc8, %rdi
movq 0x68(%rsp), %rsi
callq 0xd410
movq %rax, 0x10(%rsp)
jmp 0xc316
movq 0x10(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x58(%rsp)
movq 0x68(%rsp), %rax
movl (%rax), %ecx
movq 0x58(%rsp), %rax
movl %ecx, 0xc(%rax)
movq 0x58(%rsp), %rax
movl $0x0, 0x210(%rax)
movq 0x58(%rsp), %rax
movl $0x0, 0x214(%rax)
movq 0x58(%rsp), %rax
movb $0x0, 0x218(%rax)
movq 0x58(%rsp), %rdi
movq 0x68(%rsp), %rax
movq 0x28(%rax), %rsi
movl 0x20(%rax), %edx
callq 0x9670
jmp 0xc374
movq 0x58(%rsp), %rax
movq $0x0, 0x230(%rax)
movq 0x68(%rsp), %rax
cmpq $0x0, 0x30(%rax)
je 0xc433
movl $0x0, 0x48(%rsp)
movl 0x48(%rsp), %eax
movq %rax, 0x8(%rsp)
movq 0x58(%rsp), %rdi
addq $0x238, %rdi            # imm = 0x238
callq 0x92c0
movq %rax, %rcx
movq 0x8(%rsp), %rax
cmpq %rcx, %rax
jae 0xc431
movq 0x58(%rsp), %rdi
addq $0x238, %rdi            # imm = 0x238
movl 0x48(%rsp), %eax
movl %eax, %esi
callq 0x92e0
movq (%rax), %rdi
addq $0x8, %rdi
movq 0x68(%rsp), %rax
movq 0x30(%rax), %rax
movq (%rax), %rsi
callq 0x7980
cmpl $0x0, %eax
jne 0xc41f
movq 0x58(%rsp), %rdi
addq $0x238, %rdi            # imm = 0x238
movl 0x48(%rsp), %eax
movl %eax, %esi
callq 0x92e0
movq (%rax), %rcx
movq 0x58(%rsp), %rax
movq %rcx, 0x230(%rax)
jmp 0xc431
jmp 0xc421
movl 0x48(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x48(%rsp)
jmp 0xc39c
jmp 0xc433
movq 0x68(%rsp), %rax
movq 0x38(%rax), %rdi
leaq 0x13f40(%rip), %rsi     # 0x20383
callq 0x75f0
movq %rax, (%rsp)
jmp 0xc44e
movq (%rsp), %rax
movq %rax, 0x40(%rsp)
cmpq $0x0, 0x40(%rsp)
je 0xc482
movq 0x58(%rsp), %rdi
addq $0x10, %rdi
movq 0x40(%rsp), %rcx
movl $0xff, %esi
leaq 0x154ec(%rip), %rdx     # 0x21965
movb $0x0, %al
callq 0x7b20
jmp 0xc4a7
movq 0x58(%rsp), %rdi
addq $0x10, %rdi
movq 0x68(%rsp), %rax
movq 0x8(%rax), %rcx
movl $0xff, %esi
leaq 0x154c5(%rip), %rdx     # 0x21965
movb $0x0, %al
callq 0x7b20
movq 0x30(%rsp), %rdi
callq 0xbe10
jmp 0xc4b3
leaq 0x60(%rsp), %rdi
callq 0xd290
addq $0x78, %rsp
retq
leaq 0x60(%rsp), %rdi
callq 0xd290
movq 0x50(%rsp), %rdi
callq 0x7c40
nopw %cs:(%rax,%rax)