Default to new demod if last active out of range

This commit is contained in:
Charles J. Cliffe 2014-12-18 21:39:32 -05:00
parent 77653a54ee
commit c8adad8d6d
2 changed files with 17 additions and 10 deletions

View File

@ -24,7 +24,7 @@ void DemodulatorThread::threadMain() {
#ifdef __APPLE__ #ifdef __APPLE__
pthread_t tID = pthread_self(); // ID of this thread pthread_t tID = pthread_self(); // ID of this thread
int priority = sched_get_priority_max( SCHED_FIFO )-1; int priority = sched_get_priority_max( SCHED_FIFO )-1;
sched_param prio = { priority }; // scheduling priority of thread sched_param prio = {priority}; // scheduling priority of thread
pthread_setschedparam(tID, SCHED_FIFO, &prio); pthread_setschedparam(tID, SCHED_FIFO, &prio);
#endif #endif
@ -94,10 +94,13 @@ void DemodulatorThread::threadMain() {
} }
if (visOutQueue != NULL && visOutQueue->empty()) { if (visOutQueue != NULL && visOutQueue->empty()) {
AudioThreadInput ati_vis; if (num_audio_written > num_written) {
ati_vis.data.assign(demod_output,demod_output+num_written); visOutQueue->push(ati);
visOutQueue->push(ati_vis); } else {
// visOutQueue->push(ati); AudioThreadInput ati_vis;
ati_vis.data.assign(demod_output, demod_output + num_written);
visOutQueue->push(ati_vis);
}
} }
} }

View File

@ -77,13 +77,15 @@ void WaterfallCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
DemodulatorInstance *activeDemodulator = wxGetApp().getDemodMgr().getActiveDemodulator(); DemodulatorInstance *activeDemodulator = wxGetApp().getDemodMgr().getActiveDemodulator();
DemodulatorInstance *lastActiveDemodulator = wxGetApp().getDemodMgr().getLastActiveDemodulator(); DemodulatorInstance *lastActiveDemodulator = wxGetApp().getDemodMgr().getLastActiveDemodulator();
bool isNew = shiftDown || (wxGetApp().getDemodMgr().getLastActiveDemodulator() && !wxGetApp().getDemodMgr().getLastActiveDemodulator()->isActive());
if (mTracker.mouseInView()) { if (mTracker.mouseInView()) {
if (nextDragState == WF_DRAG_RANGE) { if (nextDragState == WF_DRAG_RANGE) {
if (mTracker.mouseDown()) { if (mTracker.mouseDown()) {
float width = mTracker.getOriginDeltaMouseX(); float width = mTracker.getOriginDeltaMouseX();
float centerPos = mTracker.getOriginMouseX() + width / 2.0; float centerPos = mTracker.getOriginMouseX() + width / 2.0;
if (shiftDown) { if (isNew) {
glContext->DrawDemod(lastActiveDemodulator); glContext->DrawDemod(lastActiveDemodulator);
glContext->DrawFreqSelector(centerPos, 0, 1, 0, width ? width : (1.0 / (float) ClientSize.x)); glContext->DrawFreqSelector(centerPos, 0, 1, 0, width ? width : (1.0 / (float) ClientSize.x));
} else { } else {
@ -91,7 +93,7 @@ void WaterfallCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
glContext->DrawFreqSelector(centerPos, 1, 1, 0, width ? width : (1.0 / (float) ClientSize.x)); glContext->DrawFreqSelector(centerPos, 1, 1, 0, width ? width : (1.0 / (float) ClientSize.x));
} }
} else { } else {
if (shiftDown) { if (isNew) {
glContext->DrawDemod(lastActiveDemodulator); glContext->DrawDemod(lastActiveDemodulator);
glContext->DrawFreqSelector(mTracker.getMouseX(), 0, 1, 0, 1.0 / (float) ClientSize.x); glContext->DrawFreqSelector(mTracker.getMouseX(), 0, 1, 0, 1.0 / (float) ClientSize.x);
} else { } else {
@ -102,7 +104,7 @@ void WaterfallCanvas::OnPaint(wxPaintEvent& WXUNUSED(event)) {
} else { } else {
if (activeDemodulator == NULL) { if (activeDemodulator == NULL) {
if (lastActiveDemodulator) { if (lastActiveDemodulator) {
if (shiftDown) { if (isNew) {
glContext->DrawDemod(lastActiveDemodulator); glContext->DrawDemod(lastActiveDemodulator);
glContext->DrawFreqSelector(mTracker.getMouseX(), 0, 1, 0); glContext->DrawFreqSelector(mTracker.getMouseX(), 0, 1, 0);
} else { } else {
@ -420,6 +422,8 @@ void WaterfallCanvas::mouseReleased(wxMouseEvent& event) {
altDown = event.AltDown(); altDown = event.AltDown();
ctrlDown = event.ControlDown(); ctrlDown = event.ControlDown();
bool isNew = shiftDown || (wxGetApp().getDemodMgr().getLastActiveDemodulator() && !wxGetApp().getDemodMgr().getLastActiveDemodulator()->isActive());
mTracker.setVertDragLock(false); mTracker.setVertDragLock(false);
mTracker.setHorizDragLock(false); mTracker.setHorizDragLock(false);
@ -431,7 +435,7 @@ void WaterfallCanvas::mouseReleased(wxMouseEvent& event) {
int freq = center_freq - (int) (0.5 * (float) SRATE) + (int) ((float) pos * (float) SRATE); int freq = center_freq - (int) (0.5 * (float) SRATE) + (int) ((float) pos * (float) SRATE);
if (dragState == WF_DRAG_NONE) { if (dragState == WF_DRAG_NONE) {
if (!shiftDown && wxGetApp().getDemodMgr().getDemodulators().size()) { if (!isNew && wxGetApp().getDemodMgr().getDemodulators().size()) {
demod = wxGetApp().getDemodMgr().getLastActiveDemodulator(); demod = wxGetApp().getDemodMgr().getLastActiveDemodulator();
} else { } else {
demod = wxGetApp().getDemodMgr().newThread(); demod = wxGetApp().getDemodMgr().newThread();
@ -493,7 +497,7 @@ void WaterfallCanvas::mouseReleased(wxMouseEvent& event) {
return; return;
} }
if (!shiftDown && wxGetApp().getDemodMgr().getDemodulators().size()) { if (!isNew && wxGetApp().getDemodMgr().getDemodulators().size()) {
demod = wxGetApp().getDemodMgr().getLastActiveDemodulator(); demod = wxGetApp().getDemodMgr().getLastActiveDemodulator();
} else { } else {
demod = wxGetApp().getDemodMgr().newThread(); demod = wxGetApp().getDemodMgr().newThread();