--- /sambashare/tasteplugin patch/new cvs checkout/vdr-plugin-taste-0.0.2d+cvs20080102.1814/status.c	2007-05-08 12:16:23.000000000 +0200
+++ ./status.c	2010-01-13 16:23:58.000000000 +0100
@@ -17,22 +17,50 @@
 void cStatusTaste::ChannelSwitch(const cDevice *Device, int ChannelNumber)
 {
   printf("cStatusTaste::ChannelSwitch(%p, %d)\n", Device, ChannelNumber);
+  dsyslog("plugin-taste: cStatusTaste was informed about channel switch at device %d, channel no %d",Device->DeviceNumber(),ChannelNumber);
+  dsyslog("plugin-taste: cDevice::CurrentChannel %d",cDevice::CurrentChannel());
+  dsyslog("plugin-taste: Device %d, ActualDevice %d, primary Device %d",Device->DeviceNumber(),cDevice::ActualDevice()->DeviceNumber(),cDevice::PrimaryDevice()->DeviceNumber());
+  for (int ii=0;ii<cDevice::NumDevices();ii++)
+  {
+    cDevice* tmpdev=cDevice::GetDevice(ii);
+    dsyslog("plugin-taste: cDevice %d replaying: %d, transferring %d",ii,tmpdev->Replaying(),tmpdev->Transferring());
+  }
 
-	if ((Device == cDevice::ActualDevice()) && !Device->Replaying()) {
-		if (mLastChannel == 0) { // Since starting VDR we didn't zap yet
-			if (ChannelNumber != 0 && ChannelNumber == cDevice::CurrentChannel()) // Channelswitch has been done
-				mLastChannel = ChannelNumber;
-			return;
-		}
+  if (Device->DeviceNumber()!=cDevice::PrimaryDevice()->DeviceNumber())
+  {
+    dsyslog("plugin-taste: just returned from StatusTaste cause ChannelSwitch not on actual livedevice");
+    return;
+  }
 
-		if (ChannelNumber == 0) { // Switch ist geplant
-			mLastChannel = cDevice::CurrentChannel();
-			return;
-		}
+  if (mLastChannel==0)
+  {
+    dsyslog("plugin-taste: just returned from StatuTaste cause mLastChannel=0 (set to %d)",cDevice::CurrentChannel());
+    mLastChannel=cDevice::CurrentChannel();
+    return;
+  }
+  
+  if (ChannelNumber==0) 
+  {
+    mLastChannel=cDevice::CurrentChannel(); 
+    dsyslog("plugin-taste: just returned from StatusTaste because ChannelNumber=0 (some switch is in progress)"); 
+    return; //seems that switching is in progress
+  }
+  
+  if (ChannelNumber!=cDevice::CurrentChannel())
+  {
+    dsyslog("plugin-taste: just returned from StatusTaste because ChannelNumber!=CurrentChannel (switch still in progress)");
+    return;
+  }
+  
+  if (Device->Replaying()) 
+  {
+    dsyslog("plugin-taste: Just returned from StatusTaste because Device is Replaying");
+    return; 
+  }
 
-		const cChannel *channel = Channels.GetByNumber(ChannelNumber);
-		if (channel != NULL && !channel->GroupSep()) {
-			cSchedulesLock schedLock;
+                        const cChannel *channel = Channels.GetByNumber(ChannelNumber);
+                        if (channel != NULL && !channel->GroupSep()) {
+                	cSchedulesLock schedLock;
 			const cSchedules *scheds = cSchedules::Schedules(schedLock);
 			if (scheds == NULL)
 				return;
@@ -45,12 +73,13 @@
 			const cEvent *follow  = sched->GetFollowingEvent();
 			if (present == NULL)
 				return;
-			
-			if (!cControlTaste::IsRequested() && !EventsTaste.Acceptable(present->Title())) {
+          		if (!cControlTaste::IsRequested() && !EventsTaste.Acceptable(present->Title())) {
 				isyslog("channel %d is not acceptable at present", ChannelNumber);
 				cControl::Launch(new cControlTaste(mLastChannel, channel, present, follow));
+				mLastChannel=0;
 			}
 		}
-	}
+
+
 }
   
