X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=bmusb.cpp;h=3d2c9f018488e202dff12e9439ebe8be665fa376;hb=5b54cc5acb28f5d2071c99ef7a715044aa30f10c;hp=85b92a6186c2e90debb70b4cc3fa85a0598d5eb7;hpb=30a75fd8110601c89ecc7c1a0832a96878917cd4;p=bmusb diff --git a/bmusb.cpp b/bmusb.cpp index 85b92a6..3d2c9f0 100644 --- a/bmusb.cpp +++ b/bmusb.cpp @@ -80,26 +80,6 @@ void change_xfer_size_for_width(int width, libusb_transfer *xfr) FrameAllocator::~FrameAllocator() {} -// Audio is more important than video, and also much cheaper. -// By having many more audio frames available, hopefully if something -// starts to drop, we'll have CPU load go down (from not having to -// process as much video) before we have to drop audio. -#define NUM_QUEUED_VIDEO_FRAMES 16 -#define NUM_QUEUED_AUDIO_FRAMES 64 - -class MallocFrameAllocator : public FrameAllocator { -public: - MallocFrameAllocator(size_t frame_size, size_t num_queued_frames); - Frame alloc_frame() override; - void release_frame(Frame frame) override; - -private: - size_t frame_size; - - mutex freelist_mutex; - stack> freelist; // All of size . -}; - MallocFrameAllocator::MallocFrameAllocator(size_t frame_size, size_t num_queued_frames) : frame_size(frame_size) { @@ -208,8 +188,14 @@ void BMUSBCapture::dequeue_thread_func() pending_audio_frames.pop_front(); lock.unlock(); audio_format.id = audio_frame.format; + + // Use the video format of the pending frame. + QueuedFrame video_frame = pending_video_frames.front(); + VideoFormat video_format; + decode_video_format(video_frame.format, &video_format); + frame_callback(audio_timecode, - FrameAllocator::Frame(), 0, VideoFormat(), + FrameAllocator::Frame(), 0, video_format, audio_frame.frame, AUDIO_HEADER_SIZE, audio_format); } else { QueuedFrame video_frame = pending_video_frames.front(); @@ -1244,3 +1230,22 @@ bool decode_video_format(uint16_t video_format, VideoFormat *decoded_video_forma decoded_video_format->frame_rate_den = 1; return false; } + +map BMUSBCapture::get_available_video_modes() const +{ + // The USB3 cards autodetect, and seem to have no provision for forcing modes. + VideoMode auto_mode; + auto_mode.name = "Autodetect"; + auto_mode.autodetect = true; + return {{ 0, auto_mode }}; +} + +uint32_t BMUSBCapture::get_current_video_mode() const +{ + return 0; // Matches get_available_video_modes(). +} + +void BMUSBCapture::set_video_mode(uint32_t video_mode_id) +{ + assert(video_mode_id == 0); // Matches get_available_video_modes(). +}