]> git.sesse.net Git - nageru/commitdiff
Refactor card setup into its own function.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Sat, 27 Feb 2016 11:52:08 +0000 (12:52 +0100)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Sat, 27 Feb 2016 11:52:08 +0000 (12:52 +0100)
mixer.cpp
mixer.h

index 9c5c853ded7961896adbaced16eff6886d6e5a6d..5f023cfd691eba9e0723e6f92c5ca4e6adb82519 100644 (file)
--- a/mixer.cpp
+++ b/mixer.cpp
@@ -136,27 +136,7 @@ Mixer::Mixer(const QSurfaceFormat &format, unsigned num_cards)
        h264_encoder.reset(new H264Encoder(h264_encoder_surface, global_flags.va_display, WIDTH, HEIGHT, &httpd));
 
        for (unsigned card_index = 0; card_index < num_cards; ++card_index) {
-               printf("Configuring card %d...\n", card_index);
-               CaptureCard *card = &cards[card_index];
-               card->capture = new BMUSBCapture(card_index);
-               card->capture->set_frame_callback(bind(&Mixer::bm_frame, this, card_index, _1, _2, _3, _4, _5, _6, _7));
-               card->frame_allocator.reset(new PBOFrameAllocator(8 << 20, WIDTH, HEIGHT));  // 8 MB.
-               card->capture->set_video_frame_allocator(card->frame_allocator.get());
-               card->surface = create_surface(format);
-               card->capture->set_dequeue_thread_callbacks(
-                       [card]{
-                               eglBindAPI(EGL_OPENGL_API);
-                               card->context = create_context(card->surface);
-                               if (!make_current(card->context, card->surface)) {
-                                       printf("failed to create bmusb context\n");
-                                       exit(1);
-                               }
-                       },
-                       [this]{
-                               resource_pool->clean_context();
-                       });
-               card->resampling_queue.reset(new ResamplingQueue(OUTPUT_FREQUENCY, OUTPUT_FREQUENCY, 2));
-               card->capture->configure_card();
+               configure_card(card_index, format, new BMUSBCapture(card_index));
        }
 
        BMUSBCapture::start_bm_thread();
@@ -238,6 +218,33 @@ Mixer::~Mixer()
        h264_encoder.reset(nullptr);
 }
 
+void Mixer::configure_card(unsigned card_index, const QSurfaceFormat &format, CaptureInterface *capture)
+{
+       printf("Configuring card %d...\n", card_index);
+
+       CaptureCard *card = &cards[card_index];
+       card->capture = capture;
+       card->capture->set_frame_callback(bind(&Mixer::bm_frame, this, card_index, _1, _2, _3, _4, _5, _6, _7));
+       card->frame_allocator.reset(new PBOFrameAllocator(8 << 20, WIDTH, HEIGHT));  // 8 MB.
+       card->capture->set_video_frame_allocator(card->frame_allocator.get());
+       card->surface = create_surface(format);
+       card->capture->set_dequeue_thread_callbacks(
+               [card]{
+                       eglBindAPI(EGL_OPENGL_API);
+                       card->context = create_context(card->surface);
+                       if (!make_current(card->context, card->surface)) {
+                               printf("failed to create bmusb context\n");
+                               exit(1);
+                       }
+               },
+               [this]{
+                       resource_pool->clean_context();
+               });
+       card->resampling_queue.reset(new ResamplingQueue(OUTPUT_FREQUENCY, OUTPUT_FREQUENCY, 2));
+       card->capture->configure_card();
+}
+
+
 namespace {
 
 int unwrap_timecode(uint16_t current_wrapped, int last)
diff --git a/mixer.h b/mixer.h
index d59b6a3221a2d0e45221301fa8c85b40c6a35e99..8f37f3840db6ff60ec06c16385424972a7e3889e 100644 (file)
--- a/mixer.h
+++ b/mixer.h
@@ -242,6 +242,7 @@ public:
        }
 
 private:
+       void configure_card(unsigned card_index, const QSurfaceFormat &format, CaptureInterface *capture);
        void bm_frame(unsigned card_index, uint16_t timecode,
                FrameAllocator::Frame video_frame, size_t video_offset, VideoFormat video_format,
                FrameAllocator::Frame audio_frame, size_t audio_offset, uint16_t audio_format);