- added RxBuffer
- build clean git-svn-id: http://moon:8086/svn/software/trunk/projects/mpsk_rx_gui@112 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
@@ -28,15 +28,14 @@
|
||||
|
||||
//==============================================================================
|
||||
MainComponent::MainComponent ()
|
||||
: m_TextEditor(new TextEditor),
|
||||
: Thread("Receiver"),
|
||||
m_TextEditor(new TextEditor),
|
||||
m_sharedAudioDeviceManager(nullptr),
|
||||
m_AudioDeviceSelectorComponent(new AudioDeviceSelectorComponent (getSharedAudioDeviceManager(), 0, 256, 0, 256, true, true, true, false)),
|
||||
m_pReceiver(new Receiver(this)),
|
||||
m_pTransmitter(new Transmitter()),
|
||||
m_ControlComponent(new ControlComponent(m_pReceiver, m_pTransmitter)), m_log(this),
|
||||
m_pReceiverControl(m_pReceiver)
|
||||
, Thread("Receiver")
|
||||
|
||||
{
|
||||
addAndMakeVisible (tabbedComponent = new TabbedComponent (TabbedButtonBar::TabsAtTop));
|
||||
tabbedComponent->setTabBarDepth (38);
|
||||
@@ -208,8 +207,8 @@ void MainComponent::timerCallback()
|
||||
BEGIN_JUCER_METADATA
|
||||
|
||||
<JUCER_COMPONENT documentType="Component" className="MainComponent" componentName=""
|
||||
parentClasses="public Component, public ChangeListener, public AudioIODeviceCallback, public ReceiverDataListener, public LogHandler, public Timer"
|
||||
constructorParams="" variableInitialisers="m_TextEditor(new TextEditor), m_sharedAudioDeviceManager(nullptr), m_AudioDeviceSelectorComponent(new AudioDeviceSelectorComponent (getSharedAudioDeviceManager(), 0, 256, 0, 256, true, true, true, false)), m_pReceiver(new Receiver(this)), m_pTransmitter(new Transmitter()), m_ControlComponent(new ControlComponent(m_pReceiver, m_pTransmitter)), m_log(this), m_pReceiverControl(m_pReceiver) "
|
||||
parentClasses="public Component, public ChangeListener, public AudioIODeviceCallback, public ReceiverDataListener, public LogHandler, public Timer, public Thread"
|
||||
constructorParams="" variableInitialisers="Thread("Receiver"), m_TextEditor(new TextEditor), m_sharedAudioDeviceManager(nullptr), m_AudioDeviceSelectorComponent(new AudioDeviceSelectorComponent (getSharedAudioDeviceManager(), 0, 256, 0, 256, true, true, true, false)), m_pReceiver(new Receiver(this)), m_pTransmitter(new Transmitter()), m_ControlComponent(new ControlComponent(m_pReceiver, m_pTransmitter)), m_log(this), m_pReceiverControl(m_pReceiver) "
|
||||
snapPixels="8" snapActive="1" snapShown="1" overlayOpacity="0.330"
|
||||
fixedSize="1" initialWidth="1280" initialHeight="1024">
|
||||
<BACKGROUND backgroundColour="ffffffff"/>
|
||||
|
||||
@@ -48,7 +48,7 @@ class MainComponent : public Component,
|
||||
public ReceiverDataListener,
|
||||
public LogHandler,
|
||||
public Timer,
|
||||
public Thread
|
||||
public Thread
|
||||
{
|
||||
public:
|
||||
//==============================================================================
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
* File: RxBuffer.hpp
|
||||
* Author: jens
|
||||
*
|
||||
* Created on 22. Dezember 2014, 15:47
|
||||
*/
|
||||
|
||||
#ifndef RXBUFFER_HPP
|
||||
#define RXBUFFER_HPP
|
||||
|
||||
#include <radio/Vector.hpp>
|
||||
|
||||
using namespace Radio;
|
||||
|
||||
|
||||
template <uint32_t numBuffers>
|
||||
class RxBuffer
|
||||
{
|
||||
public:
|
||||
RxBuffer(uint32_t size=0)
|
||||
: m_pT(nullptr)
|
||||
, m_size(size)
|
||||
{
|
||||
resize(size);
|
||||
}
|
||||
|
||||
~RxBuffer()
|
||||
{
|
||||
}
|
||||
|
||||
void write(RVec const &data, uint32_t len)
|
||||
{
|
||||
if (m_numfill.get() >= numBuffers)
|
||||
return;
|
||||
|
||||
m_buffers[m_w++] = data;
|
||||
|
||||
if (m_w >= numBuffers)
|
||||
m_w = 0;
|
||||
|
||||
m_numfill += 1;
|
||||
|
||||
if (m_pT)
|
||||
m_pT->notify();
|
||||
}
|
||||
|
||||
const RVec& read()
|
||||
{
|
||||
uint32_t index;
|
||||
m_pT = Thread::getCurrentThread();
|
||||
|
||||
while (m_numfill.get() == 0)
|
||||
{
|
||||
m_pT->wait(100);
|
||||
if (m_pT->threadShouldExit())
|
||||
return m_buffers[0];
|
||||
}
|
||||
|
||||
index = m_r++;
|
||||
if (m_r >= numBuffers)
|
||||
m_r = 0;
|
||||
|
||||
m_numfill -= 1;
|
||||
|
||||
return m_buffers[index];
|
||||
}
|
||||
|
||||
void resize(uint32_t size)
|
||||
{
|
||||
for (int i=0; i < numBuffers; i++)
|
||||
{
|
||||
m_buffers[i].resize(size);
|
||||
}
|
||||
|
||||
m_r = 0;
|
||||
m_w = 0;
|
||||
m_size = size;
|
||||
m_numfill = 0;
|
||||
}
|
||||
|
||||
private:
|
||||
Thread *m_pT;
|
||||
Atomic<uint32_t> m_numfill;
|
||||
RVec m_buffers[numBuffers];
|
||||
uint32_t m_size;
|
||||
uint32_t m_r;
|
||||
uint32_t m_w;
|
||||
};
|
||||
|
||||
|
||||
#endif /* RXBUFFER_HPP */
|
||||
|
||||
Reference in New Issue
Block a user