Ticket #3260: remove_audio_streams.diff

File remove_audio_streams.diff, 3.9 KB (added by skamithi, 17 years ago)

remove audio streams from the stream list during title transitions. resolves problem mentioned problem but sometimes during the transition audio is disabled and never reenabled. still testing patch.

  • libs/libmythtv/avformatdecoder.h

     
    189189
    190190    bool SetupAudioStream(void);
    191191    void SetupAudioStreamSubIndexes(int streamIndex);
     192    void RemoveAudioStreams();
    192193
    193194    /// Update our position map, keyframe distance, and the like.
    194195    /// Called for key frame packets.
     
    258259    bool dvdvideopause;
    259260    bool dvd_xvmc_enabled;
    260261    bool dvd_video_codec_changed;
     262    bool dvdTitleChanged;
    261263
    262264};
    263265
  • libs/libmythtv/avformatdecoder.cpp

     
    296296      // DVD
    297297      lastdvdtitle(-1), lastcellstart(0),
    298298      dvdmenupktseen(false), dvdvideopause(false),
    299       dvd_xvmc_enabled(false), dvd_video_codec_changed(false)
     299      dvd_xvmc_enabled(false), dvd_video_codec_changed(false),
     300      dvdTitleChanged(false)
    300301{
    301302    bzero(&params, sizeof(AVFormatParameters));
    302303    bzero(audioSamples, AVCODEC_MAX_AUDIO_FRAME_SIZE * sizeof(short int));
     
    16841685    return 1;
    16851686}
    16861687
     1688/** \brief remove audio streams from the context
     1689 * used by dvd code during title transitions to remove
     1690 * stale audio streams
     1691 */
     1692void AvFormatDecoder::RemoveAudioStreams()
     1693{
     1694    QMutexLocker locker(&avcodeclock);
     1695    for (uint i = 0; i < ic->nb_streams;)
     1696    {
     1697        AVStream *st = ic->streams[i];
     1698        if (st->codec->codec_type == CODEC_TYPE_AUDIO)
     1699        {
     1700            av_remove_stream(ic, st->id, 0);
     1701            i--;
     1702        }
     1703        else
     1704            i++;
     1705    }
     1706    av_read_frame_flush(ic);
     1707}
     1708
    16871709void release_avf_buffer(struct AVCodecContext *c, AVFrame *pic)
    16881710{
    16891711    (void)c;
     
    26922714            ringBuffer->DVD()->GetPartAndTitle(dvdpart, dvdtitle);
    26932715            uint cellstart = ringBuffer->DVD()->GetCellStart();
    26942716            selectedVideoIndex = 0;
     2717            if (dvdTitleChanged)
     2718            {
     2719                if ((storedPackets.count() > 10 && !dvdvideopause) ||
     2720                    dvdvideopause)
     2721                {
     2722                    RemoveAudioStreams();
     2723                    storevideoframes = false;
     2724                    dvdTitleChanged = false;
     2725                }
     2726                else
     2727                    storevideoframes = true;
     2728            }
     2729            else
     2730            {
     2731                if (storedPackets.count() < 2 && !dvdvideopause)
     2732                    storevideoframes = true;
     2733                else
     2734                    storevideoframes = false;
     2735            }
     2736               
    26952737            if (GetNVP()->AtNormalSpeed() &&
    26962738                ((lastcellstart != cellstart) || (lastdvdtitle != dvdtitle)))
    26972739            {
     
    27032745                    VERBOSE(VB_PLAYBACK, LOC + "DVD Title Changed");
    27042746                    ScanStreams(true);
    27052747                    lastdvdtitle = dvdtitle;
     2748                    if (lastdvdtitle != -1 )
     2749                        dvdTitleChanged = true;
    27062750                    if (GetNVP() && GetNVP()->getVideoOutput())
    27072751                    {
    27082752                        if (ringBuffer->InDVDMenuOrStillFrame())
     
    27172761                                             .arg(framesPlayed));
    27182762                lastcellstart = cellstart;
    27192763            }
    2720 
    2721             if (storedPackets.count() < 2 && !dvdvideopause)
    2722                 storevideoframes = true;
    2723             else
    2724                 storevideoframes = false;
    27252764        }
    27262765
    27272766        if (gotvideo)
     
    32703309                    gotvideo = 1;
    32713310                    framesPlayed++;
    32723311
    3273                     if (dvdmenupktseen)
     3312                    if (dvdmenupktseen && !dvdTitleChanged)
    32743313                    {
    32753314                        ringBuffer->DVD()->SetMenuPktPts(pts);
    32763315                        dvdmenupktseen = false;