ashishbajaj99 / mic

A simple stream wrapper for arecord (Linux (including Raspbian)) and sox (Mac, Windows). Returns a Passthrough stream object so that stream control like pause(), resume(), pipe(), etc. are all available.
MIT License
103 stars 61 forks source link

Error: write after end #24

Closed raghavSrih closed 6 years ago

raghavSrih commented 6 years ago

Hi,

When I edit your test code like below and run I get the error : Error: write after end

micInputStream.on('stopComplete', function() {
    console.log("Got SIGNAL stopComplete");
    setTimeout(function() {
            micInstance.start();
    }, 5000);
}); 

Any idea how to fix/handle it ?

ashishbajaj99 commented 6 years ago

On stop the process is killed using SIGTERM. If you want to simply pause and resume after 5 seconds use the pause and resume framework rather than stop and start

ginixsan commented 5 years ago

You should create a function 'setUpMic' (or whatever) and then wrap constructor and everything inside that function and then call it again if you want to start and stop.