Skip to content

Commit

Permalink
BearStatus to track startup of bear and log error
Browse files Browse the repository at this point in the history
  • Loading branch information
firthm01 committed Jan 5, 2024
1 parent ed85b82 commit 57a2875
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include <vector>
#include <string>
#include <../src/dynamic_renderer.hpp>
#include "variable_block_adapter.hpp"
#include <chrono>
Expand All @@ -9,6 +10,20 @@
namespace ear {
namespace plugin {

enum BearStatusStates {
NOT_ATTEMPTED = 0,
FAILED,
SUCCEEDED
};

struct BearStatus {
bear::Config startupConfig;
BearStatusStates startupSuccess{NOT_ATTEMPTED};
std::string startupErrorDesc;
BearStatusStates listenerDataSetSuccess{NOT_ATTEMPTED};
std::string listenerDataSetErrorDesc;
};

/**
* @brief Binaural monitoring plugin dsp implementation
*
Expand Down Expand Up @@ -47,6 +62,8 @@ class BinauralMonitoringAudioProcessor {
BinauralMonitoringAudioProcessor& operator=(
BinauralMonitoringAudioProcessor&&) = delete;

BearStatus getBearStatus() { return bearStatus; }

template <typename InBuffer, typename OutBuffer>
void process(const InBuffer& in, OutBuffer& out) {
using InTraits = BufferTraits<InBuffer>;
Expand Down Expand Up @@ -84,6 +101,7 @@ class BinauralMonitoringAudioProcessor {
std::shared_ptr<bear::DynamicRenderer> bearRenderer; // TODO - why shared?
std::mutex bearListenerMutex_;
bear::Listener bearListener;
BearStatus bearStatus;

bool listenerQuatsDirty{false};
std::array<double, 4> listenerQuats{1.0, 0.0, 0.0, 0.0};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,26 @@ BinauralMonitoringAudioProcessor::BinauralMonitoringAudioProcessor(

bearListener.set_position_cart(std::array<double, 3>{0.0, 0.0, 0.0});

bearStatus.startupConfig = bearConfig;
try {
bearRenderer = std::make_shared<bear::DynamicRenderer>(
blockSize,
std::max(std::max(maxObjChannels, maxDsChannels), maxHoaChannels));
bearRenderer->set_config_blocking(bearConfig);
bearStatus.startupSuccess = BearStatusStates::SUCCEEDED;
try {
bearRenderer->set_listener(bearListener);
bearStatus.listenerDataSetSuccess = BearStatusStates::SUCCEEDED;
} catch (std::exception &e) {
bearStatus.listenerDataSetSuccess = BearStatusStates::FAILED;
bearStatus.listenerDataSetErrorDesc = e.what();
bearRenderer.reset();
assert(false);
assert(false); // we're not feeding back this yet, so assert so we notice it
}
} catch (std::exception &e) {
bearStatus.startupSuccess = BearStatusStates::FAILED;
bearStatus.startupErrorDesc = e.what();
bearRenderer.reset();
assert(false);
}
}

Expand Down

0 comments on commit 57a2875

Please sign in to comment.