[mythtv] Big audio update - suggestions and Core Audio patch
Jeremiah Morris
jm at whpress.com
Wed Oct 13 22:47:40 UTC 2004
Hi Ed,
Hope your new subwoofers work out great! I'm so jealous. =)
I've looked over the audio base class, and it takes care of the 80%
redundancy I need for Core Audio. Unfortunately, it does another 10%
that I don't need or want. With a few tweaks, the base class could be
far more flexible than it is currently.
There are two audio models I've run into. Alsa and OSS use the 'push'
model, where you write data to a sound card buffer as it's available
(as buffer space allows). JACK and Core Audio (CA) use the 'pull'
model, where a callback requests data as the sound card is ready to
play it. Myth calls AudioOutput assuming the 'push' model. The base
class provides a secondary buffering layer, but it also forces the
subclasses into the 'push' model. The bio2jack code provides yet
another buffering layer to convert push to pull, and I would also have
to write such a layer for CA in order to use the base class.
However, if there has to be a glue layer already for the 'pull'
drivers, there's not much incentive to use the base class. Aside from
resampling (which, incidentally, CA provides natively), the base class
basically provides a ring buffer and a sound card feeder thread. For
the 'pull' model, both are extra overhead, as a thread is unnecessary
and another ring buffer must be implemented underneath already.
What I propose is to separate the ring buffer logic from the feeder
logic, and make the feeder thread an optional part of the base class.
I put together an implementation that adds the following:
- The thread is started and stopped by virtual methods, so the thread
doesn't have to run in the 'pull' case.
- A new method encapsulates the code to consume from the ring buffer
(most of the logic in the critical section of the feeder thread).
- pauseaudio, audio_actually_paused, and killaudio are protected, so
subclasses can read these cases directly (and thus implement an
alternative to the first part of the feeder thread).
This provides the best of both worlds: 'push' models can use the
supplied thread, and 'pull' models can easily grab arbitrary amounts of
data off the base class' private ring buffer.
I'm attaching a diff against the Oct. 11 base class, and a Core Audio
implementation. The other subclasses don't need to be changed,
although I hope eventually someone would use this to write a more
efficient JACK implementation.
Thanks for your work in making life easier for all the audio folks!
Hopefully these changes can make the base class more inclusive without
making anyone's job harder.
- Jeremiah
-------------- next part --------------
A non-text attachment was scrubbed...
Name: audio_JM.tar.gz
Type: application/x-gzip
Size: 3972 bytes
Desc: not available
Url : http://mythtv.org/pipermail/mythtv-dev/attachments/20041013/5c971702/audio_JM.tar.bin
More information about the mythtv-dev
mailing list