mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
Use wpi::mutex instead of std::mutex. (#105)
This uses a priority-aware mutex on Linux platforms.
This commit is contained in:
@@ -33,7 +33,7 @@ Frame::Frame(SourceImpl& source, std::unique_ptr<Image> image, Time time)
|
||||
|
||||
Image* Frame::GetNearestImage(int width, int height) const {
|
||||
if (!m_impl) return nullptr;
|
||||
std::lock_guard<std::recursive_mutex> lock(m_impl->mutex);
|
||||
std::lock_guard<wpi::recursive_mutex> lock(m_impl->mutex);
|
||||
Image* found = nullptr;
|
||||
|
||||
// Ideally we want the smallest image at least width/height in size
|
||||
@@ -56,7 +56,7 @@ Image* Frame::GetNearestImage(int width, int height) const {
|
||||
Image* Frame::GetNearestImage(int width, int height,
|
||||
VideoMode::PixelFormat pixelFormat) const {
|
||||
if (!m_impl) return nullptr;
|
||||
std::lock_guard<std::recursive_mutex> lock(m_impl->mutex);
|
||||
std::lock_guard<wpi::recursive_mutex> lock(m_impl->mutex);
|
||||
Image* found = nullptr;
|
||||
|
||||
// We want the smallest image at least width/height (or the next largest),
|
||||
@@ -238,7 +238,7 @@ Image* Frame::ConvertMJPEGToBGR(Image* image) {
|
||||
// Save the result
|
||||
Image* rv = newImage.release();
|
||||
if (m_impl) {
|
||||
std::lock_guard<std::recursive_mutex> lock(m_impl->mutex);
|
||||
std::lock_guard<wpi::recursive_mutex> lock(m_impl->mutex);
|
||||
m_impl->images.push_back(rv);
|
||||
}
|
||||
return rv;
|
||||
@@ -259,7 +259,7 @@ Image* Frame::ConvertMJPEGToGray(Image* image) {
|
||||
// Save the result
|
||||
Image* rv = newImage.release();
|
||||
if (m_impl) {
|
||||
std::lock_guard<std::recursive_mutex> lock(m_impl->mutex);
|
||||
std::lock_guard<wpi::recursive_mutex> lock(m_impl->mutex);
|
||||
m_impl->images.push_back(rv);
|
||||
}
|
||||
return rv;
|
||||
@@ -279,7 +279,7 @@ Image* Frame::ConvertYUYVToBGR(Image* image) {
|
||||
// Save the result
|
||||
Image* rv = newImage.release();
|
||||
if (m_impl) {
|
||||
std::lock_guard<std::recursive_mutex> lock(m_impl->mutex);
|
||||
std::lock_guard<wpi::recursive_mutex> lock(m_impl->mutex);
|
||||
m_impl->images.push_back(rv);
|
||||
}
|
||||
return rv;
|
||||
@@ -299,7 +299,7 @@ Image* Frame::ConvertBGRToRGB565(Image* image) {
|
||||
// Save the result
|
||||
Image* rv = newImage.release();
|
||||
if (m_impl) {
|
||||
std::lock_guard<std::recursive_mutex> lock(m_impl->mutex);
|
||||
std::lock_guard<wpi::recursive_mutex> lock(m_impl->mutex);
|
||||
m_impl->images.push_back(rv);
|
||||
}
|
||||
return rv;
|
||||
@@ -319,7 +319,7 @@ Image* Frame::ConvertRGB565ToBGR(Image* image) {
|
||||
// Save the result
|
||||
Image* rv = newImage.release();
|
||||
if (m_impl) {
|
||||
std::lock_guard<std::recursive_mutex> lock(m_impl->mutex);
|
||||
std::lock_guard<wpi::recursive_mutex> lock(m_impl->mutex);
|
||||
m_impl->images.push_back(rv);
|
||||
}
|
||||
return rv;
|
||||
@@ -339,7 +339,7 @@ Image* Frame::ConvertBGRToGray(Image* image) {
|
||||
// Save the result
|
||||
Image* rv = newImage.release();
|
||||
if (m_impl) {
|
||||
std::lock_guard<std::recursive_mutex> lock(m_impl->mutex);
|
||||
std::lock_guard<wpi::recursive_mutex> lock(m_impl->mutex);
|
||||
m_impl->images.push_back(rv);
|
||||
}
|
||||
return rv;
|
||||
@@ -359,7 +359,7 @@ Image* Frame::ConvertGrayToBGR(Image* image) {
|
||||
// Save the result
|
||||
Image* rv = newImage.release();
|
||||
if (m_impl) {
|
||||
std::lock_guard<std::recursive_mutex> lock(m_impl->mutex);
|
||||
std::lock_guard<wpi::recursive_mutex> lock(m_impl->mutex);
|
||||
m_impl->images.push_back(rv);
|
||||
}
|
||||
return rv;
|
||||
@@ -368,7 +368,7 @@ Image* Frame::ConvertGrayToBGR(Image* image) {
|
||||
Image* Frame::ConvertBGRToMJPEG(Image* image, int quality) {
|
||||
if (!image || image->pixelFormat != VideoMode::kBGR) return nullptr;
|
||||
if (!m_impl) return nullptr;
|
||||
std::lock_guard<std::recursive_mutex> lock(m_impl->mutex);
|
||||
std::lock_guard<wpi::recursive_mutex> lock(m_impl->mutex);
|
||||
|
||||
// Allocate a JPEG image. We don't actually know what the resulting size
|
||||
// will be; while the destination will automatically grow, doing so will
|
||||
@@ -399,7 +399,7 @@ Image* Frame::ConvertBGRToMJPEG(Image* image, int quality) {
|
||||
Image* Frame::ConvertGrayToMJPEG(Image* image, int quality) {
|
||||
if (!image || image->pixelFormat != VideoMode::kGray) return nullptr;
|
||||
if (!m_impl) return nullptr;
|
||||
std::lock_guard<std::recursive_mutex> lock(m_impl->mutex);
|
||||
std::lock_guard<wpi::recursive_mutex> lock(m_impl->mutex);
|
||||
|
||||
// Allocate a JPEG image. We don't actually know what the resulting size
|
||||
// will be; while the destination will automatically grow, doing so will
|
||||
@@ -430,7 +430,7 @@ Image* Frame::ConvertGrayToMJPEG(Image* image, int quality) {
|
||||
Image* Frame::GetImage(int width, int height,
|
||||
VideoMode::PixelFormat pixelFormat, int jpegQuality) {
|
||||
if (!m_impl) return nullptr;
|
||||
std::lock_guard<std::recursive_mutex> lock(m_impl->mutex);
|
||||
std::lock_guard<wpi::recursive_mutex> lock(m_impl->mutex);
|
||||
Image* cur = GetNearestImage(width, height, pixelFormat);
|
||||
if (!cur || cur->Is(width, height, pixelFormat)) return cur;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user