Skip to content

Commit

Permalink
clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
Andersama committed May 21, 2024
1 parent 38857df commit ef995b7
Showing 1 changed file with 23 additions and 21 deletions.
44 changes: 23 additions & 21 deletions src/asio-input.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <obs-frontend-api.h>
#include <vector>
#include <algorithm>
//#include <JuceHeader.h>
// #include <JuceHeader.h>
#include <juce_core/juce_core.h>
#include <juce_audio_devices/juce_audio_devices.h>
using namespace juce;
Expand Down Expand Up @@ -162,16 +162,16 @@ class AudioCB : public juce::AudioIODeviceCallback {
private:
static constexpr unsigned int client_mask = 0x1;
static constexpr unsigned int device_mask = 0x2;
std::vector<short> _route;
std::vector<short> _route_out;
obs_source_audio in;
obs_source_t *source;
std::vector<short> _route;
std::vector<short> _route_out;
obs_source_audio in;
obs_source_t *source;

unsigned int active;
int read_index = 0;
int wait_time = 4;
AudioCB *callback;
AudioCB *current_callback;
int read_index = 0;
int wait_time = 4;
AudioCB *callback;
AudioCB *current_callback;

size_t silent_buffer_size = 0;
uint8_t *silent_buffer = nullptr;
Expand Down Expand Up @@ -226,11 +226,13 @@ class AudioCB : public juce::AudioIODeviceCallback {
active |= client_mask;
}

void device_disconnect() {
void device_disconnect()
{
active &= client_mask;
}

void device_reconnect() {
void device_reconnect()
{
active |= device_mask;
}

Expand Down Expand Up @@ -292,10 +294,11 @@ class AudioCB : public juce::AudioIODeviceCallback {
return wait_time;
}
};

private:
std::vector<AudioListener *> _clients;
public:

public:
AudioIODevice *getDevice()
{
return _device;
Expand Down Expand Up @@ -354,10 +357,10 @@ class AudioCB : public juce::AudioIODeviceCallback {
break;
}
}

if (!found_client)
_clients.push_back(client);

client->setCurrentCallback(this);
client->setReadIndex(_write_index);
_thread->addTimeSliceClient(client);
Expand Down Expand Up @@ -412,7 +415,7 @@ class AudioCB : public juce::AudioIODeviceCallback {
_thread = global_thread;
} else {
/*
// update clients with this device to use this callback
// update clients with this device to use this callback
// BUGFIX: when pkv modified the source code to use one global thread
// this became bugged, originally
for (int i = 0; i < _thread->getNumClients(); i++) {
Expand All @@ -430,7 +433,6 @@ class AudioCB : public juce::AudioIODeviceCallback {
// since we're here, we can mark the device as being ok
known_client->device_reconnect();
}

}
if (!_thread->isThreadRunning())
_thread->startThread(10);
Expand All @@ -441,7 +443,7 @@ class AudioCB : public juce::AudioIODeviceCallback {
for (auto known_client : _clients) {
known_client->device_disconnect();
}

blog(LOG_INFO, "Stopped (%s)", _device->getName().toStdString().c_str());

std::string timestamp_string = std::to_string(last_audio_ts);
Expand All @@ -456,14 +458,14 @@ class AudioCB : public juce::AudioIODeviceCallback {
if (_thread)
_thread->stopThread(200);
// was ok because _thread was unique to each AudioCB (the this pointer)
// now any device that sends an error effectively nukes all other processing
// which likely will cause problems
*/
// now any device that sends an error effectively nukes all other processing
// which likely will cause problems
*/
// Instead we'll mark all clients as having the device disconnected
for (auto known_client : _clients) {
known_client->device_disconnect();
}

std::string error = errorMessage.toStdString();
blog(LOG_ERROR, "Device Error!\n%s", error.c_str());

Expand Down

0 comments on commit ef995b7

Please sign in to comment.