]> git.sesse.net Git - bmusb/blobdiff - bmusb/fake_capture.h
Fix v4l2proxy when stride != width * 2.
[bmusb] / bmusb / fake_capture.h
index 48dca063ae7d6b18e21e3554478b4aa1532f1000..ea9c3804e2c814e6304091df45c3d66e06cc900f 100644 (file)
@@ -12,7 +12,7 @@ namespace bmusb {
 class FakeCapture : public CaptureInterface
 {
 public:
-       FakeCapture(unsigned width, unsigned height, unsigned fps, unsigned audio_frequency, int card_index);
+       FakeCapture(unsigned width, unsigned height, unsigned fps, unsigned audio_sample_frequency, int card_index, bool has_audio = false);
        ~FakeCapture();
 
        // CaptureInterface.
@@ -65,6 +65,21 @@ public:
        void stop_dequeue_thread() override;
        bool get_disconnected() const override { return false; }
 
+       std::set<PixelFormat> get_available_pixel_formats() const override
+       {
+               return std::set<PixelFormat>{ PixelFormat_8BitYCbCr, PixelFormat_10BitYCbCr };
+       }
+
+       void set_pixel_format(PixelFormat pixel_format) override
+       {
+               current_pixel_format = pixel_format;
+       }
+
+       PixelFormat get_current_pixel_format() const
+       {
+               return current_pixel_format;
+       }
+
        std::map<uint32_t, VideoMode> get_available_video_modes() const override;
        void set_video_mode(uint32_t video_mode_id) override;
        uint32_t get_current_video_mode() const override { return 0; }
@@ -79,10 +94,19 @@ public:
 
 private:
        void producer_thread_func();
+       void make_tone(int32_t *out, unsigned num_stereo_samples, unsigned num_channels);
 
-       unsigned width, height, fps, audio_frequency;
+       unsigned width, height, fps, audio_sample_frequency;
+       PixelFormat current_pixel_format = PixelFormat_8BitYCbCr;
+       int card_index;
        uint8_t y, cb, cr;
 
+       // sin(2 * pi * f / F) and similar for cos. Used for fast sine generation.
+       // Zero when no audio.
+       float audio_sin = 0.0f, audio_cos = 0.0f;
+       float audio_real = 0.0f, audio_imag = 0.0f;  // Current state of the audio phaser.
+       float audio_ref_level;
+
        bool has_dequeue_callbacks = false;
        std::function<void()> dequeue_init_callback = nullptr;
        std::function<void()> dequeue_cleanup_callback = nullptr;