commit f150aab5e67a545824004a49277c82f66c0c4651
Author: Robert Haschke <rhaschke@techfak.uni-bielefeld.de>
Date:   Sat Nov 14 14:57:52 2020 +0100

    clang-format-10

diff --git a/server/src/AudioPlayerLibAO.cpp b/server/src/AudioPlayerLibAO.cpp
index b86a25e..77934a2 100644
--- a/server/src/AudioPlayerLibAO.cpp
+++ b/server/src/AudioPlayerLibAO.cpp
@@ -1,192 +1,193 @@
 /*
-* This file is part of hlrc_server
-*
-* Copyright(c) sschulz <AT> techfak.uni-bielefeld.de
-* http://opensource.cit-ec.de/projects/hlrc_server
-*
-* This file may be licensed under the terms of the
-* GNU General Public License Version 3 (the ``GPL''),
-* or (at your option) any later version.
-*
-* Software distributed under the License is distributed
-* on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
-* express or implied. See the GPL for the specific language
-* governing rights and limitations.
-*
-* You should have received a copy of the GPL along with this
-* program. If not, go to http://www.gnu.org/licenses/gpl.html
-* or write to the Free Software Foundation, Inc.,
-* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-*
-* The development of this software was supported by the
-* Excellence Cluster EXC 277 Cognitive Interaction Technology.
-* The Excellence Cluster EXC 277 is a grant of the Deutsche
-* Forschungsgemeinschaft (DFG) in the context of the German
-* Excellence Initiative.
-*
-*/
+ * This file is part of hlrc_server
+ *
+ * Copyright(c) sschulz <AT> techfak.uni-bielefeld.de
+ * http://opensource.cit-ec.de/projects/hlrc_server
+ *
+ * This file may be licensed under the terms of the
+ * GNU General Public License Version 3 (the ``GPL''),
+ * or (at your option) any later version.
+ *
+ * Software distributed under the License is distributed
+ * on an ``AS IS'' basis, WITHOUT WARRANTY OF ANY KIND, either
+ * express or implied. See the GPL for the specific language
+ * governing rights and limitations.
+ *
+ * You should have received a copy of the GPL along with this
+ * program. If not, go to http://www.gnu.org/licenses/gpl.html
+ * or write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The development of this software was supported by the
+ * Excellence Cluster EXC 277 Cognitive Interaction Technology.
+ * The Excellence Cluster EXC 277 is a grant of the Deutsche
+ * Forschungsgemeinschaft (DFG) in the context of the German
+ * Excellence Initiative.
+ *
+ */
 
 #include "AudioPlayerLibAO.h"
 
 using namespace std;
 using namespace boost;
 
