Merge pull request #94 from qeled/indev

Voice fixes
This commit is contained in:
Amish Shah
2015-12-11 17:34:08 +00:00
4 changed files with 16 additions and 15 deletions

View File

@@ -67,7 +67,7 @@ var AudioEncoder = (function () {
var self = this;
return new Promise(function (resolve, reject) {
var enc = _child_process2["default"].spawn(self.getCommand(), ['-i', "-", '-f', 's16le', '-ar', '48000', '-ac', 2, 'pipe:1']);
var enc = _child_process2["default"].spawn(self.getCommand(), ['-loglevel', '0', '-i', '-', '-f', 's16le', '-ar', '48000', '-ac', 2, 'pipe:1'], { stdio: ['pipe', 'pipe', 'ignore'] });
stream.pipe(enc.stdin);

View File

@@ -56,7 +56,7 @@ var VoiceConnection = (function (_EventEmitter) {
this.session = session;
this.token = token;
this.server = server;
this.endpoint = endpoint.replace(":80", "");
this.endpoint = endpoint.split(":")[0];
this.vWS = null; // vWS means voice websocket
this.ready = false;
this.vWSData = {};
@@ -67,6 +67,8 @@ var VoiceConnection = (function (_EventEmitter) {
this.streamTime = 0;
this.streamProc = null;
this.KAI = null;
this.timestamp = 0;
this.sequence = 0;
this.init();
}
@@ -108,8 +110,6 @@ var VoiceConnection = (function (_EventEmitter) {
var self = this;
var startTime = Date.now();
var sequence = 0;
var time = 0;
var count = 0;
var length = 20;
@@ -153,10 +153,10 @@ var VoiceConnection = (function (_EventEmitter) {
}
count++;
sequence + 10 < 65535 ? sequence += 1 : sequence = 0;
time + 9600 < 4294967295 ? time += 960 : time = 0;
self.sequence + 1 < 65535 ? self.sequence += 1 : self.sequence = 0;
self.timestamp + 960 < 4294967295 ? self.timestamp += 960 : self.timestamp = 0;
self.sendBuffer(buffer, sequence, time, function (e) {});
self.sendBuffer(buffer, self.sequence, self.timestamp, function (e) {});
var nextTime = startTime + count * length;

View File

@@ -45,12 +45,13 @@ export default class AudioEncoder {
var self = this;
return new Promise((resolve, reject) => {
var enc = cpoc.spawn(self.getCommand(), [
'-i', "-",
'-loglevel', '0',
'-i', '-',
'-f', 's16le',
'-ar', '48000',
'-ac', 2,
'pipe:1'
]);
], {stdio: ['pipe', 'pipe', 'ignore']});
stream.pipe(enc.stdin);

View File

@@ -24,7 +24,7 @@ export default class VoiceConnection extends EventEmitter {
this.session = session;
this.token = token;
this.server = server;
this.endpoint = endpoint.replace(":80", "");
this.endpoint = endpoint.split(":")[0];
this.vWS = null; // vWS means voice websocket
this.ready = false;
this.vWSData = {};
@@ -35,6 +35,8 @@ export default class VoiceConnection extends EventEmitter {
this.streamTime = 0;
this.streamProc = null;
this.KAI = null;
this.timestamp = 0;
this.sequence = 0;
this.init();
}
@@ -78,8 +80,6 @@ export default class VoiceConnection extends EventEmitter {
var self = this;
var startTime = Date.now();
var sequence = 0;
var time = 0;
var count = 0;
var length = 20;
@@ -123,10 +123,10 @@ export default class VoiceConnection extends EventEmitter {
}
count++;
sequence + 10 < 65535 ? sequence += 1 : sequence = 0;
time + 9600 < 4294967295 ? time += 960 : time = 0;
self.sequence + 1 < 65535 ? self.sequence += 1 : self.sequence = 0;
self.timestamp + 960 < 4294967295 ? self.timestamp += 960 : self.timestamp = 0;
self.sendBuffer(buffer, sequence, time, (e) => { });
self.sendBuffer(buffer, self.sequence, self.timestamp, (e) => { });
var nextTime = startTime + (count * length);