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

    PaSource *p;

    bool newObj = false;

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

    p->index = info->index;
    p->channels = info->channel_map.channels;
    p->volume = (const pa_volume_t) pa_cvolume_avg(&info->volume);
    p->mute = info->mute;

    strncpy(p->name, info->description, sizeof(p->name) - 1);
    strncpy(p->pa_name, info->name, sizeof(p->pa_name) - 1);

    if (newObj) {
        create_monitor_stream_for_paobject(p);
    }

    p->updatePorts(info->ports, info->n_ports);

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

    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
movb $0x0, 0x57(%rsp)
addq $0x68, %rdi
movq 0x68(%rsp), %rsi
addq $0x8, %rsi
callq 0xd3b0
movq %rax, 0x38(%rsp)
jmp 0xbe8c
movq 0x38(%rsp), %rax
cmpq $0x0, %rax
jne 0xbf56
movl $0x278, %edi            # imm = 0x278
callq 0x76a0
movq %rax, 0x28(%rsp)
jmp 0xbeac
movq 0x28(%rsp), %rdi
callq 0xa6a0
jmp 0xbeb8
movq 0x30(%rsp), %rdi
movq 0x28(%rsp), %rax
movq %rax, 0x58(%rsp)
movq 0x58(%rsp), %rax
movq %rax, 0x18(%rsp)
addq $0x68, %rdi
movq 0x68(%rsp), %rsi
addq $0x8, %rsi
callq 0xd410
movq %rax, 0x20(%rsp)
jmp 0xbeea
movq 0x20(%rsp), %rax
movq 0x18(%rsp), %rcx
movq %rcx, (%rax)
movq 0x68(%rsp), %rax
movl 0x8(%rax), %ecx
movq 0x58(%rsp), %rax
movl %ecx, 0x21c(%rax)
movq 0x58(%rsp), %rax
movq $0x0, 0x220(%rax)
movb $0x1, 0x57(%rsp)
jmp 0xbf81
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x48(%rsp)
movl %eax, 0x44(%rsp)
jmp 0xc122
movq 0x28(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x48(%rsp)
movl %eax, 0x44(%rsp)
movl $0x278, %esi            # imm = 0x278
callq 0x76c0
jmp 0xc122
movq 0x30(%rsp), %rdi
addq $0x68, %rdi
movq 0x68(%rsp), %rsi
addq $0x8, %rsi
callq 0xd410
movq %rax, 0x10(%rsp)
jmp 0xbf74
movq 0x10(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x58(%rsp)
movq 0x68(%rsp), %rax
movl 0x8(%rax), %ecx
movq 0x58(%rsp), %rax
movl %ecx, 0xc(%rax)
movq 0x68(%rsp), %rax
movzbl 0x24(%rax), %ecx
movq 0x58(%rsp), %rax
movl %ecx, 0x210(%rax)
movq 0x68(%rsp), %rdi
addq $0xac, %rdi
callq 0x7ba0
movl %eax, %ecx
movq 0x58(%rsp), %rax
movl %ecx, 0x214(%rax)
movq 0x68(%rsp), %rax
cmpl $0x0, 0x130(%rax)
setne %cl
movq 0x58(%rsp), %rax
andb $0x1, %cl
movb %cl, 0x218(%rax)
movq 0x58(%rsp), %rdi
addq $0x10, %rdi
movq 0x68(%rsp), %rax
movq 0x10(%rax), %rsi
movl $0xfe, %edx
callq 0x73b0
movq 0x58(%rsp), %rdi
addq $0x10f, %rdi            # imm = 0x10F
movq 0x68(%rsp), %rax
movq (%rax), %rsi
movl $0xfe, %edx
callq 0x73b0
testb $0x1, 0x57(%rsp)
je 0xc034
movq 0x30(%rsp), %rdi
movq 0x58(%rsp), %rsi
callq 0xc140
jmp 0xc032
jmp 0xc034
movq 0x58(%rsp), %rdi
movq 0x68(%rsp), %rax
movq 0x180(%rax), %rsi
movl 0x178(%rax), %edx
callq 0xa730
jmp 0xc052
movq 0x68(%rsp), %rax
cmpq $0x0, 0x188(%rax)
je 0xc107
movl $0x0, 0x40(%rsp)
movl 0x40(%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 0xc105
movq 0x58(%rsp), %rdi
addq $0x238, %rdi            # imm = 0x238
movl 0x40(%rsp), %eax
movl %eax, %esi
callq 0x92e0
movq (%rax), %rdi
addq $0x8, %rdi
movq 0x68(%rsp), %rax
movq 0x188(%rax), %rax
movq (%rax), %rsi
callq 0x7980
cmpl $0x0, %eax
jne 0xc0f3
movq 0x58(%rsp), %rdi
addq $0x238, %rdi            # imm = 0x238
movl 0x40(%rsp), %eax
movl %eax, %esi
callq 0x92e0
movq (%rax), %rcx
movq 0x58(%rsp), %rax
movq %rcx, 0x230(%rax)
jmp 0xc105
jmp 0xc0f5
movl 0x40(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x40(%rsp)
jmp 0xc06d
jmp 0xc107
movq 0x30(%rsp), %rdi
callq 0xbe10
jmp 0xc113
leaq 0x60(%rsp), %rdi
callq 0xd290
addq $0x78, %rsp
retq
leaq 0x60(%rsp), %rdi
callq 0xd290
movq 0x48(%rsp), %rdi
callq 0x7c40
nopw %cs:(%rax,%rax)