Commit Graph

255 Commits

Author SHA1 Message Date
Jonathan Thomas
788a3c77a6 Fixing whitespace 2022-10-21 18:15:41 -05:00
Jonathan Thomas
d8f8cba27f Do not sort_clips on every call to GetFrame, as this invalidates the internal clips list, and causes crashes in ClearAllCache() and Clear() methods. 2022-10-21 18:11:32 -05:00
Jonathan Thomas
ca33d951e6 Removing cache clearing from Timeline::Clear method - unneeded 2022-10-15 21:48:55 -05:00
Jonathan Thomas
4ad94c7727 Fixing more whitespace 2022-10-13 10:25:04 -05:00
Jonathan Thomas
9284113867 Fixing more whitespace 2022-10-13 10:21:40 -05:00
Jonathan Thomas
032ff77602 Fixing more whitespace 2022-10-13 10:21:00 -05:00
Jonathan Thomas
4e12ceb51f Fixing more whitespace 2022-10-13 10:20:23 -05:00
Jonathan Thomas
9eb5d6f903 Fixing more whitespace 2022-10-13 10:19:05 -05:00
Jonathan Thomas
31566a192a Protection for ClearAllCache method, to prevent messing with closed clips. Added a multi-threaded unit tests for Timeline::GetFrame access - to verify nothing crashes. 2022-10-13 00:01:03 -05:00
Jonathan Thomas
8fcdbc9d03 Timeline now checks cache 2nd time, after mutex - incase previous call generated the same frame 2022-10-11 23:01:26 -05:00
Jonathan Thomas
5f9c4e06d8 Large performance regression fixed by moving mutex further into the Timeline::GetFrame method - only when generating a new frame (allowing cache to actually work freely). Adding mutex back to FFmpegReader::GetFrame. Removing redundant mutex from ReaderBase.h. Adding mutex to all methods that call shrink_to_fit(). 2022-10-11 18:14:36 -05:00
Jonathan Thomas
245186f2a0 Fixing some small memory related issues - uninitialized variable, RESVG initialization only for svg files, Close QtImageReader on destructor, erase allocated_effects and allocated_clips. 2022-10-10 11:17:53 -05:00
Jonathan Thomas
32a89cfce9 Add lock to new Clear() method to prevent crashes 2022-10-06 21:59:11 -05:00
Jonathan Thomas
934ca786ed Adding new Clear() method to Timeline, to delete all allocated clips, effects, and frame mapeprs (freeing memory). Also, keep track of allocated clips and effects on timeline (when using SetJson to create them), so we can clean them up correctly on Clear() or RemoveClip()/RemoveEffect(). Added new test case for Clear(). 2022-10-06 15:07:31 -05:00
Jonathan Thomas
8c7b463e38 Improvements to the ClearAllCache() function, allowing both shallow and deep clearing. Lots of bug fixes in VideoCacheThread, to correctly pre-roll and cache the correct frames, and a new method of disabling/enabling the cache thread. 2022-09-15 18:33:06 -05:00
Jonathan Thomas
d0a3002808 Fixing transition end frame calculation 2022-08-27 16:59:14 -05:00
Jonathan Thomas
d2c7e856bb Fixing invalid "end frame" calculation for clips (we were accidentally adding +1) to the last frame of every clip, causing a repeat of the clip's last frame.
For example, if a video had only 10 frames (video_length), timeline would calculate the start_frame as 1, and end_frame as 11, which is incorrect. It should use start_frame as 1, end_frame as 10.
2022-06-25 17:39:48 -05:00
Jonathan Thomas
fbd0ecfc83 Merge branch 'develop' into caching-timing-improvements 2022-02-13 10:59:27 -06:00
Jonathan Thomas
d24e39407e Prevent crashes:
- Tweaking GetSmallestFrame to not use an additional mutex.
- Replace 2 mutex on Timeline::GetFrame with 1 mutex.
- Remove mutex from Timeline::ClearAllCache.
- Slow down loop on video cache thread.
- Protect audioThread::Seek() if missing a source.
- Rearrange StopPlayback to always stop the videoCache thread first.
2022-02-12 13:31:21 -06:00
Jonathan Thomas
fd3865a8e6 Detecting default sample rate of default audio device (Windows seems to play audio out of sync on certain audio drivers, if there is a mismatch between OpenShot and the default system audio sample rate). This info will help debug issues. Adding back in a mutex on Timeline::GetFrame causing crashes. 2022-02-11 14:12:25 -06:00
Jonathan Thomas
35d4629df6 Large refactor to caching and playback timing:
- Support different speeds (-1X, 2X, 4X, etc...)
 - Clamp getFrame between 1 and timeline length
 - Support rewind using new timing code
 - Caching in both directions (based on previous speed)
 - Removing mutex from Timeline::GetFrame (cached path)
 - Caching supports actual speed now
 - Bust cache and trigger pre-roll if we encounter too many uncached frames. This will re-sync the video + audio threads.
 - Sleep less in cache loop / Adjusting min frames to 24 (trial and error). Too few and backwards playback suffers. Too many and all playback waits.
2022-02-09 17:29:04 -06:00
Jonathan Thomas
133bae40c3 Adding pre-roll to VideoCacheThread, and making video & audio threads wait for the isReady() method before playing. Also fixed an audio bug where our internal buffer was not being cleared on seek. Removed some unused caching from Clip, and did some minor refactor on FrameMapper/Clip cache clearing. 2022-01-26 17:56:33 -06:00
Jonathan Thomas
a5f35fb42a Refactoring the VideoCacheThread to check every frame before requesting it. Adding a new method: Contains() to our cache objects, to facilitate this. Removing cache clearning experimental code from Timeline (causing playback issues). Refactoring PrivatePlayer playback timing code, to calculate an average # of frame difference between audio and video threads, and slowly adjust back towards zero when needed. 2022-01-14 15:16:04 -06:00
FeRD (Frank Dana)
806052f9c8 Clip, Timeline: Reformat logging calls 2022-01-12 11:02:52 -05:00
FeRD (Frank Dana)
59108504e3 Code changes for compatibility with JUCE 6.x
- Replace all juce::CriticalSection with std::recursive_mutex
- Replace all juce::AudioSampleBuffer with juce::AudioBuffer<float>
- Eliminate implicit reliance on 'using namespace juce;'
- Replace OpenShotAudio.h includes with targeted juce modules
2021-11-09 06:22:25 -05:00