Skip to content

Commit 2bd1654

Browse files
passingpljones
authored andcommitted
apply clang-format style definition
1 parent 6d9d941 commit 2bd1654

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

74 files changed

+6508
-7983
lines changed

android/androiddebug.cpp

+42-42
Original file line numberDiff line numberDiff line change
@@ -22,60 +22,60 @@
2222
*
2323
\******************************************************************************/
2424

25-
const char*const applicationName = "Jamulus";
25+
const char* const applicationName = "Jamulus";
2626

2727
#ifdef ANDROIDDEBUG // Set in my myapp.pro file for android builds
28-
#include <android/log.h>
29-
#include <QString>
30-
#include <QEvent>
31-
#include <QDebug>
32-
#include <stdio.h>
33-
#include <math.h>
34-
#include <string>
28+
# include <android/log.h>
29+
# include <QString>
30+
# include <QEvent>
31+
# include <QDebug>
32+
# include <stdio.h>
33+
# include <math.h>
34+
# include <string>
3535

3636
void myMessageHandler ( QtMsgType type, const QMessageLogContext& context, const QString& msg )
3737
{
38-
QString report = msg;
38+
QString report = msg;
3939

40-
if ( context.file && !QString ( context.file ).isEmpty() )
41-
{
42-
report += " in file ";
43-
report += QString ( context.file );
44-
report += " line ";
45-
report += QString::number ( context.line );
46-
}
40+
if ( context.file && !QString ( context.file ).isEmpty() )
41+
{
42+
report += " in file ";
43+
report += QString ( context.file );
44+
report += " line ";
45+
report += QString::number ( context.line );
46+
}
4747

48-
if ( context.function && !QString ( context.function ).isEmpty() )
49-
{
50-
report +=+" function ";
51-
report += QString(context.function);
52-
}
48+
if ( context.function && !QString ( context.function ).isEmpty() )
49+
{
50+
report += +" function ";
51+
report += QString ( context.function );
52+
}
5353

54-
const char*const local = report.toLocal8Bit().constData();
54+
const char* const local = report.toLocal8Bit().constData();
5555

56-
switch ( type )
57-
{
58-
case QtDebugMsg:
59-
__android_log_write ( ANDROID_LOG_DEBUG, applicationName, local) ;
60-
break;
56+
switch ( type )
57+
{
58+
case QtDebugMsg:
59+
__android_log_write ( ANDROID_LOG_DEBUG, applicationName, local );
60+
break;
6161

62-
case QtInfoMsg:
63-
__android_log_write ( ANDROID_LOG_INFO, applicationName, local );
64-
break;
62+
case QtInfoMsg:
63+
__android_log_write ( ANDROID_LOG_INFO, applicationName, local );
64+
break;
6565

66-
case QtWarningMsg:
67-
__android_log_write ( ANDROID_LOG_WARN, applicationName, local );
68-
break;
66+
case QtWarningMsg:
67+
__android_log_write ( ANDROID_LOG_WARN, applicationName, local );
68+
break;
6969

70-
case QtCriticalMsg:
71-
__android_log_write ( ANDROID_LOG_ERROR, applicationName, local );
72-
break;
70+
case QtCriticalMsg:
71+
__android_log_write ( ANDROID_LOG_ERROR, applicationName, local );
72+
break;
7373

74-
case QtFatalMsg:
75-
default:
76-
__android_log_write ( ANDROID_LOG_FATAL, applicationName, local );
77-
abort();
78-
break;
79-
}
74+
case QtFatalMsg:
75+
default:
76+
__android_log_write ( ANDROID_LOG_FATAL, applicationName, local );
77+
abort();
78+
break;
79+
}
8080
}
8181
#endif

android/ring_buffer.h

