// File: /workspace/github_cpp_makefile_star2_O2/tobias93[P]piano/rtaudio/tests/duplex.cpp
// Function: main
int main( int argc, char *argv[] )
{
  unsigned int channels, fs, bufferBytes, oDevice = 0, iDevice = 0, iOffset = 0, oOffset = 0;

  // Minimal command-line checking
  if (argc < 3 || argc > 7 ) usage();

  RtAudio adac;
  if ( adac.getDeviceCount() < 1 ) {
    std::cout << "\nNo audio devices found!\n";
    exit( 1 );
  }

  channels = (unsigned int) atoi(argv[1]);
  fs = (unsigned int) atoi(argv[2]);
  if ( argc > 3 )
    iDevice = (unsigned int) atoi(argv[3]);
  if ( argc > 4 )
    oDevice = (unsigned int) atoi(argv[4]);
  if ( argc > 5 )
    iOffset = (unsigned int) atoi(argv[5]);
  if ( argc > 6 )
    oOffset = (unsigned int) atoi(argv[6]);

  // Let RtAudio print messages to stderr.
  adac.showWarnings( true );

  // Set the same number of channels for both input and output.
  unsigned int bufferFrames = 512;
  RtAudio::StreamParameters iParams, oParams;
  iParams.deviceId = iDevice;
  iParams.nChannels = channels;
  iParams.firstChannel = iOffset;
  oParams.deviceId = oDevice;
  oParams.nChannels = channels;
  oParams.firstChannel = oOffset;

  if ( iDevice == 0 )
    iParams.deviceId = adac.getDefaultInputDevice();
  if ( oDevice == 0 )
    oParams.deviceId = adac.getDefaultOutputDevice();

  RtAudio::StreamOptions options;
  //options.flags |= RTAUDIO_NONINTERLEAVED;

  bufferBytes = bufferFrames * channels * sizeof( MY_TYPE );
  try {
    adac.openStream( &oParams, &iParams, FORMAT, fs, &bufferFrames, &inout, (void *)&bufferBytes, &options );
  }
  catch ( RtAudioError& e ) {
    std::cout << '\n' << e.getMessage() << '\n' << std::endl;
    exit( 1 );
  }

  // Test RtAudio functionality for reporting latency.
  std::cout << "\nStream latency = " << adac.getStreamLatency() << " frames" << std::endl;

  try {
    adac.startStream();

    char input;
    std::cout << "\nRunning ... press <enter> to quit (buffer frames = " << bufferFrames << ").\n";
    std::cin.get(input);

    // Stop the stream.
    adac.stopStream();
  }
  catch ( RtAudioError& e ) {
    std::cout << '\n' << e.getMessage() << '\n' << std::endl;
    goto cleanup;
  }

 cleanup:
  if ( adac.isStreamOpen() ) adac.closeStream();

  return 0;
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x68, %rsp
movl %edi, %ebp
leal -0x8(%rbp), %eax
cmpl $-0x6, %eax
jbe 0x483e
movq %rsi, %r13
leaq 0x8(%rsp), %rbx
movq %rbx, %rdi
xorl %esi, %esi
callq 0x4a5e
movq %rbx, %rdi
callq 0x494c
testl %eax, %eax
je 0x4843
movq 0x8(%r13), %rdi
callq 0x4300
movl %eax, %r14d
movq 0x10(%r13), %rdi
callq 0x4300
movl %eax, 0x18(%rsp)
cmpl $0x4, %ebp
jb 0x466c
movq 0x18(%r13), %rdi
callq 0x4300
movl %eax, %r15d
cmpl $0x4, %ebp
jne 0x4804
xorl %ebx, %ebx
jmp 0x4671
xorl %ebx, %ebx
xorl %r15d, %r15d
xorl %r12d, %r12d
xorl %eax, %eax
movq 0x8(%rsp), %rcx
movb $0x1, 0x1a0(%rcx)
movl $0x200, 0x14(%rsp)      # imm = 0x200
movl %r15d, 0x28(%rsp)
movl %r14d, 0x2c(%rsp)
movl %ebx, 0x30(%rsp)
movl %r12d, 0x1c(%rsp)
movl %r14d, 0x20(%rsp)
movl %eax, 0x24(%rsp)
testl %r15d, %r15d
jne 0x46b9
leaq 0x8(%rsp), %rdi
callq 0x4960
movl %eax, 0x28(%rsp)
testl %r12d, %r12d
jne 0x46cc
leaq 0x8(%rsp), %rdi
callq 0x4974
movl %eax, 0x1c(%rsp)
leaq 0x40(%rsp), %rbx
andq $0x0, -0x8(%rbx)
leaq 0x50(%rsp), %rax
movq %rax, -0x10(%rax)
andq $0x0, -0x8(%rax)
movb $0x0, (%rax)
andl $0x0, 0x10(%rax)
leaq 0x14(%rsp), %r9
imull (%r9), %r14d
addl %r14d, %r14d
leaq 0x34(%rsp), %rax
movl %r14d, (%rax)
leaq 0x38(%rsp), %r10
leaq -0x157(%rip), %r11      # 0x45b4
leaq 0x8(%rsp), %rdi
leaq 0x1c(%rsp), %rsi
leaq 0x28(%rsp), %rdx
pushq $0x2
popq %rcx
movl 0x18(%rsp), %r8d
pushq $0x0
pushq %r10
pushq %rax
pushq %r11
callq 0x4b82
addq $0x20, %rsp
movq 0x788f(%rip), %rdi      # 0xbfc8
leaq 0x3a8e(%rip), %rsi      # 0x81ce
callq 0x41e0
movq %rax, %r14
movq 0x8(%rsp), %rdi
callq 0x51cc
movq %r14, %rdi
movq %rax, %rsi
callq 0x41d0
leaq 0x3a7d(%rip), %rsi      # 0x81e1
movq %rax, %rdi
callq 0x41e0
movq %rax, %rdi
callq 0x40d0
movq 0x8(%rsp), %rdi
movq (%rdi), %rax
callq *0x40(%rax)
movq 0x7842(%rip), %rdi      # 0xbfc8
leaq 0x3a5c(%rip), %rsi      # 0x81e9
callq 0x41e0
movl 0x14(%rsp), %esi
movq %rax, %rdi
callq 0x4140
leaq 0x3a79(%rip), %rsi      # 0x821e
movq %rax, %rdi
callq 0x41e0
movq 0x7824(%rip), %rdi      # 0xbfd8
leaq 0x13(%rsp), %rsi
callq 0x4290
movq 0x8(%rsp), %rdi
movq (%rdi), %rax
callq *0x48(%rax)
movq 0x8(%rsp), %rax
cmpl $-0x32, 0x1bc(%rax)
je 0x47e1
leaq 0x8(%rsp), %rdi
callq 0x4994
movq %rbx, %rdi
callq 0x40c0
leaq 0x8(%rsp), %rdi
callq 0x4b72
xorl %eax, %eax
addq $0x68, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
movq 0x20(%r13), %rdi
callq 0x4300
movl %eax, %r12d
cmpl $0x6, %ebp
jb 0x4837
movq 0x28(%r13), %rdi
callq 0x4300
movl %eax, %ebx
cmpl $0x6, %ebp
je 0x4674
movq 0x30(%r13), %rdi
callq 0x4300
jmp 0x4676
xorl %ebx, %ebx
jmp 0x4674
callq 0x453c
movq 0x777e(%rip), %rdi      # 0xbfc8
leaq 0x3963(%rip), %rsi      # 0x81b4
callq 0x41e0
pushq $0x1
popq %rdi
callq 0x4250
movq %rax, %r14
jmp 0x4939
jmp 0x48c4
movq %rax, %r14
cmpl $0x1, %edx
jne 0x4931
movq %r14, %rdi
callq 0x4090
movq %rax, %r14
movq 0x7742(%rip), %rdi      # 0xbfc8
pushq $0xa
popq %rsi
callq 0x4210
movq %rax, %r15
movq (%r14), %rax
movq %r14, %rdi
callq *0x28(%rax)
movq %r15, %rdi
movq %rax, %rsi
callq 0x41a0
pushq $0xa
popq %rsi
movq %rax, %rdi
callq 0x4210
movq %rax, %rdi
callq 0x40d0
jmp 0x4856
movq %rax, %r14
callq 0x4360
jmp 0x4931
movq %rax, %r14
cmpl $0x1, %edx
jne 0x4931
movq %r14, %rdi
callq 0x4090
movq %rax, %r14
movq 0x76ea(%rip), %rdi      # 0xbfc8
pushq $0xa
popq %rsi
callq 0x4210
movq %rax, %r15
movq (%r14), %rax
movq %r14, %rdi
callq *0x28(%rax)
movq %r15, %rdi
movq %rax, %rsi
callq 0x41a0
pushq $0xa
popq %rsi
movq %rax, %rdi
callq 0x4210
movq %rax, %rdi
callq 0x40d0
callq 0x4360
jmp 0x47c9
jmp 0x492e
movq %rax, %r14
callq 0x4360
jmp 0x4931
movq %rax, %rdi
callq 0x4988
movq %rax, %r14
movq %rbx, %rdi
callq 0x40c0
leaq 0x8(%rsp), %rdi
callq 0x4b72
movq %r14, %rdi
callq 0x4380
nop