Comparing version
10
index.js
@@ -84,2 +84,6 @@ 'use strict' | ||
} | ||
if (this.device == null) { | ||
debug('setting default %o: %o', 'device', null) | ||
this.device = null | ||
} | ||
@@ -101,3 +105,3 @@ const format = Speaker.getFormat(this) | ||
this.audio_handle = bufferAlloc(binding.sizeof_audio_output_t) | ||
const r = binding.open(this.audio_handle, this.channels, this.sampleRate, format) | ||
const r = binding.open(this.audio_handle, this.channels, this.sampleRate, format, this.device) | ||
if (r !== 0) { | ||
@@ -146,2 +150,6 @@ throw new Error(`open() failed: ${r}`) | ||
} | ||
if (opts.device != null) { | ||
debug('setting %o: %o', 'device', opts.device) | ||
this.device = opts.device | ||
} | ||
if (opts.endianness == null || endianness === opts.endianness) { | ||
@@ -148,0 +156,0 @@ // no "endianness" specified or explicit native endianness |
{ | ||
"name": "speaker", | ||
"version": "0.4.0", | ||
"version": "0.4.1", | ||
"license": "MIT", | ||
@@ -5,0 +5,0 @@ "description": "Output PCM audio data to the speakers", |
@@ -52,6 +52,6 @@ # node-speaker | ||
### new Speaker([ format ]) -> Speaker instance | ||
### new Speaker([ options ]) -> Speaker instance | ||
Creates a new `Speaker` instance, which is a writable stream that you can pipe | ||
PCM audio data to. The optional `format` object may contain any of the `Writable` | ||
PCM audio data to. The optional `options` object may contain any of the `Writable` | ||
base class options, as well as any of these PCM formatting options: | ||
@@ -65,2 +65,3 @@ | ||
* `samplesPerFrame` - The number of samples to send to the audio backend at a time. You likely don't need to mess with this value. Defaults to `1024`. | ||
* `device` - The name of the playback device. E.g. `'hw:0,0'` for first device of first sound card or `'hw:1,0'` for first device of second sound card. Defaults to `null` which will pick the default device. | ||
@@ -67,0 +68,0 @@ #### "open" event |
@@ -98,2 +98,11 @@ /* eslint-env mocha */ | ||
it('should accept a device option', function (done) { | ||
const s = new Speaker({ device: 'test' }) | ||
assert.equal(s.device, 'test') | ||
s.on('close', done) | ||
s.end(bufferAlloc(0)) | ||
}) | ||
it('should not throw an Error if native "endianness" is specified', function () { | ||
@@ -100,0 +109,0 @@ assert.doesNotThrow(function () { |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
3511906
0.02%539
2.67%103
0.98%1
-50%242
-0.41%