Re: [LAD] need help mixing on the fly

From: David Griffith <dave@email-addr-hidden>
Date: Sun Feb 19 2017 - 16:46:22 EET

On Sun, 19 Feb 2017, Fons Adriaensen wrote:

> On Sun, Feb 19, 2017 at 01:47:39PM +0000, David Griffith wrote:
>
>> A mixer thread is spawned when Frotz starts up. It waits for one or
>> both float buffers to fill whereupon it mixes their contents,
>> converts the result to pcm16 and calls libao to play it. playaiff()
>> or playmusic() are spawned by the main thread as separate threads to
>> read audio data from the container IFF and fill up the float buffers
>> for the mixer to read.
>
> /me looks at code...
>
> This is all so horribly wrong that I don't know where to be
> begin. Honestly, I'm surprised it works at all (assuming it
> does, with one source).
>
> But the main error seems to be the way the audio_full and
> audio_empty semas are used. If there are two producers,
> audio_full is posted twice. And then the two producers
> are waiting on the same sema, audio_empty. This can't
> work ever. It's not some small bug -- the entire logic
> and structure of this code is just wrong.
>
> Apart from that, if this code is meant to be Linux only,
> consider using ALSA or Jack. If not, consider something
> like Portaudio. OSS and everything built on it have been
> deprecated for at least 12 years now.

I admit that I don't have a good handle on the way the producer/consumer
setup works. I got it with one producer and one consumer. With two
producers, I got lost.

The code is meant to be portable across at least Linux and BSD. That's
why I picked libao for output.

-- 
David Griffith
dave@email-addr-hidden
A: Because it fouls the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?
_______________________________________________
Linux-audio-dev mailing list
Linux-audio-dev@email-addr-hidden
http://lists.linuxaudio.org/listinfo/linux-audio-dev
Received on Sun Feb 19 20:15:01 2017

This archive was generated by hypermail 2.1.8 : Sun Feb 19 2017 - 20:15:01 EET