mirror of
https://github.com/cjcliffe/CubicSDR.git
synced 2025-09-03 13:47:53 -04:00
Preparing to change threading model
This commit is contained in:
parent
92b390fefe
commit
a9d46b7624
@ -164,8 +164,6 @@ void AppFrame::OnThread(wxCommandEvent& event) {
|
|||||||
|
|
||||||
void AppFrame::OnIdle(wxIdleEvent& event) {
|
void AppFrame::OnIdle(wxIdleEvent& event) {
|
||||||
|
|
||||||
Sleep(10);
|
|
||||||
|
|
||||||
event.Skip();
|
event.Skip();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
#include "SpectrumCanvas.h"
|
#include "SpectrumCanvas.h"
|
||||||
#include "WaterfallCanvas.h"
|
#include "WaterfallCanvas.h"
|
||||||
|
|
||||||
|
|
||||||
// Define a new frame type
|
// Define a new frame type
|
||||||
class AppFrame: public wxFrame {
|
class AppFrame: public wxFrame {
|
||||||
public:
|
public:
|
||||||
|
@ -2,6 +2,31 @@
|
|||||||
#include "CubicSDRDefs.h"
|
#include "CubicSDRDefs.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#ifdef WIN32
|
||||||
|
#include <algorithm>
|
||||||
|
#include <functional>
|
||||||
|
#include <cctype>
|
||||||
|
#include <locale>
|
||||||
|
#include <sstream>
|
||||||
|
|
||||||
|
// trim from start
|
||||||
|
static inline std::wstring &wltrim(std::wstring &s) {
|
||||||
|
s.erase(s.begin(), std::find_if(s.begin(), s.end(), std::not1(std::ptr_fun<int, int>(std::isspace))));
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
// trim from end
|
||||||
|
static inline std::wstring &wrtrim(std::wstring &s) {
|
||||||
|
s.erase(std::find_if(s.rbegin(), s.rend(), std::not1(std::ptr_fun<int, int>(std::isspace))).base(), s.end());
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
// trim from both ends
|
||||||
|
static inline std::wstring &wtrim(std::wstring &s) {
|
||||||
|
return wltrim(wrtrim(s));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
//wxDEFINE_EVENT(wxEVT_COMMAND_AudioThread_INPUT, wxThreadEvent);
|
//wxDEFINE_EVENT(wxEVT_COMMAND_AudioThread_INPUT, wxThreadEvent);
|
||||||
|
|
||||||
AudioThread::AudioThread(AudioThreadQueue* pQueue, int id) :
|
AudioThread::AudioThread(AudioThreadQueue* pQueue, int id) :
|
||||||
@ -74,16 +99,23 @@ wxThread::ExitCode AudioThread::Entry() {
|
|||||||
wchar_t dev_str[255];
|
wchar_t dev_str[255];
|
||||||
memset(dev_str, 0, sizeof(wchar_t) * 255);
|
memset(dev_str, 0, sizeof(wchar_t) * 255);
|
||||||
std::wstring env_name(L"PA_RECOMMENDED_OUTPUT_DEVICE");
|
std::wstring env_name(L"PA_RECOMMENDED_OUTPUT_DEVICE");
|
||||||
GetEnvironmentVariable(env_name.c_str(), dev_str, 255);
|
GetEnvironmentVariable(wtrim(env_name).c_str(), dev_str, 255);
|
||||||
std::wstring env_result(dev_str);
|
std::wistringstream env_result(dev_str);
|
||||||
|
|
||||||
int env_dev = _wtoi(env_result.c_str());
|
if (!env_result.eof()) {
|
||||||
|
int env_dev = -1;
|
||||||
|
env_result >> env_dev;
|
||||||
|
|
||||||
if (env_dev || env_result.length()) {
|
if (env_result.eof()) { // read everything, was all a number
|
||||||
std::cout << "Using preferred PortAudio device PA_RECOMMENDED_OUTPUT_DEVICE=" << env_result.c_str() << std::endl;
|
if (env_dev >= 0) {
|
||||||
preferred_device = env_dev;
|
std::cout << "Using preferred PortAudio device PA_RECOMMENDED_OUTPUT_DEVICE=" << env_dev << std::endl;
|
||||||
} else {
|
preferred_device = env_dev;
|
||||||
std::cout << "Environment variable PA_RECOMMENDED_OUTPUT_DEVICE not set, using PortAudio defaults." << std::endl;
|
} else {
|
||||||
|
std::cout << "Environment variable PA_RECOMMENDED_OUTPUT_DEVICE not set, using PortAudio defaults." << std::endl;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
std::cout << "Environment variable PA_RECOMMENDED_OUTPUT_DEVICE didn't evaluate to a number, using PortAudio defaults." << std::endl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user