Ticket #11440: badavsync.1.patch

File badavsync.1.patch, 2.5 KB (added by Mark Spieth, 8 years ago)
  • mythtv/libs/libmyth/audio/audiooutputbase.cpp

    commit c3aee49802ac999e3a2be9320c7796241b5b9f52
    Author: Mark Spieth <mspieth@digivation.com.au>
    Date:   Thu Mar 7 12:07:45 2013 +1100
    
        fix bad avsync
    
    diff --git a/mythtv/libs/libmyth/audio/audiooutputbase.cpp b/mythtv/libs/libmyth/audio/audiooutputbase.cpp
    index 2653076..121178c 100644
    a b int64_t AudioOutputBase::GetAudiotime(void) 
    10861086              .arg(soundcard_buffer)
    10871087              .arg(main_buffer+soundcard_buffer)
    10881088              .arg(samplerate).arg(obpf).arg(bytes_per_frame).arg(stretchfactor)
    1089               .arg((main_buffer + soundcard_buffer) * eff_stretchfactor)
    1090               .arg(((main_buffer + soundcard_buffer) * eff_stretchfactor ) /
     1089              .arg((int64_t)(main_buffer + soundcard_buffer) * eff_stretchfactor)
     1090              .arg(((int64_t)(main_buffer + soundcard_buffer) * eff_stretchfactor ) /
    10911091                   (effdsp * obpf))
    10921092              );
    10931093
    void AudioOutputBase::SetAudiotime(int frames, int64_t timecode) 
    11231123    }
    11241124
    11251125    audbuf_timecode =
    1126         timecode + (effdsp ? ((frames + processframes_unstretched * 100000) +
     1126        timecode + (effdsp ? ((frames + processframes_unstretched) * 100000 +
    11271127                    (processframes_stretched * eff_stretchfactor)
    11281128                   ) / effdsp : 0);
    11291129
    bool AudioOutputBase::AddFrames(void *in_buffer, int in_frames, 
    13191319bool AudioOutputBase::AddData(void *in_buffer, int in_len,
    13201320                              int64_t timecode, int /*in_frames*/)
    13211321{
    1322     int frames   = in_len / source_bytes_per_frame;
     1322    int in_frames= in_len / source_bytes_per_frame;
     1323    int frames   = in_frames;
    13231324    void *buffer = in_buffer;
    13241325    int bpf      = bytes_per_frame;
    13251326    int len      = in_len;
    bool AudioOutputBase::AddData(void *in_buffer, int in_len, 
    14321433    }
    14331434
    14341435    int frames_remaining = frames;
    1435     int frames_final = 0;
    14361436    int maxframes = (kAudioSRCInputSize / source_channels) & ~0xf;
    14371437    int offset = 0;
    14381438
    bool AudioOutputBase::AddData(void *in_buffer, int in_len, 
    14901490        }
    14911491
    14921492        frames = len / bpf;
    1493         frames_final += frames;
    14941493
    14951494        bdiff = kAudioRingBufferSize - waud;
    14961495        if ((len % bpf) != 0 && bdiff < len)
    bool AudioOutputBase::AddData(void *in_buffer, int in_len, 
    15891588        waud = org_waud;
    15901589    }
    15911590
    1592     SetAudiotime(frames_final, timecode);
     1591    SetAudiotime(in_frames, timecode);
    15931592
    15941593    return true;
    15951594}