mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2025-09-06 07:07:48 -04:00
new thread queue testing
This commit is contained in:
parent
99aa87df63
commit
35830afed0
@ -145,6 +145,7 @@ include_directories ( ${PROJECT_SOURCE_DIR}/src/sdr
|
|||||||
|
|
||||||
ADD_DEFINITIONS(
|
ADD_DEFINITIONS(
|
||||||
-std=c++0x # or -std=c++11
|
-std=c++0x # or -std=c++11
|
||||||
|
-pthread
|
||||||
)
|
)
|
||||||
|
|
||||||
#configure_files(${PROJECT_SOURCE_DIR}/shaders ${PROJECT_BINARY_DIR}/shaders COPYONLY)
|
#configure_files(${PROJECT_SOURCE_DIR}/shaders ${PROJECT_BINARY_DIR}/shaders COPYONLY)
|
||||||
|
@ -16,6 +16,8 @@
|
|||||||
#include "AudioThread.h"
|
#include "AudioThread.h"
|
||||||
#include "CubicSDR.h"
|
#include "CubicSDR.h"
|
||||||
|
|
||||||
|
#include <thread>
|
||||||
|
|
||||||
wxBEGIN_EVENT_TABLE(AppFrame, wxFrame)
|
wxBEGIN_EVENT_TABLE(AppFrame, wxFrame)
|
||||||
//EVT_MENU(wxID_NEW, AppFrame::OnNewWindow)
|
//EVT_MENU(wxID_NEW, AppFrame::OnNewWindow)
|
||||||
EVT_MENU(wxID_CLOSE, AppFrame::OnClose)
|
EVT_MENU(wxID_CLOSE, AppFrame::OnClose)
|
||||||
@ -26,6 +28,11 @@ wxEND_EVENT_TABLE()
|
|||||||
AppFrame::AppFrame() :
|
AppFrame::AppFrame() :
|
||||||
wxFrame(NULL, wxID_ANY, wxT("CubicSDR")), frequency(DEFAULT_FREQ) {
|
wxFrame(NULL, wxID_ANY, wxT("CubicSDR")), frequency(DEFAULT_FREQ) {
|
||||||
|
|
||||||
|
audioThreadQueue = new ThreadQueue<std::string>;
|
||||||
|
audioThread = new AudioThreadNew(audioThreadQueue);
|
||||||
|
|
||||||
|
t1 = new std::thread(&AudioThreadNew::threadMain, audioThread);
|
||||||
|
|
||||||
wxBoxSizer *vbox = new wxBoxSizer(wxVERTICAL);
|
wxBoxSizer *vbox = new wxBoxSizer(wxVERTICAL);
|
||||||
|
|
||||||
scopeCanvas = new ScopeCanvas(this, NULL);
|
scopeCanvas = new ScopeCanvas(this, NULL);
|
||||||
@ -119,6 +126,7 @@ void AppFrame::OnThread(wxCommandEvent& event) {
|
|||||||
|
|
||||||
std::vector<signed char> *new_uc_buffer;
|
std::vector<signed char> *new_uc_buffer;
|
||||||
std::vector<float> *new_float_buffer;
|
std::vector<float> *new_float_buffer;
|
||||||
|
std::string asdf("beep");
|
||||||
|
|
||||||
switch (event.GetId()) {
|
switch (event.GetId()) {
|
||||||
|
|
||||||
@ -133,7 +141,7 @@ void AppFrame::OnThread(wxCommandEvent& event) {
|
|||||||
std::cout << "Incoming IQ data empty?" << std::endl;
|
std::cout << "Incoming IQ data empty?" << std::endl;
|
||||||
}
|
}
|
||||||
delete iqData;
|
delete iqData;
|
||||||
|
// audioThreadQueue->push(asdf);
|
||||||
break; // thread wants to exit: disable controls and destroy main window
|
break; // thread wants to exit: disable controls and destroy main window
|
||||||
|
|
||||||
// Demodulator -> Audio
|
// Demodulator -> Audio
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
#include "ScopeCanvas.h"
|
#include "ScopeCanvas.h"
|
||||||
#include "SpectrumCanvas.h"
|
#include "SpectrumCanvas.h"
|
||||||
#include "WaterfallCanvas.h"
|
#include "WaterfallCanvas.h"
|
||||||
|
#include "ThreadQueue.h"
|
||||||
|
|
||||||
// Define a new frame type
|
// Define a new frame type
|
||||||
class AppFrame: public wxFrame {
|
class AppFrame: public wxFrame {
|
||||||
@ -43,6 +43,9 @@ private:
|
|||||||
|
|
||||||
DemodulatorInstance *demodulatorTest;
|
DemodulatorInstance *demodulatorTest;
|
||||||
|
|
||||||
|
ThreadQueue<std::string> *audioThreadQueue;
|
||||||
|
AudioThreadNew *audioThread;
|
||||||
|
std::thread *t1;
|
||||||
// event table
|
// event table
|
||||||
wxDECLARE_EVENT_TABLE();
|
wxDECLARE_EVENT_TABLE();
|
||||||
};
|
};
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include <queue>
|
#include <queue>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <string>
|
||||||
#include "wx/wxprec.h"
|
#include "wx/wxprec.h"
|
||||||
|
|
||||||
#ifndef WX_PRECOMP
|
#ifndef WX_PRECOMP
|
||||||
@ -11,9 +12,9 @@
|
|||||||
#include "wx/thread.h"
|
#include "wx/thread.h"
|
||||||
|
|
||||||
#include "AudioThreadQueue.h"
|
#include "AudioThreadQueue.h"
|
||||||
|
#include "ThreadQueue.h"
|
||||||
#include "portaudio.h"
|
#include "portaudio.h"
|
||||||
|
|
||||||
|
|
||||||
static int audioCallback(const void *inputBuffer, void *outputBuffer, unsigned long framesPerBuffer, const PaStreamCallbackTimeInfo* timeInfo,
|
static int audioCallback(const void *inputBuffer, void *outputBuffer, unsigned long framesPerBuffer, const PaStreamCallbackTimeInfo* timeInfo,
|
||||||
PaStreamCallbackFlags statusFlags, void *userData);
|
PaStreamCallbackFlags statusFlags, void *userData);
|
||||||
|
|
||||||
@ -33,3 +34,23 @@ protected:
|
|||||||
PaStreamParameters outputParameters;
|
PaStreamParameters outputParameters;
|
||||||
PaStream *stream;
|
PaStream *stream;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class AudioThreadNew {
|
||||||
|
private:
|
||||||
|
ThreadQueue<std::string> *threadQueue;
|
||||||
|
public:
|
||||||
|
AudioThreadNew(ThreadQueue<std::string> *tq_in) {
|
||||||
|
threadQueue = tq_in;
|
||||||
|
}
|
||||||
|
|
||||||
|
void threadMain() {
|
||||||
|
while (1) {
|
||||||
|
while (!threadQueue->empty()) {
|
||||||
|
std::string str;
|
||||||
|
if (threadQueue->try_pop(str)) {
|
||||||
|
std::cout << str << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user