]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
fix hdhomerun tuner release
authorPablo <trujulu@gmail.com>
Sun, 28 Dec 2025 11:43:53 +0000 (12:43 +0100)
committerFlole <Flole998@users.noreply.github.com>
Thu, 1 Jan 2026 16:30:59 +0000 (17:30 +0100)
src/input/mpegts/tvhdhomerun/tvhdhomerun_frontend.c

index 22ebba04eda2a2f48c53053fb03892434cc050e1..c2bd965d7cb3af85252f63148dcb109ae45e8d28 100644 (file)
@@ -213,6 +213,7 @@ tvhdhomerun_frontend_input_thread ( void *aux )
   tvhdebug(LS_TVHDHOMERUN, "setting target to none");
   tvh_mutex_lock(&hfe->hf_hdhomerun_device_mutex);
   hdhomerun_device_set_tuner_target(hfe->hf_hdhomerun_tuner, "none");
+  hdhomerun_device_tuner_lockkey_release(hfe->hf_hdhomerun_tuner);
   tvh_mutex_unlock(&hfe->hf_hdhomerun_device_mutex);
 
   sbuf_free(&sb);
@@ -407,22 +408,28 @@ static int tvhdhomerun_frontend_tune(tvhdhomerun_frontend_t *hfe, mpegts_mux_ins
   tvhinfo(LS_TVHDHOMERUN, "tuning to %s", channel_buf);
 
   tvh_mutex_lock(&hfe->hf_hdhomerun_device_mutex);
+  
   res = hdhomerun_device_tuner_lockkey_request(hfe->hf_hdhomerun_tuner, &perror);
   if(res < 1) {
     tvh_mutex_unlock(&hfe->hf_hdhomerun_device_mutex);
     tvherror(LS_TVHDHOMERUN, "failed to acquire lockkey: %s", perror);
     return SM_CODE_TUNING_FAILED;
   }
+  
   if (hfe->hf_type == DVB_TYPE_CABLECARD)
     res = hdhomerun_device_set_tuner_vchannel(hfe->hf_hdhomerun_tuner, channel_buf);
   else
     res = hdhomerun_device_set_tuner_channel(hfe->hf_hdhomerun_tuner, channel_buf);
-  tvh_mutex_unlock(&hfe->hf_hdhomerun_device_mutex);
+
   if(res < 1) {
+    hdhomerun_device_tuner_lockkey_release(hfe->hf_hdhomerun_tuner);
+    tvh_mutex_unlock(&hfe->hf_hdhomerun_device_mutex);
     tvherror(LS_TVHDHOMERUN, "failed to tune to %s", channel_buf);
     return SM_CODE_TUNING_FAILED;
   }
 
+  tvh_mutex_unlock(&hfe->hf_hdhomerun_device_mutex);
+  
   hfe->hf_status = SIGNAL_NONE;
 
   /* start the monitoring */
@@ -479,7 +486,10 @@ tvhdhomerun_frontend_stop_mux
     tvhtrace(LS_TVHDHOMERUN, "%s - input thread stopped", buf1);
   }
 
+  tvh_mutex_lock(&hfe->hf_hdhomerun_device_mutex);
+  hdhomerun_device_set_tuner_target(hfe->hf_hdhomerun_tuner, "none");
   hdhomerun_device_tuner_lockkey_release(hfe->hf_hdhomerun_tuner);
+  tvh_mutex_unlock(&hfe->hf_hdhomerun_device_mutex);
 
   hfe->hf_locked = 0;
   hfe->hf_status = 0;