[erlang-questions] NFI's and running multiple VM's

Leandro Ostera <>
Sun Mar 15 19:30:35 CET 2015


Thanks a million for the replies, guys.

@Daniel:
1. That's what I thought. I could try this for personal use but it's
clearly not the most scalable option.

2. So using ports I'd be spawning a worker that streams the audio back to
the erlang process, per user that's online and listening. I'll give this a
shot with pyspotify. Let's hope they allow for multiple audio streams for
different sessions from the same host!

3. Unfortunately the Spotify Web API doesn't provide full playback (only
30s previews), but for the rest of the data I was going to use that.

@Jesper: Indeed the library is not thread-safe. Thanks for clearing up what
that meant. And it seems that they haven't updated libspotify in the past 2
years, so hopefully with the releasing of the new Web API they'll roll out
a new release of the C lib.

Thanks for your time guys, I'll be giving this a shot and get back.

On Fri, Mar 13, 2015 at 10:43 AM, Jesper Louis Andersen <
> wrote:

>
> On Thu, Mar 12, 2015 at 11:45 PM, Leandro Ostera <> wrote:
>
>> I was trying to use a quite old erlang wrapper around libspotify
>> <https://github.com/arjan/espotify>, which seems to be defining a bunch
>> of NIFs, to make an audio streaming server that would keep N web-based
>> clients playing the same audio at (give or take milliseconds) the same
>> time. The problem is that according to one of the source files
>> <https://github.com/arjan/espotify/blob/master/src/espotify_api.erl#L73-L84>,
>> it'd only be able to have one open Spotify session per VM, which of course
>> didn't sound too exciting.
>>
>
> The library may not be thread-safe. That is, it assumes a single thread
> for access and it stores session information in global variables inside the
> library itself. You may want to check if there is a newer version of the
> library without these limitations.
>
> NIFs do support proper multithreading and local context, but the library
> needs to support it as well. The term you are looking for w.r.t the context
> are 'resources':
>
> http://www.erlang.org/doc/man/erl_nif.html#enif_resource_example
>
>
> --
> J.
>



-- 
Leandro Ostera

Github <http://github.com/ostera> | LinkedIn
<http://linkedin.com/in/leostera> | Facebook <http://facebook.com/leostera>
 | @leostera <http://twitter.com/leostera>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20150315/a73de4b0/attachment.html>


More information about the erlang-questions mailing list