[mythtv] Suggested patch for mythmusic

Jean-Yves Avenard jyavenard at gmail.com
Wed Jun 19 12:23:10 UTC 2013


Hi Paul..

I've pushed some changes to the audio framework, in that it can now
define what type of audio format it can receive.

As mythmusic is using the standard audio playback, it will work as-is,
as the standard audio can accept any format of any kind.

However, should by any reasons someone decided to extend mythmusic say
for transcoding (who knows) you;ll have to adjust your code.

Here is a patch:
http://pastebin.com/mHr1FkfZ

it's actually pretty simple, just let the audio class decode the
audio, it will decode it in the way it can accept it.

While looking over the code, something looks weird to me:
if output() returns NULL (for whatever reason, which normally
shouldn't be possible, but the logic to handle that case is still
there)

then mythmusic will continue to decode audio and fill its decoded
buffer until there's no more space and then loop doing nothing... that
feels very weird to me.
It doesn't really matter as this condition can't occur ; but if you
handle the case regardless: the code should be consistent :)

Another thing, the way you decode audio would have crashed under some
circumstances until quite recently.
DecodeAudio really expects the buffer provided to be 16-bytes aligned.
When doing:

                        ret = output()->DecodeAudio(m_audioDec,
                                                    m_outputBuffer + m_outputAt,
                                                    data_size,
                                                    &tmp_pkt);

it quickly becomes difficult to guarantee that this address is
16-bytes aligned, as it's doubtful m_outputAt will always be a
multiple of 16.

Now the code will handle it properly, reverting to C-code instead of
SSE ; but it's not optimal speed-wise.

You can look at the audiorencodebuffer.cpp in mythtranscode, how it
was done to deal with ongoing process and making sure the buffer is
always memory-aligned.

Hope this help.


More information about the mythtv-dev mailing list