Opened 21 years ago
Closed 21 years ago
#339 closed task (fixed)
Simplify Tuning process
| Reported by: | danielk | Owned by: | danielk |
|---|---|---|---|
| Priority: | major | Milestone: | 0.19 |
| Component: | mythtv | Version: | head |
| Severity: | medium | Keywords: | |
| Cc: | Ticket locked: | no |
Description
(Copied from the close of #326)
The tuning process is just way to complicated, I'd like to break it up into states and handle it all in one thread. Right now it takes place in three different threads. The pause locking I implemented makes this possible, but really it would be better to do the tuning in different states from within the RunTV loop, with multiple states that allow each portion of the tuning to be quick, but also don't require 'abort' support or shutdown of the last incomplete tune from within Pause() when there isn't a signal, etc.
If you changed the channel or exited the program you would just have to fallback to the untuned tuning state and then work your way back up to [re]starting the recorder. Now we have one tuning process before you start the recorder, another one after you start it (channel changes), and yet another process when you tune for the EITParser's passive EIT scan (where the recorder is not started).
Attachments (7)
Change History (14)
comment:1 by , 21 years ago
| Owner: | changed from to |
|---|---|
| Status: | new → assigned |
by , 21 years ago
| Attachment: | tuning-v1.patch.bz2 added |
|---|
comment:3 by , 21 years ago
Yep, I've split off the recorder changes locally, plus I'm also going to split off the tv_play changes, plus...
The recorders change was basically a Pause() refactoring to unify that code, and a fix for the DVBRecorder pause, which doesn't engage until after some data has been sent or it gets an error. This causes the "15 second delay" when changing away from an "no lock" station with the DVB drivers
The tv_play change is basically adding some caching for the channel/program data in the signal monitor. This was causing the unresponsive UI. Basically the frontend was hitting the backend way too often for info for the UI. Plus there is some additional timing info, and I've changed the "Signal Lock" message to "Partial Lock" since this has caused so much confusion.
I haven't gone through the rest of the files, but I'm sure there is a lot of pruning to do... TVRec isn't ready either, it doesn't implement tuning timeouts and I've only tested with DVB drivers.
comment:4 by , 21 years ago
Heh. Sorry, but... The tv_rec changes are pretty iffy, I think. I don't understand why you like replacing member variable accesses with function calls. It's not any easier to read, IMO, and liable to make things slower if the compiler doesn't decide those functions get inlined. The extra macros aren't good, either, especially the verbose wrappers. It just makes it harder to read if a section of code is using its own macros instead of the same functions everything else is.
The recorders Pause 'unification' looks fairly meaningless. Each of the 3 major types has completely different pausing mechanisms, so it's not really unifying anything.
The idea is to get _rid_ of the usleeps & polling, not add more. =)
comment:5 by , 21 years ago
tuning-v2.patch applied to 7283 breaks scheduled recordings for me. Backend log below. I'm not at home, so I haven't had a chance to test live TV yet.
Cheers,
Jon
2005-09-22 17:57:40.991 mythbackend version: 0.19.20050712-1 www.mythtv.org
2005-09-22 17:57:40.992 Enabled verbose msgs : important general record channel siparser
2005-09-22 17:57:40.998 AutoExpire: Found 2 recorders w/max rate of 277 MiB/min
2005-09-22 17:57:41.001 AutoExpire: space: 2.2 GB w/freq: 5 min
2005-09-22 17:57:42.983 Reschedule requested for id -1.
2005-09-22 17:57:43.158 Scheduled 23 items in 0.2 = 0.03 match + 0.14 place
2005-09-22 17:57:43.167 Recording starts soon, AUTO-Startup assumed
2005-09-22 17:57:51.004 New DB connection, total: 4
2005-09-22 17:58:01.253 TVRec(1): Changing from None to RecordingOnly
2005-09-22 17:58:01.261 TVRec(1): Request: Program(0x8122a78) channel() input() flags(Recording,)
2005-09-22 17:58:01.261 Started recording Global Village "Village Nativity/Valley Of The World's Dawn": channel 1003 on cardid 1, sourceid 1
2005-09-22 17:58:01.264 DVB#0 Opening DVB channel
2005-09-22 17:58:01.265 DVB#0 Trying to tune to channel 3.
2005-09-22 17:58:01.270 DVB#0 Frequency: 571500000 BW: 7MHz HP: 2/3 LP: 1/2C: QAM-64 TM: 8K H: None GI: 1/8
2005-09-22 17:58:01.271 DVB#0 Old Params: freq(219500000) type(OFDM)
2005-09-22 17:58:01.271 DVB#0 New Params: freq(571500000) type(OFDM)
2005-09-22 17:58:01.298 dvbchannel.cpp:wait_for_backend: Status: Signal,
2005-09-22 17:58:01.299 DVB#0 DVBChannel::Tune: Frequency tuning successful.
2005-09-22 17:58:01.300 DVB#0 Tuned to frequency for channel 3.
2005-09-22 17:58:01.317 TVRec(1): Starting Signal Monitor
2005-09-22 17:58:01.318 TVRec(1): SetSignalMonitoringRate(50, 0)
2005-09-22 17:58:01.319 TVRec(1): SetupSignalMonitor()
2005-09-22 17:58:01.320 DVB#0 Opening DVB channel
2005-09-22 17:58:01.343 SM(0)::AddFlags: Seen() Match() Wait(Sig,SNR,BER,UB,)
2005-09-22 17:58:01.344 DVBSM(0)::constructor(): initial flags 0x7400000
2005-09-22 17:58:01.344 TVRec(1): signal monitor successfully created
2005-09-22 17:58:01.345 TVRec(1): Setting up table monitoring.
2005-09-22 17:58:01.345 TVRec(1): Not ATSC channel: major(-1) minor(-1).
2005-09-22 17:58:01.346 TVRec(1): mpeg program number: 769
2005-09-22 17:58:01.347 DTVSM(0)::SetProgramNumber(769):
2005-09-22 17:58:01.347 SM(0)::RemoveFlags: Seen(PMT,) Match(PMT,) Wait()
2005-09-22 17:58:01.348 SM(0)::AddFlags: Seen() Match() Wait(PMT,)
2005-09-22 17:58:01.350 SM(0)::AddFlags: Seen() Match() Wait(PAT,PMT,)
2005-09-22 17:58:01.351 TVRec(1): Successfully set up MPEG table monitoring.
2005-09-22 17:58:01.351 SM(0)::Start: begin
2005-09-22 17:58:01.370 SM(0)::Start: end
2005-09-22 17:58:01.376 AddFlags (WaitingForSignal,SignalMonitorRunning,) -> WaitingForSignal,SignalMonitorRunning,
2005-09-22 17:58:01.375 DTVSM(0)::GetStatusList: WaitForPMT seen(0) matching(0)
2005-09-22 17:58:01.393 AddFlags (NeedToStartRecorder,) -> WaitingForSignal,NeedToStartRecorder,SignalMonitorRunning,
2005-09-22 17:58:01.471 DVBSM(0)::UpdateValues: Signal Locked
2005-09-22 17:58:01.472 DVBSM(0)::UpdateValues: Waiting for table monitor to start
2005-09-22 17:58:01.485 DVBSM(0)::UpdateValues: Table monitor started
2005-09-22 17:58:01.488 DVBSM(0)::RunTableMonitor(): begin (# of pids 2)
2005-09-22 17:58:01.489 DVBSM(0)::AddPIDFilter(0x0):
2005-09-22 17:58:01.496 DVBSM(0)::AddPIDFilter(0x1ffb):
2005-09-22 17:58:01.529 SM(0)::AddFlags: Seen(PAT,) Match() Wait()
2005-09-22 17:58:01.530 SM(0)::AddFlags: Seen() Match(PAT,) Wait()
2005-09-22 17:58:01.530 CreatePATSingleProgram()
2005-09-22 17:58:01.531 PAT in input stream
2005-09-22 17:58:01.531 Program Association Table
PSIP prefix(0x0) tableID(0x0) length(37) extension(0x300)
version(24) current(1) section(0) last_section(0)
tsid: 768
programCount: 7
program number 0 has PID 0x 10 data 0x0 0x0 0x224 0x16
program number 768 has PID 0x 400 data 0x3 0x0 0x228 0x0
program number 769 has PID 0x 401 data 0x3 0x1 0x228 0x1
program number 770 has PID 0x 402 data 0x3 0x2 0x228 0x2
program number 772 has PID 0x 408 data 0x3 0x4 0x228 0x8
program number 782 has PID 0x 403 data 0x3 0x14 0x228 0x3
program number 783 has PID 0x 404 data 0x3 0x15 0x228 0x4
2005-09-22 17:58:01.532 desired_program(769) pid(0x401)
2005-09-22 17:58:01.533 pmt_pid(0x401)
2005-09-22 17:58:01.533 PAT for output stream
2005-09-22 17:58:01.534 Program Association Table
PSIP prefix(0x0) tableID(0x0) length(13) extension(0x300)
version(24) current(1) section(0) last_section(0)
tsid: 768
programCount: 1
program number 1 has PID 0x 401 data 0x0 0x1 0x228 0x1
2005-09-22 17:58:01.535 DVBSM(0)::AddPIDFilter(0x401):
2005-09-22 17:58:01.549 SM(0)::AddFlags: Seen(PMT,) Match() Wait()
2005-09-22 17:58:01.550 SM(0)::AddFlags: Seen() Match(PMT,) Wait()
2005-09-22 17:58:01.550 CreatePMTSingleProgram()
2005-09-22 17:58:01.551 PMT in input stream
2005-09-22 17:58:01.551 Program Map Table ver(20) pid(0x401) pnum(769)
Stream #0 pid(0xa1) type(video-mpeg2 0x2)
ISO-639 Language Descriptor (0xa) length(4)
Stream Identifier Descriptor (0x52) length(1)
Stream #1 pid(0x51) type(audio-mp1-layer[1,2,3] 0x3)
ISO-639 Language Descriptor (0xa) length(4)
Stream Identifier Descriptor (0x52) length(1)
Stream #2 pid(0x29) type(private-data 0x6)
ISO-639 Language Descriptor (0xa) length(4)
Stream Identifier Descriptor (0x52) length(1)
Teletext Descriptor (0x56) length(5)
Stream #3 pid(0x384) type(dsmcc-b std data 0x11)
Stream Identifier Descriptor (0x52) length(1)
Unknown Descriptor (0x13) length(25)
Unknown Descriptor (0x14) length(13)
Data Broadcast Identifier Descriptor (0x66) length(2)
Stream #4 pid(0x1f4) type(private-sec 0x5)
Stream Identifier Descriptor (0x52) length(1)
Application Signalling Descriptor (0x6f) length(3)
2005-09-22 17:58:01.553 TVRec(1): Got good signal
2005-09-22 17:58:01.553 PMT for output stream
2005-09-22 17:58:01.554 TVRec(1): SetSignalMonitoringRate(0, 0)
2005-09-22 17:58:01.554 Program Map Table ver(20) pid(0x401) pnum(1)
Stream #0 pid(0xa1) type(video-mpeg2 0x2)
Stream #1 pid(0x51) type(audio-mp1-layer[1,2,3] 0x3)
2005-09-22 17:58:01.555 TVRec(1): TeardownSignalMonitor() -- begin
2005-09-22 17:58:01.556 DVBSM(0)::Stop: begin
2005-09-22 17:58:01.556 SM(0)::Stop: begin
2005-09-22 17:58:01.597 SM(0)::Stop: end
2005-09-22 17:58:01.601 DVBSM(0)::RunTableMonitor(): shutdown
2005-09-22 17:58:01.601 DVBSM(0)::RemovePIDFilter(0x0):
2005-09-22 17:58:01.602 DVBSM(0)::RemovePIDFilter(0x401):
2005-09-22 17:58:01.602 DVBSM(0)::RemovePIDFilter(0x1ffb):
2005-09-22 17:58:01.913 DVBSM(0)::RunTableMonitor(): end
2005-09-22 17:58:01.914 DVBSM(0)::Stop: end
2005-09-22 17:58:01.914 DVBSM(0)::Stop: begin
2005-09-22 17:58:01.915 SM(0)::Stop: begin
2005-09-22 17:58:01.915 SM(0)::Stop: end
2005-09-22 17:58:01.916 DVBSM(0)::Stop: end
2005-09-22 17:58:01.916 SM(0)::Stop: begin
2005-09-22 17:58:01.917 SM(0)::Stop: end
2005-09-22 17:58:01.917 TVRec(1): TeardownSignalMonitor() -- end
2005-09-22 17:58:01.918 ClearFlags(WaitingForSignal,SignalMonitorRunning,) -> NeedToStartRecorder,
2005-09-22 17:58:01.918 TVRec(1): prog_num(769) vs. dvbc->srv_id(769)
2005-09-22 17:58:01.919 SIParser: About to do a reset
2005-09-22 17:58:01.920 SIParser: Closing all PIDs
2005-09-22 17:58:01.920 SIParser: Using DelAllPids from SIParser which does nothing
2005-09-22 17:58:01.921 SIParser: Resetting all Table Handlers
2005-09-22 17:58:01.921 SIParser: SIParser Reset due to channel change
2005-09-22 17:58:01.926 SIParser: Added preferred language with priority 1
2005-09-22 17:58:01.927 DVB#0 DVB SI Table Parser Started
2005-09-22 17:58:01.928 SIParser: ReinitSIParser(std dvb, service #769)
2005-09-22 17:58:01.928 SIParser: Starting DVB Section Reader thread
2005-09-22 17:58:01.928 FillPMap(str dvb)
2005-09-22 17:58:01.929 FillPMap(SIS dvb)
2005-09-22 17:58:01.930 SIParser: Requesting PAT
2005-09-22 17:58:01.930 SIParser: Adding the Service with ID 769 in the SDT to the request list
QObject::connect: No such signal DVBChannel::ChannelChanged(dvb_channel_t&)
QObject::connect: (sender name: 'DVBChannel')
QObject::connect: (receiver name: 'EITScanner')
2005-09-22 17:58:01.932 AddFlags (WaitingForSIParser,SIParserRunning,) -> WaitingForSIParser,NeedToStartRecorder,SIParserRunning,
2005-09-22 17:58:02.941 SIParser: Table[0]->RequirePIDs() == true
2005-09-22 17:58:02.941 SIParser: Adding PID 0x 0 Filter 0x 0 Mask 0xff Buffer 40960
2005-09-22 17:58:02.947 SIParser: Table[2]->RequirePIDs() == true
2005-09-22 17:58:02.947 SIParser: Adding PID 0x1ffb Filter 0xff Mask 0x 0 Buffer 40960
2005-09-22 17:58:02.948 SIParser: Table[3]->RequirePIDs() == true
2005-09-22 17:58:02.949 SIParser: Adding PID 0x1ffb Filter 0xff Mask 0x 0 Buffer 40960
2005-09-22 17:58:02.949 SIParser: Table[6]->RequirePIDs() == true
2005-09-22 17:58:02.950 SIParser: Adding PID 0x 10 Filter 0x40 Mask 0xff Buffer 40960
2005-09-22 17:58:03.135 SIParser: PAT Version = 16
2005-09-22 17:58:03.136 SIParser: Tuned to TransportID: 768
2005-09-22 17:58:03.136 SIParser: NIT Present on this transport on PID 0x10
2005-09-22 17:58:03.137 SIParser: PMT #768 on PID 0x1024
2005-09-22 17:58:03.137 SIParser: PMT #769 on PID 0x1025
2005-09-22 17:58:03.138 SIParser: PMT #770 on PID 0x1026
2005-09-22 17:58:03.138 SIParser: PMT #772 on PID 0x1032
2005-09-22 17:58:03.139 SIParser: PMT #782 on PID 0x1027
2005-09-22 17:58:03.139 SIParser: PMT #783 on PID 0x1028
2005-09-22 17:58:03.140 SIParser: Services on this Transport: 768 769 770 772 782 783
2005-09-22 17:58:03.140 SIParser: Table[0]->Complete() == true
2005-09-22 17:58:03.141 SIParser: Table[1]->RequirePIDs() == true
2005-09-22 17:58:03.141 SIParser: Adding PID 0x 401 Filter 0x 2 Mask 0xff Buffer 40960
2005-09-22 17:58:03.254 SIParser: PMT ServiceID: 769 Version = 9
2005-09-22 17:58:03.255 SIParser: PID: 161
2005-09-22 17:58:03.256 SIParser: Unknown descriptor, tag = 82
2005-09-22 17:58:03.256 SIParser: PID: 81
2005-09-22 17:58:03.257 SIParser: Unknown descriptor, tag = 82
2005-09-22 17:58:03.257 SIParser: PID: 41
2005-09-22 17:58:03.257 SIParser: Unknown descriptor, tag = 82
2005-09-22 17:58:03.258 SIParser: Teletext Descriptor
2005-09-22 17:58:03.258 SIParser: lang: eng, type: 2, mag: 0, page: 1
2005-09-22 17:58:03.259 SIParser: PID: 900
2005-09-22 17:58:03.259 SIParser: Unknown descriptor, tag = 82
2005-09-22 17:58:03.260 SIParser: Unknown descriptor, tag = 19
2005-09-22 17:58:03.260 SIParser: Unknown descriptor, tag = 20
2005-09-22 17:58:03.261 SIParser: Unknown descriptor, tag = 102
2005-09-22 17:58:03.261 SIParser: PID: 500
2005-09-22 17:58:03.262 SIParser: Unknown descriptor, tag = 82
2005-09-22 17:58:03.262 SIParser: Unknown descriptor, tag = 111
2005-09-22 17:58:03.263 SIParser: Table[1]->EmitRequired() == true
2005-09-22 17:58:03.263 DVB#0 SetPMT ServiceID=769, PCRPID=161 (0xa1)
2005-09-22 17:58:03.269 TVRec(1): Got SIParser PMT
2005-09-22 17:58:03.269 ClearFlags(WaitingForSIParser,) -> NeedToStartRecorder,SIParserRunning,
2005-09-22 17:58:03.277 TVRec(1): Starting Recorder
2005-09-22 17:58:03.377 TVRec(1): Using profile 'Default' to record
2005-09-22 17:58:03.378 TVRec(1): RingBuffer not open...
2005-09-22 17:58:03.379 ClearFlags(PENDINGACTIONS,) -> SIParserRunning,
2005-09-22 17:58:03.385 TVRec(1): Changing from RecordingOnly to None
2005-09-22 17:58:03.385 TVRec(1): Request: Program(0x0) channel() input() flags(CloseRec,)
2005-09-22 17:58:03.389 Finished recording Global Village "Village Nativity/Valley Of The World's Dawn": channel 1003
2005-09-22 17:58:03.391 ClearFlags(PENDINGACTIONS,) -> SIParserRunning,
by , 21 years ago
| Attachment: | tuning-v5.patch.bz2 added |
|---|
tuning patch against rev 7306. appears to work for recordings, but only so far as recording program, does not insert into DB....
by , 21 years ago
| Attachment: | tuning-v6.patch.bz2 added |
|---|
tuning patch against revision 7306. Fixes DB problem in v5.
by , 21 years ago
| Attachment: | tuning-v7.patch.bz2 added |
|---|
tuning patch v7, implements busy loop free TVRec
comment:6 by , 21 years ago
The v7 patch implements a 30 second wait in the TVRec event loop, unless there is an event to process. If you actually see such long delays in reacting to an event please send me the "mythbackend -v channel,record" output and a description of what caused it. I'm basically looking for any event triggers that I may have missed.
BTW v7 is against revision 7316.

First version of tuning patch