Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#10736 closed Patch - Bug Fix (Fixed)

Fix passthrough case of mythtrancode running in fifo mode

Reported by: mythtv@… Owned by: beirdo
Priority: minor Milestone: 0.25.2
Component: MythTV - Mythtranscode Version: 0.25-fixes
Severity: medium Keywords:
Cc: Ticket locked: no


This is just a reminder for Gavin to sometime take another look at Ticket #10693. After just a very quick look before he thought it missed an important case, but I'm pretty sure it doesn't. He said he'd take another look, but hasn't had a chance yet, I guess. Without this ticket, it might fall completely off the radar.

Change History (4)

comment:1 Changed 9 years ago by mythtv@…

JYA noticed another problem, to do with the accuracy of the timecode calculation. I've added a commit also to fix that, plus I've commented the algorith. Here's an updated pull request containing both commits: To help anyone wishing to check this without applying the commits, here's the updated version of addData, which is the main change:

    virtual bool AddData(void *buffer, int len, int64_t timecode, int frames)
        unsigned char *buf = (unsigned char *)buffer;

        // Test if target is using a fixed buffer size.
        if (m_audioFrameSize)
            int index = 0;
            int total_frames = 0;

            // Target has a fixed buffer size, which may not match len.
            // Redistribute the bytes into appropriately sized buffers.
            while (index < len)
                // See if we have some saved from last iteration in
                // m_saveBuffer. If not create a new empty buffer.
                if (!m_saveBuffer)
                    m_saveBuffer = new AudioBuffer();

                // Use as many of the remaining frames as will fit in the space
                // left in the buffer.
                int part = min(len - index,
                               m_audioFrameSize - m_saveBuffer->m_buffer.size());
                total_frames += part / m_bytes_per_frame;
                timecode = total_frames * 1000 / m_eff_audiorate;
                // Store frames in buffer, basing frame count on number of bytes,
                // which works only for uncompressed data.
                m_saveBuffer->appendData(&buf[index], part, part / m_bytes_per_frame,

                // If we have filled the buffer...
                if (m_saveBuffer->m_buffer.size() == m_audioFrameSize)
                    // store the buffer
                    // mark m_saveBuffer as emtpy.
                    m_saveBuffer = NULL;
                    // m_last_audiotime is updated iff we store a buffer.
                    m_last_audiotime = timecode;

                index += part;
            // Target has no fixed buffer size. We can use a simpler algorithm
            // and use 'frames' directly rather than 'len / m_bytes_per_frame',
            // thus also covering the passthrough case.
            m_saveBuffer = new AudioBuffer();
            timecode += frames * 1000 / m_eff_audiorate;
            m_saveBuffer->appendData(buf, len, frames, timecode);

            m_saveBuffer = NULL;
            m_last_audiotime = timecode;

        return true;

comment:2 Changed 9 years ago by ashtonprairie@…

Since this new enhancement (audio passthru of any audio type using fifos) is broken in the 0.25 release pending resolution of this ticket, I have added a note to the 0.25 Release Notes to indicate that it is not working, with a link to this ticket. Hopefully this will prevent other users from spending effort trying to make it work until a fix is available.

Paul, you may want to add a similar note to your sample script on the wiki (further to your note that the passthru option requires 0.25.)

comment:3 Changed 9 years ago by beirdo

Milestone: unknown0.25.2
Resolution: Fixed
Status: newclosed

Merged into fixes/0.25, ported to master (and minor fixes).

comment:4 Changed 9 years ago by beirdo

Owner: set to beirdo
Note: See TracTickets for help on using tickets.