Skip to content

Commit

Permalink
Microphone: kill zombie processes
Browse files Browse the repository at this point in the history
  • Loading branch information
rwaldron committed Nov 3, 2016
1 parent 506af58 commit 795e340
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
13 changes: 11 additions & 2 deletions lib/microphone.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@ var CaptureStream = require('./capture-stream');
// Program specific
var priv = new WeakMap();

try {
cp.spawnSync("kill -9 $(pgrep 'aplay')");
} catch (error) {}

try {
cp.spawnSync("kill -9 $(pgrep 'arecord')");
} catch (error) {}


function Microphone(options) {
Emitter.call(this);

Expand Down Expand Up @@ -41,7 +50,7 @@ Microphone.prototype = Object.create(Emitter.prototype, {
}
});

var defaults = ['-f', 'cd', '-c', '1', '-r', '48000' /*, '-D', 'plughw:0,0' */ ];
var defaults = ['-f', 'cd', '-r', '48000' /*, '-D', 'plughw:0,0' */ ];

Microphone.prototype.listen = function(options) {
var state = priv.get(this);
Expand Down Expand Up @@ -195,7 +204,7 @@ var arecord = {
'-f': 'cd',
'-c': 1,
'-r': 48000,
//'-D': 'plughw:0,0',
// '-D': 'plughw:0,0',
},
};

Expand Down
2 changes: 1 addition & 1 deletion test/unit/microphone.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ exports['av.Microphone'] = {
test.equal(this.spawn.callCount, 1);
test.equal(this.spawn.lastCall.args[0], 'arecord');
test.deepEqual(this.spawn.lastCall.args[1], [
'-f', 'cd', '-c', '1', '-r', '48000'
'-f', 'cd', '-r', '48000', '-c', 1
]);

test.done();
Expand Down

0 comments on commit 795e340

Please sign in to comment.