[mythtv] [mythtv-commits] Ticket #10396: Periodical, short audio artifacts in one the channels when upmixing to 5.1

Jean-Yves Avenard jyavenard at gmail.com
Thu Mar 8 02:33:18 UTC 2012


On 8 March 2012 11:03, Mark Spieth <mark at digivation.com.au> wrote:
> Thats a big clue
>
> try this at the bottom of this section. org_waud shouldnt be set twice.
> The wrap is the reason for setting to 0.

And you have obviously misread, the code

>
> --- a/mythtv/libs/libmyth/audio/audiooutputbase.cpp
> +++ b/mythtv/libs/libmyth/audio/audiooutputbase.cpp
> @@ -1249,9 +1249,10 @@ int AudioOutputBase::CopyWithUpmix(char *buffer,
> int frames, uint &org_waud)
>              org_waud = 0;
>          }
>          if (nFrames > 0)
> +        {
>              upmixer->receiveFrames((float *)(WPOS), nFrames);
> -
> -        org_waud = (org_waud + nFrames * bpf) % kAudioRingBufferSize;
> +            org_waud = (org_waud + nFrames * bpf) % kAudioRingBufferSize;
> +        }
>      }
>      return len;
>  }
>

your code change nothing to what was happening:
nFrames = 0, so org_waud remains 0, except I think my code reads much better.


> In fact all 3 sections in this function have the same bug.
> I also suspect this may be the cause of various avsync issues too (
> which Ive seen)

they do not.

While I'm annoyed that you could make such comment without even
bothering to actually what and how it does it, I will explain:

two possibilities.
The data to be written, can fit in the circular buffer without rolling over
That data to be written, can't fit in the circular buffer without rolling over.

the number of frames we have to write is "frames"
The total size of the audio ringbuffer is kAudioRingBufferSize, with
the position where to write is org_waud

First we calculate if it can all fit without rolling over.
bdFrames = (kAudioRingBufferSize - org_waud) / bpf
gives you how many frames can fit to the end of the circular buffer

Case 1:
if bdFrames >= frames: nothing special, we write the data as is
and we update the writing pointer with:
org_waud = (org_waud + nFrames * bpf) % kAudioRingBufferSize;
so it handles the case where bdFrames == frames and we would have been
exactly at the end of the ring buffer

Case 2:
bdFrames < frames.
So we write bdFrames only
reset the ringbuffer point org_waud (it's exactly at the end)

and now we write the remaining.

To complicate the matter, we do it in a loop because the upmixer
buffer may be smaller than the total audio to be processed. So we work
by block, upmixer->putFrames only handles the maximum it physically
can and return the number of frames it has processed.


More information about the mythtv-dev mailing list