mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-04 14:01:25 +12:00
Work on demuxer, ffmpeg libs linked
This commit is contained in:
parent
8df7f49b55
commit
a14276abf1
7 changed files with 725 additions and 34 deletions
101
Utilities/SQueue.h
Normal file
101
Utilities/SQueue.h
Normal file
|
@ -0,0 +1,101 @@
|
|||
#pragma once
|
||||
|
||||
template<typename T, u32 SQSize = 666>
|
||||
class SQueue
|
||||
{
|
||||
SMutex m_mutex;
|
||||
u32 m_pos;
|
||||
u32 m_count;
|
||||
T m_data[SQSize];
|
||||
|
||||
public:
|
||||
SQueue()
|
||||
: m_pos(0)
|
||||
, m_count(0)
|
||||
{
|
||||
}
|
||||
|
||||
bool Push(T& data)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
if (Emu.IsStopped())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_mutex.GetOwner() == m_mutex.GetDeadValue())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_count >= SQSize)
|
||||
{
|
||||
Sleep(1);
|
||||
continue;
|
||||
}
|
||||
|
||||
{
|
||||
SMutexLocker lock(m_mutex);
|
||||
|
||||
if (m_count >= SQSize) continue;
|
||||
|
||||
m_data[(m_pos + m_count++) % SQSize] = data;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool Pop(T& data)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
if (Emu.IsStopped())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_mutex.GetOwner() == m_mutex.GetDeadValue())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!m_count)
|
||||
{
|
||||
Sleep(1);
|
||||
continue;
|
||||
}
|
||||
|
||||
{
|
||||
SMutexLocker lock(m_mutex);
|
||||
|
||||
if (!m_count) continue;
|
||||
|
||||
data = m_data[m_pos];
|
||||
m_pos = (m_pos + 1) % SQSize;
|
||||
m_count--;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
u32 GetCount()
|
||||
{
|
||||
SMutexLocker lock(m_mutex);
|
||||
return m_count;
|
||||
}
|
||||
|
||||
bool IsEmpty()
|
||||
{
|
||||
SMutexLocker lock(m_mutex);
|
||||
return !m_count;
|
||||
}
|
||||
|
||||
void Clear()
|
||||
{
|
||||
SMutexLocker lock(m_mutex);
|
||||
m_count = 0;
|
||||
}
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue