Skip to content
Snippets Groups Projects
Commit 6f9d37f0 authored by Steve Lhomme's avatar Steve Lhomme Committed by Jean-Baptiste Kempf
Browse files

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++.
parent 65dfe0cd
No related branches found
No related tags found
1 merge request!599sout: sdi: replace the thread cleanup calls by a canceled boolean
Pipeline #138126 passed with stage
in 15 minutes and 18 seconds
......@@ -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);
}
}
......
......@@ -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();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment