Revision 59be6a47 src/tuner.cpp

View differences:

src/tuner.cpp
20 20
#include "tuner.h"
21 21
#include "demuxer.h"
22 22
#include "tuneparams.h"
23
#include "psfilter.h"
23 24
#include "debug.h"
24 25

  
25 26
#include <iostream>
......
64 65

  
65 66
Tuner::~Tuner()
66 67
{
67
  List copy = subscribers;
68
  SinkList copy = subscribers;
68 69

  
69 70
  unsubscribeAll();
70 71

  
71 72
  // Destroy all the Demuxes
72
  for (int h = 0; h < 2; h++) {
73
    DemuxerMap &dm = demuxerMap[h];
74
    for (DemuxerMap::iterator i = dm.begin(); i != dm.end(); i++) {
75
      PIDMap &pidmap = i->second;
76
      for (PIDMap::iterator j = pidmap.begin(); j != pidmap.end(); j++)
77
	delete j->second;
78
    }
73
  for (DemuxerMap::iterator i = demuxerMap.begin(); i != demuxerMap.end(); i++) {
74
    PIDMap &pidmap = i->second;
75
    for (PIDMap::iterator j = pidmap.begin(); j != pidmap.end(); j++)
76
      delete j->second;
79 77
  }
78

  
79
  // Destroy all the PSFilters
80
  for (PSFilterMap::iterator i = psfilterMap.begin(); i != psfilterMap.end(); i++) 
81
    delete i->second;
80 82
}
81 83

  
82 84
void Tuner::setTuneParams(const TuneParams *tuneParams)
......
101 103
  return s.readyToRead(dvrFD);
102 104
}
103 105

  
104
Demuxer *Tuner::makeNewDemuxer(int pid, bool convertToPS, Demuxer::PESType pesType) const
106
Demuxer *Tuner::makeNewDemuxer(int pid, Demuxer::PESType pesType) const
105 107
{
106
  return new Demuxer(const_cast<Tuner *>(this), pid, convertToPS, pesType);
108
  return new Demuxer(const_cast<Tuner *>(this), pid, pesType);
107 109
}
108 110

  
109 111
// Keep a list of all the demuxers ever created
110
Demuxer *Tuner::getDemuxer(int pid, bool convertToPS, Demuxer::PESType pesType) const
112
Source *Tuner::getDemuxer(int pid, bool convertToPS, Demuxer::PESType pesType) const
111 113
{
112 114
  // Strictly speaking getDemuxer() is not a const
113 115
  // method, however, it does have minimal side
......
119 121

  
120 122
  assert(tuneParams != NULL);
121 123

  
122
  DemuxerMap &dm = demuxerMap[ convertToPS ? 1 : 0 ];
124
  DemuxerMap &dm = demuxerMap;
123 125
  PIDMap &pidMap = dm[tuneParams];
124 126
  Demuxer *&demuxer = pidMap[pid];
125 127

  
126
  if (demuxer == NULL)
127
    demuxer = makeNewDemuxer(pid, convertToPS, pesType);
128
  if (demuxer == NULL) 
129
    demuxer = makeNewDemuxer(pid, pesType);
130

  
131
  if (!convertToPS) 
132
    return demuxer;
128 133

  
129
  return demuxer;
134
  PSFilter *&psfilter = psfilterMap[demuxer];
135
  if (psfilter == NULL) 
136
    psfilter = new PSFilter(demuxer);
137
  return psfilter;
130 138
}
131 139

  
132 140
bool Tuner::openFrontend()

Also available in: Unified diff