+70-44
Original file line numberDiff line numberDiff line change
@@ -30,35 +30,42 @@
3030
* Data is contained in a vector dynamically allocated.
3131
*/
3232
template<typename T>
33-
class RingBuffer {
33+
class RingBuffer
34+
{
3435
public:
3536
/**
3637
* @brief RingBuffer
3738
* @param max maximum number of elements that can be contained in the ring buffer
3839
*/
39-
RingBuffer(std::size_t max = 0):mData(max),mRead(0),mWrite(0),mFull(false) { }
40+
RingBuffer ( std::size_t max = 0 ) : mData ( max ), mRead ( 0 ), mWrite ( 0 ), mFull ( false ) {}
4041

4142
/**
4243
* @brief Resets the ring_buffer
4344
* @param max maximum number of elements that can be contained in the ring buffer.
4445
*/
45-
void reset(std::size_t max = 0) {
46-
mData = std::vector<T>(max);
47-
mRead = 0;
46+
void reset ( std::size_t max = 0 )
47+
{
48+
mData = std::vector<T> ( max );
49+
mRead = 0;
4850
mWrite = 0;
49-
mFull = false;
51+
mFull = false;
5052
}
5153

5254
/**
5355
* @brief Current number of elements contained in the ring buffer
5456
* @return
5557
*/
56-
std::size_t size() const {
58+
std::size_t size() const
59+
{
5760
std::size_t size = capacity();
58-
if(!mFull) {
59-
if(mWrite >= mRead) {
61+
if ( !mFull )
62+
{
63+
if ( mWrite >= mRead )
64+
{
6065
size = mWrite - mRead;
61-
} else {
66+
}
67+
else
68+
{
6269
size = capacity() + mWrite - mRead;
6370
}
6471
}
@@ -75,7 +82,7 @@ class RingBuffer {
7582
* @brief whether the ring buffer is empty.
7683
* @return
7784
*/
78-
bool isEmpty() const { return !isFull() && (mRead == mWrite); }
85+
bool isEmpty() const { return !isFull() && ( mRead == mWrite ); }
7986

8087
/**
8188
* @brief Maximum number of elements in the ring buffer
@@ -87,7 +94,8 @@ class RingBuffer {
8794
* @brief Adds a single value
8895
* @param v the value to add
8996
*/
90-
void put(const T &v) {
97+
void put ( const T& v )
98+
{
9199
mData[mWrite] = v;
92100
forward();
93101
}
@@ -97,12 +105,16 @@ class RingBuffer {
97105
* @param v the value read
98106
* @return true if the value was read
99107
*/
100-
bool get(T&v) {
101-
if(!isEmpty()) {
108+
bool get ( T& v )
109+
{
110+
if ( !isEmpty() )
111+
{
102112
v = mData[mRead];
103113
backward();
104114
return true;
105-
} else {
115+
}
116+
else
117+
{
106118
return false;
107119
}
108120
}
@@ -112,13 +124,15 @@ class RingBuffer {
112124
* @param v pointer to the consecutive values
113125
* @param count number of consecutive values.
114126
*/
115-
void put(const T *v, std::size_t count) {
116-
std::size_t avail = mWrite - capacity();
117-
std::size_t to_copy = std::min(count,avail);
118-
memcpy(mData.data() + mWrite,v, to_copy*sizeof(T));
119-
forward(to_copy);
120-
if(to_copy < count) {
121-
put(v+to_copy,count - to_copy);
127+
void put ( const T* v, std::size_t count )
128+
{
129+
std::size_t avail = mWrite - capacity();
130+
std::size_t to_copy = std::min ( count, avail );
131+
memcpy ( mData.data() + mWrite, v, to_copy * sizeof ( T ) );
132+
forward ( to_copy );
133+
if ( to_copy < count )
134+
{
135+
put ( v + to_copy, count - to_copy );
122136
}
123137
}
124138

@@ -128,45 +142,57 @@ class RingBuffer {
128142
* @param count Maximum available size in the memory area
129143
* @return actual number of elements read.
130144
*/
131-
std::size_t get(T *v, std::size_t count) {
145+
std::size_t get ( T* v, std::size_t count )
146+
{
132147
std::size_t avail = 0;
133-
if(mRead < mWrite) {
148+
if ( mRead < mWrite )
149+
{
134150
avail = mWrite - mRead;
135-
} else {
151+
}
152+
else
153+
{
136154
avail = mRead - capacity();
137155
}
138-
std::size_t to_copy = std::min(count, avail);
139-
memcpy(v, mData.data() + mRead, to_copy * sizeof(T));
140-
backward(to_copy);
141-
if((size()>0)&&(count > to_copy)) {
142-
return to_copy + get(v + to_copy, count - to_copy);
143-
} else {
156+
std::size_t to_copy = std::min ( count, avail );
157+
memcpy ( v, mData.data() + mRead, to_copy * sizeof ( T ) );
158+
backward ( to_copy );
159+
if ( ( size() > 0 ) && ( count > to_copy ) )
160+
{
161+
return to_copy + get ( v + to_copy, count - to_copy );
162+
}
163+
else
164+
{
144165
return to_copy;
145166
}
146167
}
168+
147169
private:
148-
void forward() {
149-
if(isFull()) {
150-
mRead = (mRead + 1) % capacity();
170+
void forward()
171+
{
172+
if ( isFull() )
173+
{
174+
mRead = ( mRead + 1 ) % capacity();
151175
}
152-
mWrite = (mWrite + 1) % capacity();
153-
mFull = (mRead == mWrite);
176+
mWrite = ( mWrite + 1 ) % capacity();
177+
mFull = ( mRead == mWrite );
154178
}
155179

156-
void forward(std::size_t count) {
157-
for(std::size_t i=0; i<count;i++) {
180+
void forward ( std::size_t count )
181+
{
182+
for ( std::size_t i = 0; i < count; i++ )
183+
{
158184
forward();
159185
}
160186
}
161187

162-
void backward(std::size_t count) {
188+
void backward ( std::size_t count )
189+
{
163190
mFull = false;
164-
mRead = (mRead + count) % capacity();
191+
mRead = ( mRead + count ) % capacity();
165192
}
166193

167194
std::vector<T> mData;
168-
std::size_t mRead; /** offset to reading point */
169-
std::size_t mWrite; /** offset to writing point */
170-
bool mFull;
195+
std::size_t mRead; /** offset to reading point */
196+
std::size_t mWrite; /** offset to writing point */
197+
bool mFull;
171198
};
172-

0 commit comments

Comments
 (0)