summaryrefslogtreecommitdiff
path: root/drivers/pulseaudio
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2017-03-05 16:44:50 +0100
committerRémi Verschelde <rverschelde@gmail.com>2017-03-05 16:44:50 +0100
commit5dbf1809c6e3e905b94b8764e99491e608122261 (patch)
tree5e5a5360db15d86d59ec8c6e4f7eb511388c5a9a /drivers/pulseaudio
parent45438e9918d421b244bfd7776a30e67dc7f2d3e3 (diff)
A Whole New World (clang-format edition)
I can show you the code Pretty, with proper whitespace Tell me, coder, now when did You last write readable code? I can open your eyes Make you see your bad indent Force you to respect the style The core devs agreed upon A whole new world A new fantastic code format A de facto standard With some sugar Enforced with clang-format A whole new world A dazzling style we all dreamed of And when we read it through It's crystal clear That now we're in a whole new world of code
Diffstat (limited to 'drivers/pulseaudio')
-rw-r--r--drivers/pulseaudio/audio_driver_pulseaudio.cpp41
-rw-r--r--drivers/pulseaudio/audio_driver_pulseaudio.h28
2 files changed, 32 insertions, 37 deletions
diff --git a/drivers/pulseaudio/audio_driver_pulseaudio.cpp b/drivers/pulseaudio/audio_driver_pulseaudio.cpp
index f5268f3ebd..d33ec3ce3a 100644
--- a/drivers/pulseaudio/audio_driver_pulseaudio.cpp
+++ b/drivers/pulseaudio/audio_driver_pulseaudio.cpp
@@ -43,7 +43,7 @@ Error AudioDriverPulseAudio::init() {
samples_in = NULL;
samples_out = NULL;
- mix_rate = GLOBAL_DEF("audio/mix_rate",44100);
+ mix_rate = GLOBAL_DEF("audio/mix_rate", 44100);
speaker_mode = SPEAKER_MODE_STEREO;
channels = 2;
@@ -64,23 +64,21 @@ Error AudioDriverPulseAudio::init() {
attr.minreq = (uint32_t)-1;
int error_code;
- pulse = pa_simple_new( NULL, // default server
- "Godot", // application name
- PA_STREAM_PLAYBACK,
- NULL, // default device
- "Sound", // stream description
- &spec,
- NULL, // use default channel map
- &attr, // use buffering attributes from above
- &error_code
- );
+ pulse = pa_simple_new(NULL, // default server
+ "Godot", // application name
+ PA_STREAM_PLAYBACK,
+ NULL, // default device
+ "Sound", // stream description
+ &spec,
+ NULL, // use default channel map
+ &attr, // use buffering attributes from above
+ &error_code);
if (pulse == NULL) {
- fprintf(stderr, "PulseAudio ERR: %s\n", pa_strerror(error_code));\
+ fprintf(stderr, "PulseAudio ERR: %s\n", pa_strerror(error_code));
ERR_FAIL_COND_V(pulse == NULL, ERR_CANT_OPEN);
}
-
samples_in = memnew_arr(int32_t, buffer_size * channels);
samples_out = memnew_arr(int16_t, buffer_size * channels);
@@ -92,23 +90,23 @@ Error AudioDriverPulseAudio::init() {
float AudioDriverPulseAudio::get_latency() {
- if (latency==0) { //only do this once since it's approximate anyway
+ if (latency == 0) { //only do this once since it's approximate anyway
int error_code;
- pa_usec_t palat = pa_simple_get_latency( pulse,&error_code);
- latency=double(palat)/1000000.0;
+ pa_usec_t palat = pa_simple_get_latency(pulse, &error_code);
+ latency = double(palat) / 1000000.0;
}
return latency;
}
-void AudioDriverPulseAudio::thread_func(void* p_udata) {
+void AudioDriverPulseAudio::thread_func(void *p_udata) {
print_line("thread");
- AudioDriverPulseAudio* ad = (AudioDriverPulseAudio*)p_udata;
+ AudioDriverPulseAudio *ad = (AudioDriverPulseAudio *)p_udata;
while (!ad->exit_thread) {
if (!ad->active) {
- for (unsigned int i=0; i < ad->buffer_size * ad->channels; i++) {
+ for (unsigned int i = 0; i < ad->buffer_size * ad->channels; i++) {
ad->samples_out[i] = 0;
}
@@ -119,7 +117,7 @@ void AudioDriverPulseAudio::thread_func(void* p_udata) {
ad->unlock();
- for (unsigned int i=0; i < ad->buffer_size * ad->channels;i ++) {
+ for (unsigned int i = 0; i < ad->buffer_size * ad->channels; i++) {
ad->samples_out[i] = ad->samples_in[i] >> 16;
}
}
@@ -199,11 +197,10 @@ AudioDriverPulseAudio::AudioDriverPulseAudio() {
mutex = NULL;
thread = NULL;
pulse = NULL;
- latency=0;
+ latency = 0;
}
AudioDriverPulseAudio::~AudioDriverPulseAudio() {
-
}
#endif
diff --git a/drivers/pulseaudio/audio_driver_pulseaudio.h b/drivers/pulseaudio/audio_driver_pulseaudio.h
index 36ae8c2e53..b6508434d4 100644
--- a/drivers/pulseaudio/audio_driver_pulseaudio.h
+++ b/drivers/pulseaudio/audio_driver_pulseaudio.h
@@ -30,27 +30,27 @@
#ifdef PULSEAUDIO_ENABLED
-#include "core/os/thread.h"
#include "core/os/mutex.h"
+#include "core/os/thread.h"
#include <pulse/simple.h>
-class AudioDriverPulseAudio : public AudioDriver{
+class AudioDriverPulseAudio : public AudioDriver {
- Thread* thread;
- Mutex* mutex;
+ Thread *thread;
+ Mutex *mutex;
- pa_simple* pulse;
+ pa_simple *pulse;
- int32_t* samples_in;
- int16_t* samples_out;
+ int32_t *samples_in;
+ int16_t *samples_out;
- static void thread_func(void* p_udata);
+ static void thread_func(void *p_udata);
unsigned int mix_rate;
SpeakerMode speaker_mode;
- unsigned int buffer_size;
+ unsigned int buffer_size;
int channels;
bool active;
@@ -61,9 +61,8 @@ class AudioDriverPulseAudio : public AudioDriver{
float latency;
public:
-
- const char* get_name() const {
- return "PulseAudio";
+ const char *get_name() const {
+ return "PulseAudio";
};
virtual Error init();
@@ -76,9 +75,8 @@ public:
virtual float get_latency();
-
- AudioDriverPulseAudio();
- ~AudioDriverPulseAudio();
+ AudioDriverPulseAudio();
+ ~AudioDriverPulseAudio();
};
#endif