Git Product home page Git Product logo

Comments (17)

TooTallNate avatar TooTallNate commented on July 26, 2024

Doesn't speaker.destroy() do this or no? You can create a new Speaker instance once you're ready to start playing audio again.

from node-speaker.

TooTallNate avatar TooTallNate commented on July 26, 2024

Oh, nvm, speaker.destroy() doesn't even exist, haha! Ok, so let's add that and then this feature request should be fulfilled.

from node-speaker.

karlmikko avatar karlmikko commented on July 26, 2024

speaker has no method destroy

from node-speaker.

TooTallNate avatar TooTallNate commented on July 26, 2024

Sorry, does calling speaker.close() do the trick though?

from node-speaker.

karlmikko avatar karlmikko commented on July 26, 2024

Yes but i get a segfault

from node-speaker.

karlmikko avatar karlmikko commented on July 26, 2024

i guess we could then close this issue as the segfault is a different issue

from node-speaker.

TooTallNate avatar TooTallNate commented on July 26, 2024

Well that's not good! Can you show me some repro code?

from node-speaker.

TooTallNate avatar TooTallNate commented on July 26, 2024

It's cool man we can just re-title the issue

from node-speaker.

karlmikko avatar karlmikko commented on July 26, 2024

var lame = require('lame');
var icecast = require('icecast');
var Speaker = require('speaker');

var speaker = new Speaker();
var decoder = new lame.Decoder();
decoder.pipe(speaker);

// URL to a known Icecast stream
var url = 'http://shoutmedia.abc.net.au:10426/';

// connect to the remote stream
var station = icecast.get(url, function (res) {

// log the HTTP response headers
console.error(res.headers);

// log any "metadata" events that happen
res.on('metadata', function (metadata) {
var parsed = icecast.parse(metadata);
console.error(parsed);
});

// Let's play the music (assuming MP3 data).
// lame decodes and Speaker sends to speakers!
res.pipe(decoder);
});

setTimeout(function(){
speaker.close();
}, 5000);

from node-speaker.

karlmikko avatar karlmikko commented on July 26, 2024

this is what i am doing right now - maybe i am being stupid with it

from node-speaker.

karlmikko avatar karlmikko commented on July 26, 2024

I am on mac osx mavericks

from node-speaker.

TooTallNate avatar TooTallNate commented on July 26, 2024

Side note: use icecast module instead of radio-stream. The former replaces the later, and the later is just around for legacy purposes.

from node-speaker.

karlmikko avatar karlmikko commented on July 26, 2024

thanks!

basically what i am trying to do is the icecast example except with a stop that stops playback instantly

from node-speaker.

karlmikko avatar karlmikko commented on July 26, 2024

maybe icecast should have a "stop" on it

from node-speaker.

karlmikko avatar karlmikko commented on July 26, 2024

updated code sample with icecast - segfault on close still.

from node-speaker.

karlmikko avatar karlmikko commented on July 26, 2024

Been doing some more testing and can make the seg fault happen when you fill the speaker.audio_handle with null

I suspect that the binding is not closed yet and the close then clears the buffer so the binding get crap data

from node-speaker.

TooTallNate avatar TooTallNate commented on July 26, 2024

I was able to repro the segfault easily with the "sine.js" example script, with the diff below:

diff --git a/examples/sine.js b/examples/sine.js
index 2658f05..bd1a22c 100644
--- a/examples/sine.js
+++ b/examples/sine.js
@@ -27,7 +27,11 @@ sine.samplesGenerated = 0;
 sine._read = read;

 // create a SineWaveGenerator instance and pipe it to the speaker
-sine.pipe(new Speaker());
+var s = new Speaker();
+sine.pipe(s);
+setTimeout(function() {
+  s.close();
+}, 500);

 // the Readable "_read()" callback function
 function read (n) {

from node-speaker.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.