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

    // https://github.com/pulseaudio/pavucontrol/blob/master/src/mainwindow.cc#L802
    const char *app;

    if ((app = pa_proplist_gets(info->proplist, PA_PROP_APPLICATION_ID))) {
        if (strcmp(app, "org.PulseAudio.pavucontrol") == 0
            || strcmp(app, "org.gnome.VolumeControl") == 0
            || strcmp(app, "org.kde.kmixd") == 0
            || strcmp(app, "ncpamixer") == 0) {
            return;
        }
    }

    PaSourceOutput *p;

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

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

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

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

    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 0x78(%rsp), %rax
movq 0xd0(%rax), %rdi
leaq 0x1475a(%rip), %rsi     # 0x202af
callq 0x75f0
movq %rax, 0x40(%rsp)
jmp 0xbb61
movq 0x40(%rsp), %rax
movq %rax, 0x68(%rsp)
cmpq $0x0, %rax
je 0xbbeb
movq 0x68(%rsp), %rdi
leaq 0x147be(%rip), %rsi     # 0x2033b
callq 0x7980
cmpl $0x0, %eax
je 0xbbc9
movq 0x68(%rsp), %rdi
leaq 0x147c3(%rip), %rsi     # 0x20356
callq 0x7980
cmpl $0x0, %eax
je 0xbbc9
movq 0x68(%rsp), %rdi
leaq 0x147c5(%rip), %rsi     # 0x2036e
callq 0x7980
cmpl $0x0, %eax
je 0xbbc9
movq 0x68(%rsp), %rdi
leaq 0x146e6(%rip), %rsi     # 0x202a5
callq 0x7980
cmpl $0x0, %eax
jne 0xbbe9
movl $0x1, 0x58(%rsp)
jmp 0xbde0
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x60(%rsp)
movl %eax, 0x5c(%rsp)
jmp 0xbdf2
jmp 0xbbeb
movq 0x38(%rsp), %rdi
addq $0x98, %rdi
movq 0x78(%rsp), %rsi
callq 0xd3b0
movq %rax, 0x30(%rsp)
jmp 0xbc08
movq 0x30(%rsp), %rax
cmpq $0x0, %rax
jne 0xbca6
movl $0x2a8, %edi            # imm = 0x2A8
callq 0x76a0
movq %rax, 0x28(%rsp)
jmp 0xbc28
movq 0x28(%rsp), %rdi
callq 0xa860
jmp 0xbc34
movq 0x38(%rsp), %rdi
movq 0x28(%rsp), %rax
movq %rax, 0x50(%rsp)
movq 0x50(%rsp), %rax
movq %rax, 0x18(%rsp)
addq $0x98, %rdi
movq 0x78(%rsp), %rsi
callq 0xd410
movq %rax, 0x20(%rsp)
jmp 0xbc65
movq 0x20(%rsp), %rax
movq 0x18(%rsp), %rcx
movq %rcx, (%rax)
movq 0x50(%rsp), %rax
movq $0x0, 0x220(%rax)
jmp 0xbcd0
movq 0x28(%rsp), %rdi
movq %rax, %rcx
movl %edx, %eax
movq %rcx, 0x60(%rsp)
movl %eax, 0x5c(%rsp)
movl $0x2a8, %esi            # imm = 0x2A8
callq 0x76c0
jmp 0xbdf2
movq 0x38(%rsp), %rdi
addq $0x98, %rdi
movq 0x78(%rsp), %rsi
callq 0xd410
movq %rax, 0x10(%rsp)
jmp 0xbcc3
movq 0x10(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x50(%rsp)
movq 0x78(%rsp), %rax
movl (%rax), %ecx
movq 0x50(%rsp), %rax
movl %ecx, 0xc(%rax)
movq 0x78(%rsp), %rax
movl 0x18(%rax), %ecx
movq 0x50(%rsp), %rax
movl %ecx, 0x2a0(%rax)
movq 0x78(%rsp), %rax
movzbl 0x28(%rax), %ecx
movq 0x50(%rsp), %rax
movl %ecx, 0x210(%rax)
movq 0x78(%rsp), %rax
movl 0x18(%rax), %ecx
movq 0x50(%rsp), %rax
movl %ecx, 0x21c(%rax)
movq 0x78(%rsp), %rdi
addq $0xdc, %rdi
callq 0x7ba0
movl %eax, %ecx
movq 0x50(%rsp), %rax
movl %ecx, 0x214(%rax)
movq 0x78(%rsp), %rax
movl 0x160(%rax), %eax
testl %eax, %eax
movq 0x50(%rsp), %rax
setne 0x218(%rax)
movq 0x50(%rsp), %rdi
addq $0x10, %rdi
movq 0x78(%rsp), %rax
movq 0x8(%rax), %rsi
movl $0xfe, %edx
callq 0x73b0
movq 0x78(%rsp), %rax
movq 0xd0(%rax), %rdi
leaq 0x14515(%rip), %rsi     # 0x20294
callq 0x75f0
movq %rax, 0x8(%rsp)
jmp 0xbd8b
movq 0x8(%rsp), %rax
movq %rax, 0x48(%rsp)
cmpq $0x0, 0x48(%rsp)
je 0xbda8
movq 0x48(%rsp), %rax
movq %rax, (%rsp)
jmp 0xbdb5
leaq 0x145cd(%rip), %rax     # 0x2037c
movq %rax, (%rsp)
jmp 0xbdb5
movq (%rsp), %rsi
movq 0x50(%rsp), %rdi
addq $0x280, %rdi            # imm = 0x280
callq 0x7920
jmp 0xbdcc
movq 0x38(%rsp), %rdi
callq 0xbe10
jmp 0xbdd8
movl $0x0, 0x58(%rsp)
leaq 0x70(%rsp), %rdi
callq 0xd290
addq $0x88, %rsp
retq
leaq 0x70(%rsp), %rdi
callq 0xd290
movq 0x60(%rsp), %rdi
callq 0x7c40
nopw %cs:(%rax,%rax)