#include <movit/image_format.h>
#include <movit/init.h>
#include <movit/resource_pool.h>
+#include <pthread.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
alsa.reset(new ALSAOutput(OUTPUT_FREQUENCY, /*num_channels=*/2));
}
if (global_flags.output_card != -1) {
- set_output_card(global_flags.output_card);
+ set_output_card_internal(global_flags.output_card);
}
}
audio_mixer.trigger_state_changed_callback();
}
-void Mixer::set_output_card(int card_index)
+void Mixer::set_output_card_internal(int card_index)
{
- if (card_index == output_card_index) {
- return;
- }
+ // We don't really need to take card_mutex, since we're in the mixer
+ // thread and don't mess with any queues (which is the only thing that happens
+ // from other threads), but it's probably the safest in the long run.
unique_lock<mutex> lock(card_mutex);
if (output_card_index != -1) {
// Switch the old card from output to input.
if (card_index != -1) {
CaptureCard *card = &cards[card_index];
bmusb::CaptureInterface *capture = card->capture.get();
+ // TODO: DeckLinkCapture::stop_dequeue_thread can actually take
+ // several seconds to complete (blocking on DisableVideoInput);
+ // see if we can maybe do it asynchronously.
lock.unlock();
capture->stop_dequeue_thread();
lock.lock();
void Mixer::thread_func()
{
+ pthread_setname_np(pthread_self(), "Mixer_OpenGL");
+
eglBindAPI(EGL_OPENGL_API);
QOpenGLContext *context = create_context(mixer_surface);
if (!make_current(context, mixer_surface)) {
int stats_dropped_frames = 0;
while (!should_quit) {
+ if (desired_output_card_index != output_card_index) {
+ set_output_card_internal(desired_output_card_index);
+ }
+
CaptureCard::NewFrame new_frames[MAX_VIDEO_CARDS];
bool has_new_frame[MAX_VIDEO_CARDS] = { false };
void Mixer::audio_thread_func()
{
+ pthread_setname_np(pthread_self(), "Mixer_Audio");
+
while (!should_quit) {
AudioTask task;