MythTV / mythtv

The official MythTV repository
https://www.mythtv.org
GNU General Public License v2.0
699 stars 343 forks source link

Avoid removing PID filters when using virtual channel tuning #906

Closed SteveErl closed 4 weeks ago

SteveErl commented 1 month ago

The first step is to improve the error messages. In two places the "UpdateFilters called in wrong tune mode" message has been updated to specify the value of the wrong tune mode.

After these updates, an example of the error message is:

mythbackend: mythbackend[779282]: E HDHRStreamHandler hdhrstreamhandler.cpp:242 (UpdateFilters) HDHRSH[4] (13249773): UpdateFilters called in wrong tune mode, 4

The tune mode was hdhrTuneModeVChannel (= 4), and we know that UpdateFilters was called, but in hdhrstreamhandler.cpp, the only call to it is avoided for Vchan tuning.

108 void HDHRStreamHandler::run(void)
...
140             UpdateFiltersFromStreamData();
141             if (m_tuneMode != hdhrTuneModeVChannel)
142                 UpdateFilters();

Code examination reveals that the offending invocation of UpdateFilters() is in StreamHandler::RemoveAllPIDFilters().

This routine is called unconditionally in

108 void HDHRStreamHandler::run(void)
...
183     LOG(VB_RECORD, LOG_INFO, LOC + "RunTS(): " + "shutdown");
184
185     RemoveAllPIDFilters();

The solution is to condition the call to RemoveAllPIDFilters() in the same way the call to UpdateFilters() was previously conditioned. If we're using Virtual Channel Tuning, then don't bother removing filters which were never created in the first place.

After applying this solution, the UpdateFilters called in wrong tune mode error messages no longer appear in mythbackend.log.

Resolves #905

Checklist
kmdewaal commented 4 weeks ago

I cannot test this myself but it looks good.