On Tuesday 18 September 2001 05:36 am, Alexander Leidinger wrote:
> On 17 Sep, Mark Taylor wrote:
> >> A frontend I've been toying with: ...
> >> http://evilcode.net/dklame/threaded.c
> >
> > Does that code work? It looks ok at first glance.
>
> Without looking at the frontend: how can this work? How is thread N+1
> - working on frame N+1 - able to know how much of the bitreservoir it
> can use, if thread x to N - with x <= N - is working on frame x to N?
>
> > Latest reports are that lame is thread safe and can do what you are
> > trying.
>
> I expect libmp3lame to be reentrant, but not to be thread safe.
> My definitions:
> - reentrant: multiple threads can call every function in the lib if
> they work on independent datasets (in this case: dataset =
> outputstream) without disturbing each other.
> - thread safe: multiple threads can call every function in the lib,
> even if they work on datasets whic
> h depend on each other (in this
> case: different buffers for the same outputstream) - because the
> constraints get fulfilled automatically by the functions, e.g.
> by locking of datastructures (to prevent race conditions) and/or some
> sort of syncronisation.
>
> If we are thread safe, I want to slap someone into the face because I
> haven't seen any commit log which talks about the neccessary data
> locking or synchronisation work.
>
> Bye,
> Alexander.
Yeah, you're right. A simple test reveals the truth. I created a single
lame_global_flags pointer for every thread rather than an individual one
for each and used locking for it around lame_encode_buffer. The result
is a happy sounding MP3. The performance, as expected, sucks....
With each encoder thread consuming ~50% of a CPU on a dual CPU
box, again... as expected. I've just taken a look at how gogo does it
and there doesn't appear to be too much involved, it's entirely concentrated
in encodeframe(). When I get some more time I'll see if I can't merge
gogo's pthread changes into encoder.c.
Sam
--
MP3 ENCODER mailing list archive is at:
http://www.mail-archive.com/mp3encoder%40minnie.cs.adfa.edu.au/