[vlc-commits] [Git][videolan/vlc][master] sout: sdi: replace the thread cleanup calls by a canceled boolean
Jean-Baptiste Kempf (@jbk)
gitlab at videolan.org
Wed Sep 15 07:36:55 UTC 2021
Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC
Commits:
6f9d37f0 by Steve Lhomme at 2021-09-15T07:10:53+00:00
sout: sdi: replace the thread cleanup calls by a canceled boolean
mutex_cleanup_push() and vlc_cleanup_pop() are not available in C++.
All we want is to tell the feeder thread to exit when it's idle.
The condition will be triggered when:
* a frame has completed
* the maxdelay to wait before scheduling a new frame has been reached
* the local thread cancel has been requested
We no longer use the cancellation API which is not available in C++.
- - - - -
2 changed files:
- modules/stream_out/sdi/DBMSDIOutput.cpp
- modules/stream_out/sdi/DBMSDIOutput.hpp
Changes:
=====================================
modules/stream_out/sdi/DBMSDIOutput.cpp
=====================================
@@ -69,6 +69,7 @@ DBMSDIOutput::DBMSDIOutput(sout_stream_t *p_stream) :
streamStartTime = VLC_TICK_INVALID;
vlc_mutex_init(&feeder.lock);
vlc_cond_init(&feeder.cond);
+ feeder.canceled = false;
}
DBMSDIOutput::~DBMSDIOutput()
@@ -77,7 +78,12 @@ DBMSDIOutput::~DBMSDIOutput()
{
while(!isDrained())
vlc_tick_wait(vlc_tick_now() + CLOCK_FREQ/60);
- vlc_cancel(feeder.thread);
+
+ vlc_mutex_lock(&feeder.lock);
+ feeder.canceled = true;
+ vlc_cond_signal(&feeder.cond);
+ vlc_mutex_unlock(&feeder.lock);
+
vlc_join(feeder.thread, NULL);
}
@@ -560,14 +566,12 @@ void DBMSDIOutput::feederThread()
for(;;)
{
vlc_mutex_lock(&feeder.lock);
- mutex_cleanup_push(&feeder.lock);
vlc_cond_timedwait(&feeder.cond, &feeder.lock, vlc_tick_now() + maxdelay);
- vlc_cleanup_pop();
- int cancel = vlc_savecancel();
+ if (feeder.canceled)
+ break;
doSchedule();
if(timescale)
maxdelay = CLOCK_FREQ * frameduration / timescale;
- vlc_restorecancel(cancel);
vlc_mutex_unlock(&feeder.lock);
}
}
=====================================
modules/stream_out/sdi/DBMSDIOutput.hpp
=====================================
@@ -72,6 +72,7 @@ namespace sdi_sout
vlc_mutex_t lock; /* Driver calls callback... until buffer is empty :/ */
vlc_cond_t cond;
vlc_thread_t thread;
+ bool canceled;
} feeder;
static void *feederThreadCallback(void *);
void feederThread();
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/6f9d37f069fa16fd99f157f89a4e00e320a2aa59
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/6f9d37f069fa16fd99f157f89a4e00e320a2aa59
You're receiving this email because of your account on code.videolan.org.
More information about the vlc-commits
mailing list