Permalink
Browse files

implemented platform checks for nice/renice functionality (solves #13)

  • Loading branch information...
1 parent fa6a98d commit f984e972b303b8e74899d5931cbe66f7d6618fb0 @schaermu schaermu committed Jun 8, 2012
Showing with 13 additions and 7 deletions.
  1. +5 −2 lib/processor.js
  2. +1 −1 test/coverage.html
  3. +7 −4 test/processor.test.js
View
@@ -1,6 +1,7 @@
var fs = require('fs'),
path = require('path'),
async = require('../support/async.min.js'),
+ os = require('os').platform(),
exec = require('child_process').exec,
spawn = require('child_process').spawn,
Registry = require('./registry'),
@@ -250,7 +251,8 @@ exports = module.exports = function Processor(command) {
j++;
- if (self.options._nice.level) {
+ // only set niceness if running on a non-windows platform
+ if (self.options._nice.level && !os.match(/win(32|64)/)) {
// execute ffmpeg through nice
exec('nice -n ' + self.options._nice.level + ' ' + self.determineFfmpegPath() + ' ' + tnArgs.join(' '), taskcallback);
} else {
@@ -356,7 +358,8 @@ exports = module.exports = function Processor(command) {
this._spawnProcess = function(args, options) {
var retProc = spawn(this.determineFfmpegPath(), args, options);
- if (this.options._nice.level) {
+ // only re-nice if running on a non-windows platform
+ if (this.options._nice.level && !os.match(/win(32|64)/)) {
var niceLvl = (this.options._nice.level > 0 ? '+' + this.options._nice.level : this.options._nice.level);
// renice the spawned process without waiting for callback
var self = this;
View

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -2,6 +2,7 @@ var Ffmpeg = require('../index'),
path = require('path'),
fs = require('fs'),
assert = require('assert'),
+ os = require('os').platform(),
exec = require('child_process').exec;
describe('Processor', function() {
@@ -27,10 +28,12 @@ describe('Processor', function() {
});
});
- it('should properly limit niceness', function() {
- new Ffmpeg({ source: this.testfile, nolog: true, timeout: 0.02 })
- .renice(100).options._nice.level.should.equal(0);
- });
+ if (!os.match(/win(32|64)/)) {
+ it('should properly limit niceness', function() {
+ new Ffmpeg({ source: this.testfile, nolog: true, timeout: 0.02 })
+ .renice(100).options._nice.level.should.equal(0);
+ });
+ }
it('should kill the process on timeout', function(done) {
var testFile = __dirname + '/assets/testProcessKill.flv';

0 comments on commit f984e97

Please sign in to comment.