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

stop function fails to capture on 'error' event when arecord is the pcm recorder #44

Closed sdetweil closed 6 years ago

sdetweil commented 6 years ago

in the smart mirror application, due to a bug in arecord, we need to stop and restart the lpcm recorder.

when the stop function is called, and the cp.kill() is executed, arecord sends an abort error on the stdout stream.. but node-lpcm is not handling error on that stream.. and the application dies for uncaught exception

you can see this by redirecting arecord to a file, and then issue a kill on arecord.

the fix is to add

    rec.on('error', function(data){
    // rec.emit('error', data.toString())
})

to the list of handlers in the start function

sdetweil commented 6 years ago

using application can add the stdout error handler, no need for this library to add handler.