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

    PaSink *p;

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

    p->index = info->index;
    p->channels = info->channel_map.channels;
    p->monitor_index = info->monitor_source;
    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);

    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, 0x38(%rsp)
addq $0x100, %rsi            # imm = 0x100
leaq 0x60(%rsp), %rdi
callq 0xd180
movq 0x38(%rsp), %rdi
addq $0x38, %rdi
movq 0x68(%rsp), %rsi
addq $0x8, %rsi
callq 0xd3b0
movq %rax, 0x40(%rsp)
jmp 0xc527
movq 0x40(%rsp), %rax
cmpq $0x0, %rax
jne 0xc5d9
movl $0x278, %edi            # imm = 0x278
callq 0x76a0
movq %rax, 0x30(%rsp)
jmp 0xc547
movq 0x30(%rsp), %rdi
callq 0x9fc0
jmp 0xc553
movq 0x38(%rsp), %rdi
movq 0x30(%rsp), %rax
movq %rax, 0x58(%rsp)
movq 0x58(%rsp), %rax
movq %rax, 0x20(%rsp)
addq $0x38, %rdi
movq 0x68(%rsp), %rsi
addq $0x8, %rsi
callq 0xd410
movq %rax, 0x28(%rsp)
jmp 0xc585
movq 0x28(%rsp), %rax
movq 0x20(%rsp), %rcx
movq %rcx, (%rax)
movq 0x58(%rsp), %rax
movq $0x0, 0x220(%rax)
jmp 0xc604
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x50(%rsp)
movl %eax, 0x4c(%rsp)
jmp 0xc7a2
movq 0x30(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x50(%rsp)
movl %eax, 0x4c(%rsp)
movl $0x278, %esi            # imm = 0x278
callq 0x76c0
jmp 0xc7a2
movq 0x38(%rsp), %rdi
addq $0x38, %rdi
movq 0x68(%rsp), %rsi
addq $0x8, %rsi
callq 0xd410
movq %rax, 0x18(%rsp)
jmp 0xc5f7
movq 0x18(%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), %rax
movl 0x134(%rax), %ecx
movq 0x58(%rsp), %rax
movl %ecx, 0x21c(%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
movl 0x130(%rax), %eax
testl %eax, %eax
movq 0x58(%rsp), %rax
setne 0x218(%rax)
movq 0x58(%rsp), %rdi
addq $0x10, %rdi
movq 0x68(%rsp), %rax
movq 0x10(%rax), %rsi
movl $0xfe, %edx
movq %rdx, 0x10(%rsp)
callq 0x73b0
movq 0x10(%rsp), %rdx
movq 0x58(%rsp), %rdi
addq $0x10f, %rdi            # imm = 0x10F
movq 0x68(%rsp), %rax
movq (%rax), %rsi
callq 0x73b0
movq 0x58(%rsp), %rdi
movq 0x68(%rsp), %rax
movq 0x180(%rax), %rsi
movl 0x178(%rax), %edx
callq 0xa050
jmp 0xc6d2
movq 0x68(%rsp), %rax
cmpq $0x0, 0x188(%rax)
je 0xc787
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 0xc785
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 0x188(%rax), %rax
movq (%rax), %rsi
callq 0x7980
cmpl $0x0, %eax
jne 0xc773
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 0xc785
jmp 0xc775
movl 0x48(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x48(%rsp)
jmp 0xc6ed
jmp 0xc787
movq 0x38(%rsp), %rdi
callq 0xbe10
jmp 0xc793
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)