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/AudioPlayerRSB.cpp b/server/src/AudioPlayerRSB.cpp
index e96346d..ffe6439 100644
--- a/server/src/AudioPlayerRSB.cpp
+++ b/server/src/AudioPlayerRSB.cpp
@@ -1,30 +1,30 @@
 /*
-* 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 "AudioPlayerRSB.h"
 
@@ -37,155 +37,156 @@ using namespace std;
 using namespace rsb;
 using namespace boost;
 
+// new audio player with gievn device type (default is pulse)
+AudioPlayerRSB::AudioPlayerRSB(string driver) : AudioPlayer(driver) {
+	assert(driver.length() > 3);
 
-//new audio player with gievn device type (default is pulse)
-AudioPlayerRSB::AudioPlayerRSB(string driver): AudioPlayer(driver){
-    assert(driver.length() > 3);
+	string scope = driver.substr(3);
 
-    string scope = driver.substr(3);
+	printf("> using rsb for playback, scope = '%s'\n", scope.c_str());
 
-    printf("> using rsb for playback, scope = '%s'\n", scope.c_str());
+	printf("> registering converters\n");
+	rsb::converter::Converter<string>::Ptr soundChunkConverter(
+	   new rsb::converter::ProtocolBufferConverter<rst::audition::SoundChunk>());
+	rsb::converter::converterRepository<string>()->registerConverter(soundChunkConverter);
 
+	// first get a factory instance that is used to create RSB domain objects
+	Factory& factory = getFactory();
 
-    printf("> registering converters\n");
-    rsb::converter::Converter<string>::Ptr soundChunkConverter(new rsb::converter::ProtocolBufferConverter<rst::audition::SoundChunk>());
-    rsb::converter::converterRepository<string>()->registerConverter(soundChunkConverter);
+	// create informer
+	informer = factory.createInformer<rst::audition::SoundChunk>(scope);
 
-    //first get a factory instance that is used to create RSB domain objects
-    Factory &factory = getFactory();
-
-    //create informer
-    informer = factory.createInformer<rst::audition::SoundChunk> (scope);
-
-    //start audio playback thread:
-    playback_thread_ptr = new boost::thread(boost::bind(&AudioPlayerRSB::playback_thread, this));
+	// start audio playback thread:
+	playback_thread_ptr = new boost::thread(boost::bind(&AudioPlayerRSB::playback_thread, this));
 }
 
+// this will return once we start playing
+void AudioPlayerRSB::play(boost::shared_ptr<AudioData> _audio_data) {
+	audio_data = _audio_data;
 
-//this will return once we start playing
-void AudioPlayerRSB::play(boost::shared_ptr<AudioData> _audio_data){
-    audio_data = _audio_data;
-
-    printf("> AudioPlayerRSB: play() %d samples requested\n",(int)audio_data->samples.size());
+	printf("> AudioPlayerRSB: play() %d samples requested\n", (int)audio_data->samples.size());
 
-    //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);
+	}
 
-    //ok, we can play the audio. copy/setup data:
-    //audio_data_ptr = boost::shared_ptr<rst::audition::SoundChunk>(boost::make_shared<rst::audition::SoundChunk>(*audio_chunk));
-    playback_requested = true;
+	// ok, we can play the audio. copy/setup data:
+	// audio_data_ptr = boost::shared_ptr<rst::audition::SoundChunk>(boost::make_shared<rst::audition::SoundChunk>(*audio_chunk));
+	playback_requested = true;
 }
 
-
-void AudioPlayerRSB::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("> AudioPlayerRSB: loading\n");
-                    playback_state = LOADING;
-                }
-                break;
-
-            case(LOADING):{
-                //send the data
-                try{
-                    publish_audio_data();
-                }catch (std::exception e) {
-                        printf("> AudioPlayerRSB: WARNING: failed to call informer. audio playback probably failed\n> error message = %s",e.what());
-                        playback_active = false;
-                        playback_requested = false;
-                        playback_state = IDLE;
-                        break;
-                }
-
-                //add some delay to meet the delay until playback starts (FIXME: this should be determined!)
-                //usleep(100*1000); //100ms
-
-                //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;
-
-                //now we have to wait until the audio playback finished....
-                long sample_count = audio_data_ptr->sample_count();
-                int sampling_rate  = audio_data_ptr->rate();
-                double playback_time = (double)sample_count / (double)sampling_rate;
-                printf("> AudioPlayerRSB estimated playbacktime to %5.3lf seconds. will wait now...",playback_time);
-                boost::this_thread::sleep(boost::posix_time::milliseconds(1000.0 * playback_time));
-                printf("> AudioPlayerRSB finished waiting...\n");
-                break;
-            }
-
-            case(PLAYING):
-                //when we reach this case, the playback finshed
-                playback_state = IDLE;
-                playback_active = false;
-                printf("> AudioPlayerRSB: finished playback");
-                break;
-
-            case(ERROR):
-                printf("> AudioPlayerRSB ERROR! exiting\n");
-                exit(EXIT_FAILURE);
-                break;
-        }
-
-        //1ms delay to safe cpu time
-        usleep(1000);
-    }
-
-    //done
-    playback_state = CLOSED;
+void AudioPlayerRSB::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("> AudioPlayerRSB: loading\n");
+					playback_state = LOADING;
+				}
+				break;
+
+			case (LOADING):
+			{
+				// send the data
+				try {
+					publish_audio_data();
+				}
+				catch (std::exception e) {
+					printf(
+					   "> AudioPlayerRSB: WARNING: failed to call informer. audio playback probably failed\n> error message = %s",
+					   e.what());
+					playback_active = false;
+					playback_requested = false;
+					playback_state = IDLE;
+					break;
+				}
+
+				// add some delay to meet the delay until playback starts (FIXME: this should be determined!)
+				// usleep(100*1000); //100ms
+
+				// 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;
+
+				// now we have to wait until the audio playback finished....
+				long sample_count = audio_data_ptr->sample_count();
+				int sampling_rate = audio_data_ptr->rate();
+				double playback_time = (double)sample_count / (double)sampling_rate;
+				printf("> AudioPlayerRSB estimated playbacktime to %5.3lf seconds. will wait now...", playback_time);
+				boost::this_thread::sleep(boost::posix_time::milliseconds(1000.0 * playback_time));
+				printf("> AudioPlayerRSB finished waiting...\n");
+				break;
+			}
+
+			case (PLAYING):
+				// when we reach this case, the playback finshed
+				playback_state = IDLE;
+				playback_active = false;
+				printf("> AudioPlayerRSB: finished playback");
+				break;
+
+			case (ERROR):
+				printf("> AudioPlayerRSB ERROR! exiting\n");
+				exit(EXIT_FAILURE);
+				break;
+		}
+
+		// 1ms delay to safe cpu time
+		usleep(1000);
+	}
+
+	// done
+	playback_state = CLOSED;
 }
 
-void AudioPlayerRSB::publish_audio_data(){
-    boost::shared_ptr<rst::audition::SoundChunk> request(new rst::audition::SoundChunk());
-
-    request->set_channels(audio_data->sample_channels);
-    request->set_data(audio_data->samples.data());
-/*
-    if (audio_data.sample_big_endian){
-        request->set_endianness(rst::audition::SoundChunk_EndianNess_ENDIAN_BIG);
-    }else{
-        request->set_endianness(rst::audition::SoundChunk_EndianNess_ENDIAN_LITTLE);
-    }
-
-    request->set_rate(audio_data.sample_rate);
-    request->set_sample_count(audio_data.samples.size() / audio_data.sample_channels / (audio_data.sample_bit/8));
-
-    switch (audio_data.sample_bit){
-        case(8):
-            request->set_sample_type(audio_data.sample_signed?(rst::audition::SoundChunk::SAMPLE_S8):(rst::audition::SoundChunk::SAMPLE_U8));
-            break;
-        case(16):
-            request->set_sample_type(audio_data.sample_signed?(rst::audition::SoundChunk::SAMPLE_S16):(rst::audition::SoundChunk::SAMPLE_U16));
-            break;
-        case(24):
-            request->set_sample_type(audio_data.sample_signed?(rst::audition::SoundChunk::SAMPLE_S24):(rst::audition::SoundChunk::SAMPLE_U24));
-            break;
-        default:
-            throw runtime_error("AudioPlayerRSB::publish_audio_data() unsupported sample type bit width");
-    }
-*/
-    informer->publish(request);
+void AudioPlayerRSB::publish_audio_data() {
+	boost::shared_ptr<rst::audition::SoundChunk> request(new rst::audition::SoundChunk());
+
+	request->set_channels(audio_data->sample_channels);
+	request->set_data(audio_data->samples.data());
+	/*
+	    if (audio_data.sample_big_endian){
+	        request->set_endianness(rst::audition::SoundChunk_EndianNess_ENDIAN_BIG);
+	    }else{
+	        request->set_endianness(rst::audition::SoundChunk_EndianNess_ENDIAN_LITTLE);
+	    }
+
+	    request->set_rate(audio_data.sample_rate);
+	    request->set_sample_count(audio_data.samples.size() / audio_data.sample_channels / (audio_data.sample_bit/8));
+
+	    switch (audio_data.sample_bit){
+	        case(8):
+	            request->set_sample_type(audio_data.sample_signed?(rst::audition::SoundChunk::SAMPLE_S8):(rst::audition::SoundChunk::SAMPLE_U8));
+	            break;
+	        case(16):
+	            request->set_sample_type(audio_data.sample_signed?(rst::audition::SoundChunk::SAMPLE_S16):(rst::audition::SoundChunk::SAMPLE_U16));
+	            break;
+	        case(24):
+	            request->set_sample_type(audio_data.sample_signed?(rst::audition::SoundChunk::SAMPLE_S24):(rst::audition::SoundChunk::SAMPLE_U24));
+	            break;
+	        default:
+	            throw runtime_error("AudioPlayerRSB::publish_audio_data() unsupported sample type bit width");
+	    }
+	*/
+	informer->publish(request);
 }
 
-AudioPlayerRSB::~AudioPlayerRSB(){
+AudioPlayerRSB::~AudioPlayerRSB() {
 }
 
 #endif
