TooTallNate / node-speaker

Output PCM audio data to the speakers
655 stars 147 forks source link

require-time segfault for 48000 bitrate device (jack backend) #110

Open belm0 opened 6 years ago

belm0 commented 6 years ago

My system only has 48000 bitrate audio, yet the node-speaker init is briefly opening a 44100 channel for Nan, causing a segfault.

$ node
> require('speaker');
Registered as JACK client mpg123-23847.
[../deps/mpg123/src/output/jack.c:271] error: JACK Sample Rate 48000 is different to sample rate of file 44100.
[../deps/mpg123/src/output/jack.c:58] warning: FIXME: One needs to wait or write some silence here to prevent the last bits of audio to vanish out of the ringbuffer.
Segmentation fault

(note I added value details to the jack.c logging)

Offending init code in binding.cc:

       audio_output_t ao;
        memset(&ao, 0, sizeof(audio_output_t));
        mpg123_output_module_info.init_output(&ao);
        ao.channels = 2;
        ao.rate = 44100;
        ao.format = MPG123_ENC_SIGNED_16;
        ao.open(&ao);
        Nan::ForceSet(target, Nan::New("formats").ToLocalChecked(), Nan::New(ao.get_formats(&ao)));
        ao.close(&ao);