Fix any instance where null is checked (or tracked) in
From: Erik Hovland <erik@hovland.org>
a function once and not checked every time the pointer
is used.
---
mythtv/libs/libmythtv/NuppelVideoPlayer.cpp | 42 ++++++++++++++++-----------
mythtv/libs/libmythtv/guidegrid.cpp | 4 +--
mythtv/libs/libmythtv/tv_play.cpp | 20 +++++++++----
mythtv/libs/libmythtv/tv_rec.cpp | 16 ++++++----
4 files changed, 51 insertions(+), 31 deletions(-)
diff --git a/mythtv/libs/libmythtv/NuppelVideoPlayer.cpp b/mythtv/libs/libmythtv/NuppelVideoPlayer.cpp
index 23380c0..a3dd0d6 100644
a
|
b
|
void NuppelVideoPlayer::InitAVSync(void) |
2299 | 2299 | warpfactor = warpfactor_avg; |
2300 | 2300 | } |
2301 | 2301 | |
2302 | | refreshrate = videoOutput->GetRefreshRate(); |
| 2302 | refreshrate = videoOutput ? videoOutput->GetRefreshRate() : -1; |
2303 | 2303 | if (refreshrate <= 0) |
2304 | 2304 | refreshrate = frame_interval; |
| 2305 | |
2305 | 2306 | vsynctol = refreshrate / 4; |
2306 | 2307 | |
2307 | 2308 | if (!using_null_videoout) |
… |
… |
void NuppelVideoPlayer::OutputVideoLoop(void) |
2884 | 2885 | |
2885 | 2886 | if (ringBuffer->isDVD()) |
2886 | 2887 | { |
2887 | | int nbframes = videoOutput->ValidVideoFrames(); |
| 2888 | int nbframes = 0; |
| 2889 | if (videoOutput) |
| 2890 | nbframes = videoOutput->ValidVideoFrames(); |
2888 | 2891 | |
2889 | 2892 | if (nbframes < 2) |
2890 | 2893 | { |
… |
… |
void NuppelVideoPlayer::DoPlay(void) |
4148 | 4151 | if (skip_changed) |
4149 | 4152 | { |
4150 | 4153 | //cout << "handling skip change" << endl; |
4151 | | videoOutput->SetPrebuffering(ffrew_skip == 1); |
| 4154 | if (videoOutput) { |
| 4155 | videoOutput->SetPrebuffering(ffrew_skip == 1); |
4152 | 4156 | |
4153 | 4157 | #ifdef USING_IVTV |
4154 | | if (IsIVTVDecoder()) |
4155 | | { |
4156 | | VideoOutputIvtv *vidout = (VideoOutputIvtv *)videoOutput; |
4157 | | vidout->NextPlay(play_speed / ffrew_skip, normal_speed, |
4158 | | (ffrew_skip == 1) ? 2 : 0); |
4159 | | } |
| 4158 | if (IsIVTVDecoder()) |
| 4159 | { |
| 4160 | VideoOutputIvtv *vidout = dynamic_cast<VideoOutputIvtv *>(videoOutput); |
| 4161 | if (vidout) |
| 4162 | vidout->NextPlay(play_speed / ffrew_skip, normal_speed, |
| 4163 | (ffrew_skip == 1) ? 2 : 0); |
| 4164 | } |
4160 | 4165 | #endif |
| 4166 | } |
4161 | 4167 | |
4162 | 4168 | GetDecoder()->setExactSeeks(exactseeks && ffrew_skip == 1); |
4163 | 4169 | GetDecoder()->DoRewind(framesPlayed); |
… |
… |
void NuppelVideoPlayer::DoPlay(void) |
4203 | 4209 | } |
4204 | 4210 | |
4205 | 4211 | #ifdef USING_IVTV |
4206 | | if (IsIVTVDecoder()) |
| 4212 | if (IsIVTVDecoder() && videoOutput) |
4207 | 4213 | { |
4208 | | VideoOutputIvtv *vidout = (VideoOutputIvtv *)videoOutput; |
4209 | | vidout->Play(play_speed / ffrew_skip, normal_speed, |
4210 | | (ffrew_skip == 1) ? 2 : 0); |
| 4214 | VideoOutputIvtv *vidout = dynamic_cast<VideoOutputIvtv *>(videoOutput); |
| 4215 | if (vidout) |
| 4216 | vidout->Play(play_speed / ffrew_skip, normal_speed, |
| 4217 | (ffrew_skip == 1) ? 2 : 0); |
4211 | 4218 | } |
4212 | 4219 | #endif |
4213 | 4220 | |
… |
… |
long long NuppelVideoPlayer::CalcMaxFFTime(long long ff, bool setjump) const |
4316 | 4323 | if (behind < maxtime || behind - ff <= maxtime * 2) |
4317 | 4324 | { |
4318 | 4325 | ret = -1; |
4319 | | if (setjump) |
| 4326 | if (setjump && livetvchain) |
4320 | 4327 | livetvchain->JumpToNext(true, 1); |
4321 | 4328 | } |
4322 | 4329 | } |
… |
… |
bool NuppelVideoPlayer::IsReallyNearEnd(void) const |
4397 | 4404 | */ |
4398 | 4405 | bool NuppelVideoPlayer::IsNearEnd(long long margin) const |
4399 | 4406 | { |
4400 | | long long framesRead, framesLeft; |
| 4407 | long long framesRead, framesLeft = 0; |
4401 | 4408 | |
4402 | 4409 | if (!m_playbackinfo || m_playbackinfo->isVideo || !GetDecoder()) |
4403 | 4410 | return false; |
… |
… |
bool NuppelVideoPlayer::IsNearEnd(long long margin) const |
4433 | 4440 | if (livetv && livetvchain && livetvchain->HasNext()) |
4434 | 4441 | return false; |
4435 | 4442 | |
4436 | | framesLeft = nvr_enc->GetCachedFramesWritten() - framesRead; |
| 4443 | if (nvr_enc) |
| 4444 | framesLeft = nvr_enc->GetCachedFramesWritten() - framesRead; |
4437 | 4445 | |
4438 | 4446 | // if it looks like we are near end, get an updated GetFramesWritten() |
4439 | | if (framesLeft < margin) |
| 4447 | if (framesLeft < margin && nvr_enc) |
4440 | 4448 | framesLeft = nvr_enc->GetFramesWritten() - framesRead; |
4441 | 4449 | |
4442 | 4450 | return (framesLeft < margin); |
diff --git a/mythtv/libs/libmythtv/guidegrid.cpp b/mythtv/libs/libmythtv/guidegrid.cpp
index 64d3659..bf80e52 100644
a
|
b
|
void GuideGrid::fillProgramRowInfos(unsigned int row) |
1212 | 1212 | } |
1213 | 1213 | else |
1214 | 1214 | { |
1215 | | if (proginfo == *program) |
| 1215 | if (proginfo && proginfo == *program) |
1216 | 1216 | { |
1217 | 1217 | proginfo->spread++; |
1218 | 1218 | } |
1219 | | else |
| 1219 | else if (*program) |
1220 | 1220 | { |
1221 | 1221 | proginfo = *program; |
1222 | 1222 | proginfo->startCol = x; |
diff --git a/mythtv/libs/libmythtv/tv_play.cpp b/mythtv/libs/libmythtv/tv_play.cpp
index f4a525e..2c42c33 100644
a
|
b
|
void TV::SwapPIP(void) |
4057 | 4057 | main.buffer = prbuffer; |
4058 | 4058 | main.recorder = recorder; |
4059 | 4059 | main.chain = tvchain; |
4060 | | main.frame = nvp->GetFramesPlayed(); |
| 4060 | main.frame = nvp ? nvp->GetFramesPlayed() : -1; |
4061 | 4061 | pip.buffer = piprbuffer; |
4062 | 4062 | pip.recorder = piprecorder; |
4063 | 4063 | pip.chain = piptvchain; |
… |
… |
void TV::SwapPIP(void) |
4069 | 4069 | piprbuffer->Pause(); |
4070 | 4070 | piprbuffer->WaitForPause(); |
4071 | 4071 | |
4072 | | nvp->StopPlaying(); |
| 4072 | if (nvp) |
| 4073 | nvp->StopPlaying(); |
| 4074 | |
4073 | 4075 | pipnvp->StopPlaying(); |
| 4076 | |
4074 | 4077 | { |
4075 | 4078 | QMutexLocker locker(&osdlock); // prevent UpdateOSDSignal using osd... |
4076 | 4079 | pthread_join(decode, NULL); |
… |
… |
void TV::DoPause(bool showOSD) |
4219 | 4222 | |
4220 | 4223 | if (paused) |
4221 | 4224 | { |
4222 | | activerbuffer->WaitForPause(); |
| 4225 | if (activerbuffer) |
| 4226 | activerbuffer->WaitForPause(); |
| 4227 | |
4223 | 4228 | DoNVPSeek(time); |
4224 | 4229 | if (showOSD) |
4225 | 4230 | UpdateOSDSeekMessage(tr("Paused"), -1); |
… |
… |
void TV::ChangeChannel(uint chanid, const QString &chan) |
5130 | 5135 | if (!prevChan.empty() && prevChan.back() == channum) |
5131 | 5136 | return; |
5132 | 5137 | |
5133 | | if (!activerecorder->CheckChannel(channum)) |
| 5138 | if (!activerecorder || !activerecorder->CheckChannel(channum)) |
5134 | 5139 | return; |
5135 | 5140 | |
5136 | 5141 | if (nvp) |
… |
… |
bool TV::VideoThemeCheck(QString str, bool stayPaused) |
5874 | 5879 | bool ret = true; |
5875 | 5880 | bool allowembed = (nvp && nvp->getVideoOutput() && |
5876 | 5881 | nvp->getVideoOutput()->AllowPreviewEPG()); |
| 5882 | long long margin = 0; |
| 5883 | |
| 5884 | if (nvp) |
| 5885 | margin = static_cast<long long>((nvp->GetFrameRate() * |
| 5886 | nvp->GetAudioStretchFactor())); |
5877 | 5887 | |
5878 | | long long margin = (long long)(nvp->GetFrameRate() * |
5879 | | nvp->GetAudioStretchFactor()); |
5880 | 5888 | margin = margin * 5; |
5881 | 5889 | QDomElement xmldata; |
5882 | 5890 | XMLParse *theme = new XMLParse(); |
diff --git a/mythtv/libs/libmythtv/tv_rec.cpp b/mythtv/libs/libmythtv/tv_rec.cpp
index 04d94a2..b76d823 100644
a
|
b
|
static QString load_profile(QString cardtype, void *tvchain, |
3944 | 3944 | void TVRec::TuningNewRecorder(MPEGStreamData *streamData) |
3945 | 3945 | { |
3946 | 3946 | VERBOSE(VB_RECORD, LOC + "Starting Recorder"); |
| 3947 | #ifdef USING_V4L |
| 3948 | V4LChannel* v4lChannel = 0; |
| 3949 | #endif |
3947 | 3950 | |
3948 | 3951 | bool had_dummyrec = false; |
3949 | 3952 | if (HasFlags(kFlagDummyRecorderRunning)) |
… |
… |
void TVRec::TuningNewRecorder(MPEGStreamData *streamData) |
4038 | 4041 | |
4039 | 4042 | // Setup for framebuffer capture devices.. |
4040 | 4043 | if (channel) |
4041 | | { |
4042 | 4044 | SetVideoFiltersForChannel(channel->GetCurrentSourceID(), |
4043 | 4045 | channel->GetCurrentName()); |
4044 | | } |
4045 | 4046 | |
4046 | 4047 | #ifdef USING_V4L |
4047 | | if (GetV4LChannel()) |
| 4048 | v4lChannel = GetV4LChannel(); |
| 4049 | if (v4lChannel) |
4048 | 4050 | { |
4049 | | channel->InitPictureAttributes(); |
| 4051 | v4lChannel->InitPictureAttributes(); |
4050 | 4052 | CloseChannel(); |
4051 | 4053 | } |
4052 | 4054 | #endif |
… |
… |
void TVRec::TuningNewRecorder(MPEGStreamData *streamData) |
4059 | 4061 | usleep(5 * 1000); |
4060 | 4062 | stateChangeLock.lock(); |
4061 | 4063 | |
4062 | | if (GetV4LChannel()) |
4063 | | channel->SetFd(recorder->GetVideoFd()); |
| 4064 | #ifdef USING_V4L |
| 4065 | if (v4lChannel) |
| 4066 | v4lChannel->SetFd(recorder->GetVideoFd()); |
| 4067 | #endif |
4064 | 4068 | |
4065 | 4069 | SetFlags(kFlagRecorderRunning | kFlagRingBufferReady); |
4066 | 4070 | |