Continuing service after modifying file

Moderators: Gully, peteru

Post Reply
User avatar
adoxa
Wizard
Posts: 1490
Joined: Thu Feb 23, 2017 22:58
Location: CQ
Contact:

Continuing service after modifying file

Post by adoxa » Sun Apr 09, 2017 17:00

I've added "end at this position" to the cutlist editor, which truncates the .ts file (as well as .ap & .sc). The actual truncation is working fine, but I'd like to stay in the editor and that's where I'm having problems. If I do nothing, the gauge remains at the original length. If I restart the service (stopService/playService), the gauge updates, but then the edits are skipped and the last position is saved. If I get the cuesheet again (self.session.nav.getCurrentService().cueSheet()), then playback doesn't work at all. Is this doable or should I just "and exit"?

prl
Wizard God
Posts: 32705
Joined: Tue Sep 04, 2007 13:49
Location: Canberra; Black Mountain Tower transmitters

Re: Continuing service after modifying file

Post by prl » Sun Apr 09, 2017 17:23

adoxa wrote:... If I do nothing, the gauge remains at the original length. If I restart the service (stopService/playService), the gauge updates, but then the edits are skipped and the last position is saved.
Am I right in thinking that you're using file.truncate()? Chopping off the file at the point where it's being played is probably going to be tricky to do. Stopping the service is probably the right thing to do, but you should probably leave it stopped. I'm not sure I quite understand what happens after you restart it.
adoxa wrote:If I get the cuesheet again (self.session.nav.getCurrentService().cueSheet()), then playback doesn't work at all. Is this doable or should I just "and exit"?
I'd have thought that fetching the cue sheet reference again wouldn't change anything unless the new fetch returned None. You can compare the actual memory addresses of the C++ cue sheet objects with:

Code: Select all

oldCueSheet = self.cueSheet # or wherever it is
self.cueSheet = self.session.nav.getCurrentService().cueSheet()
print "Cue sheets old, new:", oldCueSheet.getPtrString(), self.cueSheet.getPtrString()  # It returns an integer, not a string. See lib/base/smartptr.h
You get the contents of the cue sheet with self.cueSheet.getCutList().
Peter
T4 HDMI
U4, T4, T3, T2, V2 test/development machines
Sony BDV-9200W HT system
LG OLED55C9PTA 55" OLED TV

User avatar
adoxa
Wizard
Posts: 1490
Joined: Thu Feb 23, 2017 22:58
Location: CQ
Contact:

Re: Continuing service after modifying file

Post by adoxa » Mon Apr 10, 2017 00:44

prl wrote:Am I right in thinking that you're using file.truncate()? Chopping off the file at the point where it's being played is probably going to be tricky to do.
I adapted mcut, so ftruncate, but the principle's the same. Surprisingly, truncation was successful whilst playing, but nothing recognised the new length (but I didn't expect it to).
prl wrote:Stopping the service is probably the right thing to do, but you should probably leave it stopped. I'm not sure I quite understand what happens after you restart it.
I stop it, then execute a program with eConsoleAppContainer, using its callback to restart it. That works fine, apart from not being able to disable the cuts again (setCutListEnable), so the cuts are skipped and the last position is saved.
prl wrote:I'd have thought that fetching the cue sheet reference again wouldn't change anything unless the new fetch returned None. You can compare the actual memory addresses of the C++ cue sheet objects...
The pointers are different. The log has "[eDVBVideo0] VIDEO_PLAY failed: Operation not permitted". It still starts at the initial in cut and pauses, and I can still toggle a mark and remove before/after, but none of the play/skip functions work.

User avatar
adoxa
Wizard
Posts: 1490
Joined: Thu Feb 23, 2017 22:58
Location: CQ
Contact:

Re: Continuing service after modifying file

Post by adoxa » Tue Apr 11, 2017 20:33

It's not related to the console callback, as it happens when I stop & start from __init__:

Code: Select all

		session.nav.playService(service)
		self.pauseService()
		cur_service = session.nav.getCurrentService()
		self.cue = cur_service and cur_service.cueSheet()
		session.nav.stopService()
		session.nav.playService(service)
		self.pauseService()
		service = session.nav.getCurrentService()
		#self.cue = service and service.cueSheet()
[/size]
That will seek, but remove the comment from the last line and seeking is disabled, even if the first self.cue is commented.

User avatar
adoxa
Wizard
Posts: 1490
Joined: Thu Feb 23, 2017 22:58
Location: CQ
Contact:

Re: Continuing service after modifying file

Post by adoxa » Wed Apr 12, 2017 17:55

Getting the service and cuesheet each time solves the problem, so now I set the cutlist state from a function, rather than storing the cuesheet directly:

Code: Select all

	def setCutListEnable(self):
		service = self.session.nav.getCurrentService()
		cue = service and service.cueSheet()
		if cue is not None:
			cue.setCutListEnable(self.cut_state)
[/size]

Post Reply

Return to “Developers Community”