This file is indexed.

/usr/lib/nodejs/groove/lib/index.js is in node-groove 2.5.0-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
var bindings = require('bindings')('groove.node');
var EventEmitter = require('events').EventEmitter;
var util = require('util');

var DB_SCALE = Math.log(10.0) * 0.05;

/* "C++ modules aren't really for doing complex things that need to be
 * strewn across multiple modules.  Just get your binding done as quick
 * as possible, get out of there, and then wrap it in JS for all the fancy stuff
 *
 * -isaacs
 */

// hi-jack some of the native methods
var bindingsCreatePlayer = bindings.createPlayer;
var bindingsCreateLoudnessDetector = bindings.createLoudnessDetector;
var bindingsCreateFingerprinter = bindings.createFingerprinter;
var bindingsCreateEncoder = bindings.createEncoder;

bindings.createPlayer = jsCreatePlayer;
bindings.createEncoder = jsCreateEncoder;
bindings.createLoudnessDetector = jsCreateLoudnessDetector;
bindings.createFingerprinter = jsCreateFingerprinter;
bindings.loudnessToReplayGain = loudnessToReplayGain;
bindings.dBToFloat = dBToFloat;
bindings.DUMMY_DEVICE = -2;

module.exports = bindings;

function jsCreateEncoder() {
  var encoder = bindingsCreateEncoder(eventCb);

  postHocInherit(encoder, EventEmitter);
  EventEmitter.call(encoder);

  return encoder;

  function eventCb() {
    encoder.emit('buffer');
  }
}

function jsCreatePlayer() {
  var player = bindingsCreatePlayer(eventCb);

  postHocInherit(player, EventEmitter);
  EventEmitter.call(player);

  return player;

  function eventCb(id) {
    switch (id) {
    case bindings._EVENT_NOWPLAYING:
      player.emit('nowplaying');
      break;
    case bindings._EVENT_BUFFERUNDERRUN:
      player.emit('bufferunderrun');
      break;
    case bindings._EVENT_DEVICEREOPENED:
      player.emit('devicereopened');
      break;
    }
  }
}

function jsCreateLoudnessDetector() {
  var detector = bindingsCreateLoudnessDetector(eventCb);

  postHocInherit(detector, EventEmitter);
  EventEmitter.call(detector);

  return detector;

  function eventCb() {
    detector.emit('info');
  }
}

function jsCreateFingerprinter() {
  var printer = bindingsCreateFingerprinter(eventCb);
  postHocInherit(printer, EventEmitter);
  EventEmitter.call(printer);

  return printer;

  function eventCb() {
    printer.emit('info');
  }
}

function postHocInherit(baseInstance, Super) {
  var baseProto = Object.getPrototypeOf(baseInstance);
  var superProto = Super.prototype;
  Object.keys(superProto).forEach(function(method) {
    if (!baseProto[method]) baseProto[method] = superProto[method];
  });
}

function clamp_rg(x) {
  if (x > 51.0) return 51.0;
  else if (x < -51.0) return -51.0;
  else return x;
}

function loudnessToReplayGain(loudness) {
  return clamp_rg(-18.0 - loudness);
}

function dBToFloat(dB) {
  return Math.exp(dB * DB_SCALE);
}