gillesdemey / node-record-lpcm16

:microphone: Records a 16-bit signed-integer linear pulse modulation code encoded audio file.
ISC License
212 stars 59 forks source link

fix for issue 44 #45

Closed sdetweil closed 6 years ago

sdetweil commented 6 years ago

add handler for fatal error on stdout if pcm process dies, or is killed.

gillesdemey commented 6 years ago

Thanks for this, though we're already discussing this in #30 and would likely require a major semver release :)

sdetweil commented 6 years ago

thanks.. but note that this is different.. 30 is discussing capturing STDERR.. this is on STDOUT... if this is NOT captured, the node process will die.. 30 is NICE to have.. this is MANDATORY

gillesdemey commented 6 years ago

The cp.stdout is returned from the start() function, so adding an error handler shouldn't require modification to the existing library.

Something like the following example should work for handling those exceptions

const rec = record.start({
  sampleRate : 44100,
  verbose : true
})

rec.on('error', err => {
  // an error occurred on stdout
})

rec.pipe(file)
sdetweil commented 6 years ago

ok, got it.. the user can handle it..