Ticket #1985: deadlock-freebox.10277.diff

File deadlock-freebox.10277.diff, 3.3 KB (added by mythtv@…, 19 years ago)
  • libs/libmythtv/freeboxrecorder.cpp

     
    44 *  Distributed as part of MythTV under GPL v2 and later.
    55 */
    66
     7#include "freeboxrecorder.h"
     8
    79#include <qwaitcondition.h>
    810#include <qmutex.h>
    911
     
    1517#include "mpeg/tspacket.h"
    1618#include "freeboxchannel.h"
    1719#include "freeboxmediasink.h"
    18 #include "freeboxrecorder.h"
    1920
    2021// ============================================================================
    2122// FreeboxData : Helper class use for static Callback handler
     
    4748    MediaSession& session = subsession->parentSession();
    4849    MediaSubsessionIterator iter(session);
    4950
    50     while (subsession = iter.next())
     51    while ((subsession = iter.next()))
    5152    {
    5253        if (subsession->sink)
    5354            return;
     
    7677                        FreeboxChannel  *channel) :
    7778        _rec(recorder),
    7879        _streamData(1, true),
     80        _curChanInfo(channel->GetCurrentChanInfo()),
    7981        _live_env(NULL),
    8082        _rtsp_client(NULL),
    8183        _session(NULL),
     
    99101
    100102    // Gets
    101103    FreeboxChannelInfo GetCurrentChanInfo(void) const
    102         { return _channel->GetCurrentChanInfo(); }
     104        { return _curChanInfo; }
    103105    MPEGStreamData&    StreamData(void)
    104106        { return _streamData; }
    105107    UsageEnvironment*  GetLiveEnv(void)
     
    113115    void SetLiveEnv(UsageEnvironment *env) { _live_env    = env;     }
    114116    void SetRTSPClient(RTSPClient *client) { _rtsp_client = client;  }
    115117    void SetSession(MediaSession *session) { _session     = session; }
     118    void SetChannelInfo(const FreeboxChannelInfo& chanInfo)
     119        { _curChanInfo = chanInfo; }
    116120
    117121  public: // MPEGSingleProgramStreamListener
    118122    void HandleSingleProgramPAT(ProgramAssociationTable *pat);
     
    121125  private:
    122126    FreeboxRecorder    *_rec;
    123127    MPEGStreamData      _streamData;
     128    FreeboxChannelInfo  _curChanInfo;
    124129    UsageEnvironment   *_live_env;
    125130    RTSPClient         *_rtsp_client;
    126131    MediaSession       *_session;
     
    157162    // Ensure RTSP cleanup, remove old RTSP session
    158163    MediaSubsessionIterator iter(*_session);
    159164    MediaSubsession *subsession;
    160     while (subsession = iter.next())
     165    while ((subsession = iter.next()))
    161166    {
    162167        Medium::close(subsession->sink);
    163168        subsession->sink = NULL;
     
    194199    _impl->Close();
    195200}
    196201
    197 void FreeboxRecorder::ChannelChanged(const FreeboxChannelInfo&)
     202void FreeboxRecorder::ChannelChanged(const FreeboxChannelInfo& chanInfo)
    198203{
    199     // Channel change, we need to close current RTSP flow, and open a new one
     204    // keep a copy to avoid deadlocks
     205    _impl->SetChannelInfo(chanInfo);
     206    // Channel changed, we need to close current RTSP flow, and open a new one
    200207    ResetEventLoop();
    201208}
    202209
     
    308315    MediaSubsession *subsession;
    309316    bool madeProgress = false;
    310317
    311     while (subsession = iter.next())
     318    while ((subsession = iter.next()))
    312319    {
    313320        if (!subsession->initiate(-1))
    314321        {
     
    363370    madeProgress = false;
    364371    iter.reset();
    365372
    366     while (subsession = iter.next())
     373    while ((subsession = iter.next()))
    367374    {
    368375        if (!subsession->readSource())
    369376            continue; // was not initiated