This commit splits out synchronization primitives from LibThreading into LibSync. This is because LibThreading depends on LibCore, while LibCore needs the synchronization primitives from LibThreading. This worked while they were header only, but when I tried to add an implementation file it ran into the circular dependency. To abstract away the pthread implementation using cpp files is necessary so the synchronization primitives were moved to a separate library.
35 lines
727 B
C++
35 lines
727 B
C++
/*
|
|
* Copyright (c) 2026, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AK/AtomicRefCounted.h>
|
|
#include <AK/RefPtr.h>
|
|
#include <LibMedia/Forward.h>
|
|
#include <LibSync/Mutex.h>
|
|
|
|
namespace Web::Painting {
|
|
|
|
class VideoFrameSource final : public AtomicRefCounted<VideoFrameSource> {
|
|
public:
|
|
static NonnullRefPtr<VideoFrameSource> create();
|
|
~VideoFrameSource();
|
|
|
|
u64 id() const { return m_id; }
|
|
|
|
void update(RefPtr<Media::VideoFrame>);
|
|
void clear();
|
|
RefPtr<Media::VideoFrame> current_frame() const;
|
|
|
|
private:
|
|
VideoFrameSource();
|
|
|
|
u64 m_id { 0 };
|
|
mutable Sync::Mutex m_mutex;
|
|
RefPtr<Media::VideoFrame> m_frame;
|
|
};
|
|
|
|
}
|