Hi,
The test scenario I’m using is the following:
· A FileStreamer node connected to a hard limiter node
· The hard limiter node is connected to the server
I’m trying to use RAII to manage object lifetimes. I’ve created a class that appropriately increments and decrements the ref count of a LavHandle, but I’m still seeing the file streamer node living longer than it should probably due to the following:
• Given some node a and some other node b , the call a.connect(some_output, b, some_input) creates a strong reference from
b to a . The connection remains alive until b is collected or you explicitly kill it.
I was going to try disconnecting this node from the hard limiter if the handle’s ref count is 0, but the documentation cautions against using the function that returns the ref count of a handle. How else can I kill the node when all references to it are gone?
Also, is setting a LavHandle to 0 equivalent to an empty lav handle? E.g, it does nothing if 0 is passed to decreaseRefCount?
Tried looking for the implementation of the python bindings to see how it might be done, but can’t find the source files that expose this to python.
This is unfortunately a bit complicated, and you're probably not
going to be able to treat it like Raii. here is more information
than you ever wanted; providing more information than you ever
wanted is a thing I tend to do.
--
You received this message because you are subscribed to the Google Groups "libaudioverse" group.
To unsubscribe from this group and stop receiving emails from it, send an email to libaudiovers...@camlorn.net.
To post to this group, send email to libaud...@camlorn.net.
To view this discussion on the web visit https://groups.google.com/a/camlorn.net/d/msgid/libaudioverse/002401d1e817%240162f790%240428e6b0%24%40gmail.com.
O, yeah. Forgot the last part. I don't suggest passing 0 to
Lav_handleDecRef. It's kind of like passing null to delete and/or
free, depending which you use. I'm pretty sure that errors, but
at the least it makes little logical sense to do it.
--
Hi,
Thanks for the explanation, and yeah I couldn't figure out why you did it that way. I think it'd be helpful if you put this in the manual. I'm still very interested to try libaudioverse, because it looks much saner than the alternatives.
Could you check on the getRefCount function? getRefCount is the most convenient way to know when to pause and isolate.
Admittedly, I don't have much experience with audio libraries - using libsndfile, openal-soft and alure for .ogg files was not my idea of fun. So am unsure if these are the right semantics to use.
Why not have the strong reference go the other way i.e connecting A to B causes a strong reference from A to B? If you lose all references to nodes that have no inputs like file streamer, I can't think of why you'd want to keep them around.
I was asking about having a 0 LavHandle for being able to safely default construct nodes, or to leave the object in a state that the destructor can run when its moved. The alternative is a pointer to a lav handle, which adds another layer of indirection.
Glad to know that an autogenerated c++ binding is in the works. I'm writing the bare minimum to be able to use it for basic sound playback right now in a game.
To view this discussion on the web visit https://groups.google.com/a/camlorn.net/d/msgid/libaudioverse/fd160d23-3582-9308-ab08-ad8d79d7275d%40camlorn.net.
Oh actually, the question I should be asking is: does a LavHandle returned by a function that creates some resource ever have the value 0?
From: Austin Hicks [mailto:cam...@camlorn.net]
Sent: Thursday, July 28, 2016 3:53 AM
To: libaud...@camlorn.net
To view this discussion on the web visit https://groups.google.com/a/camlorn.net/d/msgid/libaudioverse/6f915368-5b67-c103-0117-efe2401b5617%40camlorn.net.
A newly created handle can never have the value 0. In that case,
the first access flag is set (see
Lav_handleGetAndClearFirstAccess--long name, but you don't use it
often) and the refcount is put at 1. I am 99.99% certain that the
refcount is also set to 1 in all callback situations but am
questioning that some now that we are having this conversation.
If that ends up not being the case, it's a bug. If you use a
HandleBox as described below, then it's not an issue for callbacks
to have strong handles.
I'm looking at the implementation of Lav_handleGetRefCount, and
using it won't crash you. Unfortunately, it's not going to work
out if you're trying to use it to ask if a handle has a refcount
of 0, as there is no guarantee that the handle wasn't just deleted
out from under you. Handles with refcounts of 0 may also be
reincremented if you're using callbacks. It is also going to be
hard to use it right if you have multiple threads changing the
refcount, as the standard concerns apply. Given that it's really
bad practice to write your application that way if you're a C
programmer, I'm not willing to extend my guarantees. I hate
refcounts like this too, but the alternatives are all equally
unsatisfactory in other ways, so here we are.
To view this discussion on the web visit https://groups.google.com/a/camlorn.net/d/msgid/libaudioverse/009001d1e9b5%24a0e29010%24e2a7b030%24%40gmail.com.
Thanks, doing that worked perfectly.
I'm guessing that any discussion about changing the direction of strong references needs to be completed before V0.9 is released? I could get used to how it is now, if noone else has had any problem with it.
I'm actually only doing this audiogame in c++ as I was already somewhat familiar with it, availability of libraries and its more difficult to reverse engineer executables. Am strongly considering using a different language for future projects for productivity reasons. Not looking forward to serialization at all - why in the world doesn't c++ have any compile-time reflection yet? Visual Studio isn't very accessible, and CMake's syntax is ugly.
Though this is off topic, can anyone suggest any language alternatives that would work better and fits these requirements?
To view this discussion on the web visit https://groups.google.com/a/camlorn.net/d/msgid/libaudioverse/e618ed70-dc69-bcbb-0f13-be3c47ca7baf%40camlorn.net.
How much difference does connecting everything to the HardLimiter node before it goes to the server make compared to direct connections to the server?
I’m thinking of routing all sound effects and streaming music to separate nodes for volume adjustment purposes. Wouldn’t this sort of thing be a common use case? In which situations would you rather hold onto nodes in the middle instead of the starting node?
How’re you setting up the bindings? It looks like you aren’t using something like swig.
To view this discussion on the web visit https://groups.google.com/a/camlorn.net/d/msgid/libaudioverse/e618ed70-dc69-bcbb-0f13-be3c47ca7baf%40camlorn.net.
In the common case, you have buffer->source. Here, you would
hold both.
To view this discussion on the web visit https://groups.google.com/a/camlorn.net/d/msgid/libaudioverse/006b01d1ea8b%24866c4010%249344c030%24%40gmail.com.
I did consider something like the autoisolate functionality you suggest – it might be the best way to solve the common cases. Lets revisit this post 0.9.
To view this discussion on the web visit https://groups.google.com/a/camlorn.net/d/msgid/libaudioverse/7467c131-bf91-69f4-077d-567972fe22ca%40camlorn.net.