Search code examples
bashmacosconcurrencycore-audiosox

Robust way to play multiple audio files concurrently from the shell?


I'm experimenting with playing audio files on a Mac (OS X 10.10.5) via several concurrent shell scripts. Each script runs in a separate Terminal session and periodically invokes an instance of sox (v. 14.4.2) to play an audio file. For example, one script might do this:

sox foo.aif -t coreaudio

while another script does this:

sox bar.aif -t coreaudio

The second file plays OK, but only after echoing the error message

sox[8139:17123955] *** CFMessagePort: bootstrap_register(): failed 1100 (0x44c) 'Permission denied', port = 0x46407, name = 'sox' See /usr/include/servers/bootstrap_defs.h for the error codes.

(/usr/include/servers/bootstrap_defs.h isn't too helpful: it says that error code 1100 is defined as BOOTSTRAP_NOT_PRIVILEGED.)

Each subsequent invocation of sox throws the same error, as long as another instance is still playing. I've tried running up to 4 concurrent instances and get the same results.

Even though sox appears to be playing the files OK, this error message makes me nervous, since my application demands rock-solid stability (it will be playing up to 4 files concurrently 24/7/365). Also, I don't like peppering my Terminal sessions (or, after redirection of stderr, my log files) with unhelpful error messages.

Questions:

  1. Can I safely ignore this error, since the sound files appear to be playing OK?

  2. Might this error somehow be related to issues I'm having with other "downstream" audio applications? (For example, when I send audio from these sox instances to instances of BUTT (Broadcast Using this Tool), BUTT stops streaming and behaves as if it has lost connection with its audio source).

  3. Are there any alternatives to sox that can play audio files from the command line in concurrent sessions without throwing this error?


Solution

  • Just to close this thread... The error messages do not appear when I repeat the test on on a newer Mac running OS X 10.12.4. I can run 5 concurrent instances of sox or afplay without error.

    As to part (3) of my original question... afplay is indeed a handy quick-n-dirty alternative to sox for previewing audio files from the command line (thanks, @Dave !). My situation, however, is multichannel (>8 channels) -- something afplay can't do but which sox does handily. But since I didn't mention the multichannel aspect in my question, I consider the question answered. Thanks!