// File: fulhax[P]ncpamixer/src/pa.cpp
// Function: Pa::update_input(pa_sink_input_info const*)
void Pa::update_input(const pa_sink_input_info *info)
{

    std::lock_guard<std::mutex> lk(inputMtx);

    PaInput *p;

    bool sink_changed = true;

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

        if (PA_INPUTS.count(info->index)) {
            sink_changed = info->sink != p->sink;
        }
    }


    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;
    p->sink = info->sink;
    snprintf(p->name, sizeof(p->name), "%s", info->name);

    const auto app_name = pa_proplist_gets(info->proplist, PA_PROP_APPLICATION_NAME);
    p->app_name = (app_name != NULL) ? app_name : "Module";

    if (sink_changed) {
        create_monitor_stream_for_paobject(p);
    }

    notify_update();
}

// Assembly:
subq $0x88, %rsp
movq %rdi, 0x80(%rsp)
movq %rsi, 0x78(%rsp)
movq 0x80(%rsp), %rsi
movq %rsi, 0x38(%rsp)
addq $0x100, %rsi            # imm = 0x100
leaq 0x70(%rsp), %rdi
callq 0xd180
movq 0x38(%rsp), %rdi
movb $0x1, 0x67(%rsp)
addq $0x8, %rdi
movq 0x78(%rsp), %rsi
callq 0xd3b0
movq %rax, 0x40(%rsp)
jmp 0xc811
movq 0x40(%rsp), %rax
cmpq $0x0, %rax
jne 0xc8c2
movl $0x2a0, %edi            # imm = 0x2A0
callq 0x76a0
movq %rax, 0x30(%rsp)
jmp 0xc831
movq 0x30(%rsp), %rdi
callq 0xa550
jmp 0xc83d
movq 0x38(%rsp), %rdi
movq 0x30(%rsp), %rax
movq %rax, 0x68(%rsp)
movq 0x68(%rsp), %rax
movq %rax, 0x20(%rsp)
addq $0x8, %rdi
movq 0x78(%rsp), %rsi
callq 0xd410
movq %rax, 0x28(%rsp)
jmp 0xc86b
movq 0x28(%rsp), %rax
movq 0x20(%rsp), %rcx
movq %rcx, (%rax)
movq 0x68(%rsp), %rax
movq $0x0, 0x220(%rax)
jmp 0xc92c
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x58(%rsp)
movl %eax, 0x54(%rsp)
jmp 0xca56
movq 0x30(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x58(%rsp)
movl %eax, 0x54(%rsp)
movl $0x2a0, %esi            # imm = 0x2A0
callq 0x76c0
jmp 0xca56
movq 0x38(%rsp), %rdi
addq $0x8, %rdi
movq 0x78(%rsp), %rsi
callq 0xd410
movq %rax, 0x18(%rsp)
jmp 0xc8dc
movq 0x38(%rsp), %rdi
movq 0x18(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x68(%rsp)
addq $0x8, %rdi
movq 0x78(%rsp), %rsi
callq 0xd3b0
movq %rax, 0x10(%rsp)
jmp 0xc903
movq 0x10(%rsp), %rax
cmpq $0x0, %rax
je 0xc92a
movq 0x78(%rsp), %rax
movl 0x18(%rax), %eax
movq 0x68(%rsp), %rcx
cmpl 0x278(%rcx), %eax
setne %al
andb $0x1, %al
movb %al, 0x67(%rsp)
jmp 0xc92c
movq 0x78(%rsp), %rax
movl (%rax), %ecx
movq 0x68(%rsp), %rax
movl %ecx, 0xc(%rax)
movq 0x78(%rsp), %rax
movzbl 0x28(%rax), %ecx
movq 0x68(%rsp), %rax
movl %ecx, 0x210(%rax)
movq 0x78(%rsp), %rdi
addq $0xac, %rdi
callq 0x7ba0
movl %eax, %ecx
movq 0x68(%rsp), %rax
movl %ecx, 0x214(%rax)
movq 0x78(%rsp), %rax
movl 0x150(%rax), %eax
testl %eax, %eax
movq 0x68(%rsp), %rax
setne 0x218(%rax)
movq 0x78(%rsp), %rax
movl 0x18(%rax), %ecx
movq 0x68(%rsp), %rax
movl %ecx, 0x278(%rax)
movq 0x68(%rsp), %rdi
addq $0x10, %rdi
movq 0x78(%rsp), %rax
movq 0x8(%rax), %rcx
leaq 0x14fb3(%rip), %rdx     # 0x21965
xorl %eax, %eax
movl $0xff, %esi
callq 0x7b20
movq 0x78(%rsp), %rax
movq 0x158(%rax), %rdi
leaq 0x138c3(%rip), %rsi     # 0x20294
callq 0x75f0
movq %rax, 0x8(%rsp)
jmp 0xc9dd
movq 0x8(%rsp), %rax
movq %rax, 0x48(%rsp)
cmpq $0x0, 0x48(%rsp)
je 0xc9fa
movq 0x48(%rsp), %rax
movq %rax, (%rsp)
jmp 0xca07
leaq 0x1397b(%rip), %rax     # 0x2037c
movq %rax, (%rsp)
jmp 0xca07
movq (%rsp), %rsi
movq 0x68(%rsp), %rdi
addq $0x280, %rdi            # imm = 0x280
callq 0x7920
jmp 0xca1e
testb $0x1, 0x67(%rsp)
je 0xca38
movq 0x38(%rsp), %rdi
movq 0x68(%rsp), %rsi
callq 0xc140
jmp 0xca36
jmp 0xca38
movq 0x38(%rsp), %rdi
callq 0xbe10
jmp 0xca44
leaq 0x70(%rsp), %rdi
callq 0xd290
addq $0x88, %rsp
retq
leaq 0x70(%rsp), %rdi
callq 0xd290
movq 0x58(%rsp), %rdi
callq 0x7c40
nopw (%rax,%rax)