Skip to content

June 2025 Build

Choose a tag to compare

@ffbsoffa ffbsoffa released this 06 Jun 16:48
· 66 commits to stable since this release
a16cc9a

June 2025 Build Change Log

🎥 Decoder Stability at High Speeds

  • Fixed VideoToolbox "invalid state" errors when playback speed exceeds 2x
  • Resolved hardware decoder crashes during rapid speed changes
  • Implemented automatic retry mechanism for hardware decoder failures (5-second retry interval)
  • Made error handling less aggressive - only specific critical errors permanently disable HW acceleration
  • Applied similar fixes to low-resolution decoder for consistency

🔧 Architecture Refactoring

  • Created independent WindowManager class to separate SDL/display logic from main application loop
  • Moved frame selection logic from main loop to WindowManager.selectFrame() method (~150 lines cleanup)
  • Created DeepPauseManager class to handle deep pause logic and state management
  • Created KeyboardManager class to encapsulate all keyboard event handling and menu commands (~200 lines moved from main.cpp)
  • Centralized decoder parameter calculation in WindowManager.calculateDecoderParams()
  • Simplified main loop structure by encapsulating window management, rendering, and event handling
  • Improved code organization and maintainability with dedicated manager classes

⚡ Improved Event Processing

  • Implemented callback-based event handling with WindowManager.processEvents() method
  • Centralized keyboard handling in KeyboardManager class with organized event processing
  • Added mouse shuttle control with Shift+LeftClick for professional-style speed control
  • Added frame timing optimization with adaptive delay for better responsiveness
  • Improved deep pause behavior with reduced CPU usage and better wake-up responsiveness
  • Enhanced event processing strategy with adaptive CPU usage based on activity
  • Note: macOS menu blocking is a known SDL limitation that requires deeper architectural changes to fully resolve

🛠️ Code Quality Improvements

  • Removed spam logging - cleaned up verbose console output:
    • "Previous decode still running" messages
    • "Speed > 1.1x. Cancelling async decode" messages
  • Consolidated includes - moved 40+ include statements to includes.h for cleaner main.cpp
  • Consolidated globals - moved 80+ global variables and declarations to globals.h/cpp
  • Enhanced thread safety with proper atomic operations
  • Added better error recovery mechanisms
  • Improved resource cleanup and memory management

New Features

🖱️ Mouse Shuttle Control

  • Professional-style shuttle control with mouse for intuitive speed control
  • Activation: Hold Shift + Left Click and drag mouse horizontally
  • Speed control: Every 10 pixels of movement = 1x speed change (up to 24x max)
  • Direction control:
    • Drag left from start position → reverse playback
    • Drag right from start position → forward playback
  • Smooth inertia: Respects existing playback rate for natural transitions
  • Direction changes: Automatically slows to 0x before reversing direction
  • Release behavior: Returns to 1x normal speed when mouse button is released

Technical Details

Decoder Changes

  • Modified requestStop() methods to avoid buffer flushing during active decoding
  • Added is_decoding_ flag to track decode state safely
  • Implemented asynchronous decoding with std::async and std::future
  • Added cancelOngoingDecode() for quick interruption capability

WindowManager Architecture

  • Encapsulated SDL initialization, window creation, and rendering
  • Added frame timing helpers: setTargetFPS(), beginFrameTiming(), endFrameTiming()
  • Implemented processEvents() with callback-based event handling
  • Moved frame selection logic to selectFrame() method with smart caching and transitions
  • Added decoder parameter calculation with calculateDecoderParams() for FPS-based optimization
  • Streamlined event processing with improved responsiveness

KeyboardManager Architecture

  • Centralized all keyboard and mouse event handling
  • Mouse shuttle implementation with handleMouseEvent(), startMouseShuttle(), updateMouseShuttle()
  • Inertia-based direction changes: Prevents jarring transitions when reversing direction
  • Global state management with mouse_shuttle_active and mouse_shuttle_start_x variables
  • Integrated with existing speed control system for consistent behavior

macOS Compatibility

  • Stable event processing using standard SDL_PollEvent approach
  • Adaptive event polling that reduces CPU usage during idle periods
  • Known limitation: Brief video pause during system menu interactions (inherent SDL behavior)

Files Modified

  • source_alt/core/decode/full_res_decoder.cpp - Core decoder stability fixes
  • source_alt/core/decode/full_res_decoder_manager.cpp - Async decoding implementation
  • source_alt/core/decode/low_res_decoder.cpp - Low-res decoder fixes
  • source_alt/core/display/window_manager.h - New WindowManager class interface
  • source_alt/core/display/window_manager.cpp - WindowManager implementation
  • source_alt/main/keyboard_manager.h - New KeyboardManager class interface
  • source_alt/main/keyboard_manager.cpp - KeyboardManager implementation with mouse shuttle control
  • source_alt/main/deep_pause_manager.h - New DeepPauseManager class interface
  • source_alt/main/deep_pause_manager.cpp - DeepPauseManager implementation
  • source_alt/main/includes.h - Consolidated include statements
  • source_alt/main/globals.h - Consolidated global variable declarations
  • source_alt/main/globals.cpp - Global variable definitions
  • source_alt/main/main.cpp - Refactored to use manager classes, significantly simplified main loop
  • source_alt/core/menu/menu_system.mm - Updated to use KeyboardManager for menu commands

Performance Impact

  • Reduced CPU usage during pause states with deep pause optimization
  • Better responsiveness during high-speed playback (>2x)
  • Smoother playback with improved frame timing
  • Intuitive speed control with mouse shuttle for faster workflow
  • Non-blocking UI during system menu interactions on macOS

Compatibility

  • All changes maintain backward compatibility
  • No configuration changes required
  • Works with existing video formats and hardware acceleration
  • macOS-specific improvements for menu interaction