Can't play audio from SCNNode

SCNNode.addAudioPlayer() doesn't play any audio as documented. I have a valid SCNAudioPlayer, created with a valid SCNAudioSource from a valid audio file format.


I've also tried making a node run a SCNAction.play() action with the same valid SCNAudioSource.


Either way, at runtime, everything looks valid but no audio is produced. What's up with that?


Can someone confirm whether this works or not in Xcode 8 Beta 4?


Here's a test case:


func test(_ rootNode: SCNNode) {
  if let path = Bundle.main.path(forResource: "Money.caf", ofType: nil, inDirectory: kSoundBundleName) {
  let audioNode = SCNNode()
  rootNode.addChildNode(audioNode)
  let audioSource = SCNAudioSource(fileNamed: path)!
//  audioSource.isPositional = false
  let audioPlayer = SCNAudioPlayer(source: audioSource)
  audioNode.addAudioPlayer(audioPlayer)
  let play = SCNAction.play(audioSource, waitForCompletion: true)
  audioNode.run(play)
  }
}


And here's an internal exception that gets thrown on first use:


libc++abi.dylib`__cxa_throw:
->  0x7fff9203ca01 <+0>:   pushq  %rbp
    0x7fff9203ca02 <+1>:   movq   %rsp, %rbp
    0x7fff9203ca05 <+4>:   pushq  %r15
    0x7fff9203ca07 <+6>:   pushq  %r14
    0x7fff9203ca09 <+8>:   pushq  %r12
    0x7fff9203ca0b <+10>:  pushq  %rbx
    0x7fff9203ca0c <+11>:  movq   %rdx, %r14
    0x7fff9203ca0f <+14>:  movq   %rsi, %r15
    0x7fff9203ca12 <+17>:  movq   %rdi, %rbx
    0x7fff9203ca15 <+20>:  callq  0x7fff9203c615            ; __cxa_get_globals
    0x7fff9203ca1a <+25>:  movq   %rax, %r12
    0x7fff9203ca1d <+28>:  callq  0x7fff9203cfc0            ; std::get_unexpected()
    0x7fff9203ca22 <+33>:  movq   %rax, -0x60(%rbx)
    0x7fff9203ca26 <+37>:  callq  0x7fff9203cff8            ; std::get_terminate()
    0x7fff9203ca2b <+42>:  movq   %rax, -0x58(%rbx)
    0x7fff9203ca2f <+46>:  movq   %r15, -0x70(%rbx)
    0x7fff9203ca33 <+50>:  movq   %r14, -0x68(%rbx)
    0x7fff9203ca37 <+54>:  leaq   -0x20(%rbx), %r14
    0x7fff9203ca3b <+58>:  movabsq $0x434c4e47432b2b00, %rax ; imm = 0x434C4E47432B2B00
    0x7fff9203ca45 <+68>:  movq   %rax, -0x20(%rbx)
    0x7fff9203ca49 <+72>:  movq   $0x1, -0x78(%rbx)
    0x7fff9203ca51 <+80>:  incl   0x8(%r12)
    0x7fff9203ca56 <+85>:  leaq   0x1d(%rip), %rax          ; __cxxabiv1::exception_cleanup_func(_Unwind_Reason_Code, _Unwind_Exception*)
    0x7fff9203ca5d <+92>:  movq   %rax, -0x18(%rbx)
    0x7fff9203ca61 <+96>:  movq   %r14, %rdi
    0x7fff9203ca64 <+99>:  callq  0x7fff9203fe90            ; symbol stub for: _Unwind_RaiseException
    0x7fff9203ca69 <+104>: movq   %r14, %rdi
    0x7fff9203ca6c <+107>: callq  0x7fff9203ca9e            ; __cxa_begin_catch
    0x7fff9203ca71 <+112>: movq   -0x58(%rbx), %rdi
    0x7fff9203ca75 <+116>: callq  0x7fff9203d006            ; std::__terminate(void (*)())

Looks like this is partially fixed in Xcode 8 Beta 5. Sounds now play from nodes, albeit faintly. And there's no apparent way to adjust the relative volume. But the internal exception is still thrown as shown above when the first sound plays.

Can't play audio from SCNNode
 
 
Q