Skip to content

Commit 51d8546

Browse files
committed
format
1 parent 044f7e0 commit 51d8546

18 files changed

+265
-263
lines changed

src/aumiks/config.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ SOFTWARE.
2727

2828
#pragma once
2929

30-
namespace aumiks{
30+
namespace aumiks {
3131

3232
typedef float real;
3333

34-
}
34+
} // namespace aumiks

src/aumiks/frame.hpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,25 +27,25 @@ SOFTWARE.
2727

2828
#pragma once
2929

30-
#include <audout/format.hpp>
31-
3230
#include <array>
3331

32+
#include <audout/format.hpp>
3433
#include <utki/debug.hpp>
3534

3635
#include "config.hpp"
3736

38-
namespace aumiks{
37+
namespace aumiks {
3938

40-
struct frame{
39+
struct frame {
4140
std::array<real, audout::num_channels(audout::frame::stereo)> channel;
42-
43-
void add(const frame& f){
41+
42+
void add(const frame& f)
43+
{
4444
ASSERT(this->channel.size() == f.channel.size())
45-
for(unsigned i = 0; i != this->channel.size(); ++i){
45+
for (unsigned i = 0; i != this->channel.size(); ++i) {
4646
this->channel[i] += f.channel[i];
4747
}
4848
}
4949
};
5050

51-
}
51+
} // namespace aumiks

src/aumiks/input.cpp

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,43 +29,46 @@ SOFTWARE.
2929

3030
using namespace aumiks;
3131

32-
void input::connect(std::shared_ptr<aumiks::source> source){
32+
void input::connect(std::shared_ptr<aumiks::source> source)
33+
{
3334
ASSERT(source)
3435

35-
if(this->is_connected()){
36+
if (this->is_connected()) {
3637
throw std::logic_error("the input already connected");
3738
}
3839

39-
if(source->is_connected()){
40+
if (source->is_connected()) {
4041
throw std::logic_error("the source is already connected");
4142
}
42-
43+
4344
{
4445
std::lock_guard<decltype(this->mutex)> guard(this->mutex);
4546
source->is_source_connected = true;
4647
this->src = std::move(source);
4748
}
4849
}
4950

50-
void input::disconnect()noexcept{
51+
void input::disconnect() noexcept
52+
{
5153
std::lock_guard<decltype(this->mutex)> guard(this->mutex);
5254

53-
if(this->src){
55+
if (this->src) {
5456
this->src->is_source_connected = false;
5557
this->src.reset();
5658
}
5759
}
5860

59-
bool input::fill_sample_buffer(utki::span<frame> buf)noexcept{
61+
bool input::fill_sample_buffer(utki::span<frame> buf) noexcept
62+
{
6063
{
6164
std::lock_guard<decltype(this->mutex)> guard(this->mutex);
62-
if(this->src != this->src_in_use){
65+
if (this->src != this->src_in_use) {
6366
this->src_in_use = this->src;
6467
}
6568
}
66-
if(!this->src_in_use){
67-
for(auto& b : buf){
68-
for(auto& c : b.channel){
69+
if (!this->src_in_use) {
70+
for (auto& b : buf) {
71+
for (auto& c : b.channel) {
6972
c = 0;
7073
}
7174
}

src/aumiks/input.hpp

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,39 +27,41 @@ SOFTWARE.
2727

2828
#pragma once
2929

30-
#include <utki/spin_lock.hpp>
31-
32-
#include <type_traits>
3330
#include <mutex>
31+
#include <type_traits>
32+
33+
#include <utki/spin_lock.hpp>
3434

3535
#include "config.hpp"
36-
#include "source.hpp"
3736
#include "frame.hpp"
37+
#include "source.hpp"
3838

39-
namespace aumiks{
39+
namespace aumiks {
4040

41-
class input{
41+
class input
42+
{
4243
protected:
4344
std::shared_ptr<source> src;
44-
45+
4546
std::shared_ptr<source> src_in_use;
46-
47+
4748
utki::spin_lock mutex;
48-
49+
4950
public:
5051
input() = default;
51-
52+
5253
virtual ~input() = default;
53-
54-
void disconnect()noexcept;
55-
54+
55+
void disconnect() noexcept;
56+
5657
void connect(std::shared_ptr<aumiks::source> source);
57-
58-
bool is_connected()const{
58+
59+
bool is_connected() const
60+
{
5961
return this->src.get() != nullptr;
6062
}
6163

62-
bool fill_sample_buffer(utki::span<frame> buf)noexcept;
64+
bool fill_sample_buffer(utki::span<frame> buf) noexcept;
6365
};
6466

65-
}
67+
} // namespace aumiks

src/aumiks/mixer.cpp

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -29,50 +29,45 @@ SOFTWARE.
2929

3030
using namespace aumiks;
3131

32-
void mixer::connect(std::shared_ptr<aumiks::source> source){
32+
void mixer::connect(std::shared_ptr<aumiks::source> source)
33+
{
3334
std::lock_guard<decltype(this->spin_lock)> guard(this->spin_lock);
3435
this->inputs_to_add.emplace_back();
3536
this->inputs_to_add.back().connect(std::move(source));
3637
}
3738

38-
bool mixer::fill_sample_buffer(utki::span<frame> buf)noexcept{
39+
bool mixer::fill_sample_buffer(utki::span<frame> buf) noexcept
40+
{
3941
{
4042
std::lock_guard<decltype(this->spin_lock)> guard(this->spin_lock);
4143
this->inputs.splice(this->inputs.end(), this->inputs_to_add);
4244
}
4345

4446
this->tmp_buf.resize(buf.size());
4547

46-
for(auto& f : buf){
47-
for(auto& c : f.channel){
48+
for (auto& f : buf) {
49+
for (auto& c : f.channel) {
4850
c = 0;
4951
}
5052
}
5153

52-
for(auto i = this->inputs.begin(); i != this->inputs.end();){
53-
if(i->fill_sample_buffer(utki::make_span(this->tmp_buf))){
54+
for (auto i = this->inputs.begin(); i != this->inputs.end();) {
55+
if (i->fill_sample_buffer(utki::make_span(this->tmp_buf))) {
5456
i = this->inputs.erase(i);
55-
}else{
57+
} else {
5658
++i;
5759
}
5860

5961
auto src = this->tmp_buf.cbegin();
60-
for(
61-
auto dst = buf.begin(),
62-
end = buf.end();
63-
dst != end;
64-
++dst,
65-
++src
66-
)
67-
{
62+
for (auto dst = buf.begin(), end = buf.end(); dst != end; ++dst, ++src) {
6863
ASSERT(src != this->tmp_buf.cend())
6964
dst->add(*src);
7065
}
7166
}
7267

73-
if(this->is_finite()){
68+
if (this->is_finite()) {
7469
return this->inputs.size() == 0;
75-
}else{
70+
} else {
7671
return false;
7772
}
7873
}

src/aumiks/mixer.hpp

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,39 +27,42 @@ SOFTWARE.
2727

2828
#pragma once
2929

30-
#include "source.hpp"
31-
#include "input.hpp"
32-
3330
#include <list>
3431

3532
#include <utki/spin_lock.hpp>
3633

37-
namespace aumiks{
34+
#include "input.hpp"
35+
#include "source.hpp"
36+
37+
namespace aumiks {
3838

39-
class mixer : virtual public source{
39+
class mixer : virtual public source
40+
{
4041
volatile bool is_mixer_finite = true;
41-
42+
4243
utki::spin_lock spin_lock;
43-
44+
4445
std::list<aumiks::input> inputs;
45-
46+
4647
decltype(inputs) inputs_to_add;
47-
48+
4849
std::vector<frame> tmp_buf;
49-
50+
5051
public:
5152
void connect(std::shared_ptr<aumiks::source> source);
52-
53-
void set_finite(bool finite)noexcept{
53+
54+
void set_finite(bool finite) noexcept
55+
{
5456
this->is_mixer_finite = finite;
5557
}
56-
57-
bool is_finite()const noexcept{
58+
59+
bool is_finite() const noexcept
60+
{
5861
return this->is_mixer_finite;
5962
}
60-
63+
6164
protected:
62-
bool fill_sample_buffer(utki::span<frame> buf)noexcept override;
65+
bool fill_sample_buffer(utki::span<frame> buf) noexcept override;
6366
};
6467

65-
}
68+
} // namespace aumiks

src/aumiks/null_source.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,10 @@ SOFTWARE.
2929

3030
using namespace aumiks;
3131

32-
bool null_source::fill_sample_buffer(utki::span<frame> buf)noexcept{
33-
for(auto& f : buf){
34-
for(auto& c : f.channel){
32+
bool null_source::fill_sample_buffer(utki::span<frame> buf) noexcept
33+
{
34+
for (auto& f : buf) {
35+
for (auto& c : f.channel) {
3536
c = real(0);
3637
}
3738
}

src/aumiks/null_source.hpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,12 @@ SOFTWARE.
2929

3030
#include "source.hpp"
3131

32-
namespace aumiks{
32+
namespace aumiks {
3333

34-
class null_source : public source{
34+
class null_source : public source
35+
{
3536
public:
36-
bool fill_sample_buffer(utki::span<frame> buf)noexcept override;
37+
bool fill_sample_buffer(utki::span<frame> buf) noexcept override;
3738
};
3839

39-
}
40+
} // namespace aumiks

0 commit comments

Comments
 (0)