-//new audio player with gievn device type (default is pulse)
-AudioPlayerLibAO::AudioPlayerLibAO(string driver): AudioPlayer(driver){
-    printf("> using libao for playback\n");
+// new audio player with gievn device type (default is pulse)
+AudioPlayerLibAO::AudioPlayerLibAO(string driver) : AudioPlayer(driver) {
+	printf("> using libao for playback\n");
 
-    //initialize
-    ao_initialize();
+	// initialize
+	ao_initialize();
 
-    //configure driver
-    if (audio_driver.empty()){
-        //use default:
-        driver = ao_default_driver_id();
-    }else{
-        driver = ao_driver_id(audio_driver.c_str());
-    }
+	// configure driver
+	if (audio_driver.empty()) {
+		// use default:
+		driver = ao_default_driver_id();
+	}
+	else {
+		driver = ao_driver_id(audio_driver.c_str());
+	}
 
-    //start audio playback thread:
-    playback_thread_ptr = new boost::thread(boost::bind(&AudioPlayerLibAO::playback_thread, this));
+	// start audio playback thread:
+	playback_thread_ptr = new boost::thread(boost::bind(&AudioPlayerLibAO::playback_thread, this));
 }
 
+// this will return once we start playing
+void AudioPlayerLibAO::play(boost::shared_ptr<AudioData> audio) {
+	audio_data = audio;
 
-//this will return once we start playing
-void AudioPlayerLibAO::play(boost::shared_ptr<AudioData> audio){
-    audio_data = audio;
+	printf("> AudioPlayerLibAO: play() %d samples requested\n", (int)audio_data->samples.size());
 
-    printf("> AudioPlayerLibAO: play() %d samples requested\n",(int)audio_data->samples.size());
+	// skip empty audio data
+	if (audio_data->samples.size() == 0) {
+		printf("> warning: empty audio data - skipped.\n");
+		return;
+	}
 
-    //skip empty audio data
-    if (audio_data->samples.size() == 0){
-        printf("> warning: empty audio data - skipped.\n");
-        return;
-    }
+	// check if we can play this file:
+	while (playback_state != IDLE) {
+		printf("> player not ready yet, waiting for 10ms\n");
+		usleep(10 * 1000);
+	}
 
-    //check if we can play this file:
-    while(playback_state != IDLE){
-        printf("> player not ready yet, waiting for 10ms\n");
-        usleep(10*1000);
-    }
+	audio_format = extract_ao_format(audio_data);
 
-    audio_format = extract_ao_format(audio_data);
+	playback_requested = true;
 
-    playback_requested = true;
-
-    //wait for playback to start:
-    printf("> waiting for playback start...\n");
-    while(playback_requested){
-        usleep(1*1000);
-    }
-    printf("> playback running.\n");
+	// wait for playback to start:
+	printf("> waiting for playback start...\n");
+	while (playback_requested) {
+		usleep(1 * 1000);
+	}
+	printf("> playback running.\n");
 }
 
-
-ao_sample_format AudioPlayerLibAO::extract_ao_format(boost::shared_ptr<AudioData> audio){
-    ao_sample_format ao_format;
-
-    //get bits per sample
-    ao_format.bits = audio->sample_bit;
-    //bitrate
-    ao_format.rate = audio->sample_rate;
-    //endianess
-    ao_format.byte_format = audio->sample_big_endian?AO_FMT_BIG:AO_FMT_LITTLE;
-    //number of channels
-    ao_format.channels = audio->sample_channels;
-
-    //format matrix:
-    if (ao_format.channels == 1){
-        ao_format.matrix = (char *)"L";
-    }else if(ao_format.channels == 2){
-        ao_format.matrix = (char *)"L,R";
-    }else{
-        printf("> invalid AudioData channel count given. ignoring request\n");
-        throw runtime_error("AudioPlayerLibAO::extract_ao_format() unsupported number of audio channels given in AudioData");
-    }
-
-    printf("> AudioPlayerLibAO: format=%d rate=%d endianess=%d channels=%d\n", ao_format.bits, ao_format.rate, ao_format.byte_format, ao_format.channels);
-
-    return ao_format;
+ao_sample_format AudioPlayerLibAO::extract_ao_format(boost::shared_ptr<AudioData> audio) {
+	ao_sample_format ao_format;
+
+	// get bits per sample
+	ao_format.bits = audio->sample_bit;
+	// bitrate
+	ao_format.rate = audio->sample_rate;
+	// endianess
+	ao_format.byte_format = audio->sample_big_endian ? AO_FMT_BIG : AO_FMT_LITTLE;
+	// number of channels
+	ao_format.channels = audio->sample_channels;
+
+	// format matrix:
+	if (ao_format.channels == 1) {
+		ao_format.matrix = (char*)"L";
+	}
+	else if (ao_format.channels == 2) {
+		ao_format.matrix = (char*)"L,R";
+	}
+	else {
+		printf("> invalid AudioData channel count given. ignoring request\n");
+		throw runtime_error("AudioPlayerLibAO::extract_ao_format() unsupported number of audio channels given in AudioData");
+	}
+
+	printf("> AudioPlayerLibAO: format=%d rate=%d endianess=%d channels=%d\n", ao_format.bits, ao_format.rate,
+	       ao_format.byte_format, ao_format.channels);
+
+	return ao_format;
 }
 
-
-
-void AudioPlayerLibAO::playback_thread(){
-    printf("> playback thread started\n");
-    playback_state = IDLE;
-
-    while(playback_state != EXITING){
-        switch (playback_state){
-            default:
-            case(INITIALIZING):
-                //waiting to be ready
-                break;
-
-            case(IDLE):
-                //nothing to do, wait here until we are triggered to play!
-                if (playback_requested){
-                    printf("> AudioPlayer: loading\n");
-                    playback_state = LOADING;
-                }
-                break;
-
-            case(LOADING):
-                //check if we can play that format:
-                device = ao_open_live(driver, &audio_format, NULL /* no options */);
-
-                if (device == NULL){
-                    printf("> AudioPlayer: WARNING: can not open requested audio device. trying to fall back to default driver\n");
-                    driver = ao_default_driver_id();
-                    device = ao_open_live(driver, &audio_format, NULL /* no options */);
-                }
-
-                if (device == NULL){
-                    //failed to init device for format:
-                    printf("> AudioPlayer: WARNING: can not open audio device, not playing audio file!\n");
-                    playback_active = false;
-                    playback_requested = false;
-                    playback_state = IDLE;
-                    break;
-                }else{
-                    //ok we can now play the data
-                    printf("> AudioPlayer: playback started\n");
-                    //mark request as beeing processed
-                    playback_requested = false;
-                    //enter actual playing state
-                    playback_state = PLAYING;
-                    playback_active = true;
-
-                    ao_play(device, audio_data->samples.data(), audio_data->samples.size());
-                    printf("> AudioPlayer: finished playback\n");
-                }
-                break;
-
-            case(PLAYING):
-                //when we reach this case, the ao_play() call finished
-                //-> we can close this now:
-                ao_close(device);
-                playback_state = IDLE;
-                playback_active = false;
-                printf("> AudioPlayer: device closed\n");
-                break;
-
-            case(ERROR):
-                printf("> AudioPlayer ERROR! exiting\n");
-                exit(EXIT_FAILURE);
-                break;
-        }
-
-        //1ms delay to safe cpu time
-        usleep(1000);
-    }
-
-    //shutdown audio!
-    ao_shutdown();
-
-    //done
-    playback_state = CLOSED;
-
+void AudioPlayerLibAO::playback_thread() {
+	printf("> playback thread started\n");
+	playback_state = IDLE;
+
+	while (playback_state != EXITING) {
+		switch (playback_state) {
+			default:
+			case (INITIALIZING):
+				// waiting to be ready
+				break;
+
+			case (IDLE):
+				// nothing to do, wait here until we are triggered to play!
+				if (playback_requested) {
+					printf("> AudioPlayer: loading\n");
+					playback_state = LOADING;
+				}
+				break;
+
+			case (LOADING):
+				// check if we can play that format:
+				device = ao_open_live(driver, &audio_format, NULL /* no options */);
+
+				if (device == NULL) {
+					printf(
+					   "> AudioPlayer: WARNING: can not open requested audio device. trying to fall back to default driver\n");
+					driver = ao_default_driver_id();
+					device = ao_open_live(driver, &audio_format, NULL /* no options */);
+				}
+
+				if (device == NULL) {
+					// failed to init device for format:
+					printf("> AudioPlayer: WARNING: can not open audio device, not playing audio file!\n");
+					playback_active = false;
+					playback_requested = false;
+					playback_state = IDLE;
+					break;
+				}
+				else {
+					// ok we can now play the data
+					printf("> AudioPlayer: playback started\n");
+					// mark request as beeing processed
+					playback_requested = false;
+					// enter actual playing state
+					playback_state = PLAYING;
+					playback_active = true;
+
+					ao_play(device, audio_data->samples.data(), audio_data->samples.size());
+					printf("> AudioPlayer: finished playback\n");
+				}
+				break;
+
+			case (PLAYING):
+				// when we reach this case, the ao_play() call finished
+				//-> we can close this now:
+				ao_close(device);
+				playback_state = IDLE;
+				playback_active = false;
+				printf("> AudioPlayer: device closed\n");
+				break;
+
+			case (ERROR):
+				printf("> AudioPlayer ERROR! exiting\n");
+				exit(EXIT_FAILURE);
+				break;
+		}
+
+		// 1ms delay to safe cpu time
+		usleep(1000);
+	}
+
+	// shutdown audio!
+	ao_shutdown();
+
+	// done
+	playback_state = CLOSED;
 }
 
-AudioPlayerLibAO::~AudioPlayerLibAO(){
+AudioPlayerLibAO::~AudioPlayerLibAO() {
 }
