diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..0123055 --- /dev/null +++ b/.clang-format @@ -0,0 +1,94 @@ +# Copyright (c) 2017, Intel Corporation +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, +# are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, this +# list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation and/or +# other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors +# may be used to endorse or promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +# ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +--- +# The extra indent or outdent of access modifiers +AccessModifierOffset: -4 + +# Align parameters on the open bracket +AlignAfterOpenBracket: Align + +# Disallows contracting simple braced statements to a single line +AllowShortBlocksOnASingleLine: 'false' + +# Short case labels wont't be contracted to a single line +AllowShortCaseLabelsOnASingleLine: 'false' + +# Merge all inline functions fitting on a single line +AllowShortFunctionsOnASingleLine: 'Inline' + +# If (a) return; cannot be put on a single line +AllowShortIfStatementsOnASingleLine: 'false' + +# While (true) continue; cannot be put on a single line +AllowShortLoopsOnASingleLine: 'false' + +# Break after the template<...> of a template declaration. +AlwaysBreakTemplateDeclarations: 'true' + +# Configure each individual brace in BraceWrapping +BreakBeforeBraces: 'Custom' + +# Control of individual brace wrapping cases +BraceWrapping: { + AfterClass: 'true' + AfterControlStatement: 'false' + AfterEnum : 'true' + AfterFunction : 'true' + AfterNamespace : 'true' + AfterStruct : 'true' + AfterUnion : 'true' + BeforeCatch : 'false' + BeforeElse : 'false' + IndentBraces : 'false' +} + +# The column limit +ColumnLimit: '100' + +# The number of columns to use for indentation. +IndentWidth: '4' + +# Targeted language +Language: Cpp + +# No indentation for namespaces. +NamespaceIndentation: None + +# Pointer is aligned to right side +PointerAlignment: Right + +# High penalty to avoid line break just after return type +PenaltyReturnTypeOnItsOwnLine: 10000 + +# Treat 'catch' BDD macros as control instructions +ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH, GIVEN, WHEN, AND_WHEN, THEN, AND_THEN, + SECTION ] + +SortIncludes: 'false' +... diff --git a/.travis.yml b/.travis.yml index 69d6530..ea15961 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,14 +11,20 @@ env: addons: apt: + # Travis white list of ppa + # https://github.com/travis-ci/apt-source-whitelist/blob/master/ubuntu.json sources: - ubuntu-toolchain-r-test - george-edison55-precise-backports + - llvm-toolchain-precise-3.8 + # Travis white list of dpkg packages + # https://github.com/travis-ci/apt-package-whitelist/blob/master/ubuntu-precise packages: - g++-4.8 - cmake-data - cmake - libasound2-dev + - clang-format-3.8 before_install: - mkdir $CMAKE_PREFIX_PATH @@ -30,7 +36,12 @@ install: before_script: - export CC=gcc-4.8 CXX=g++-4.8 +# how to build script: + # Check coding style + - (git ls-files | grep -E '\.[ch](pp)?$' | xargs clang-format-3.8 -i && + git diff --exit-code || { git reset --hard; false; }) + - ( mkdir -p build/debug && cd build/debug && cmake -DCMAKE_BUILD_TYPE=Debug $TRAVIS_BUILD_DIR && make -j$(nproc) ) - ( mkdir build/release && cd build && diff --git a/base/AlsaCtlPortConfig.cpp b/base/AlsaCtlPortConfig.cpp index a799a0c..c4cf4f4 100644 --- a/base/AlsaCtlPortConfig.cpp +++ b/base/AlsaCtlPortConfig.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2015, Intel Corporation + * Copyright (c) 2011-2017, Intel Corporation * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, @@ -42,20 +42,14 @@ using std::string; AlsaCtlPortConfig::AlsaCtlPortConfig(const string &mappingValue, CInstanceConfigurableElement *instanceConfigurableElement, - const CMappingContext &context, - core::log::Logger& logger, + const CMappingContext &context, core::log::Logger &logger, const PortConfig &defaultPortConfig) - : base(mappingValue, - instanceConfigurableElement, - context, - logger), - _device(context.getItemAsInteger(AlsaCtlDevice)), - _portConfig(defaultPortConfig) + : base(mappingValue, instanceConfigurableElement, context, logger), + _device(context.getItemAsInteger(AlsaCtlDevice)), _portConfig(defaultPortConfig) { - } -bool AlsaCtlPortConfig::receiveFromHW(string &/*error*/) +bool AlsaCtlPortConfig::receiveFromHW(string & /*error*/) { blackboardWrite(&_portConfig, sizeof(_portConfig)); @@ -144,13 +138,12 @@ void AlsaCtlPortConfig::closeStream(StreamDirection streamDirection) } string AlsaCtlPortConfig::formatAlsaError(StreamDirection streamDirection, - const string &functionName, - const string &error) + const string &functionName, const string &error) { std::ostringstream stringStream; - stringStream << (streamDirection ? "Capture" : "Playback") << " " << - functionName << " error: " << error; + stringStream << (streamDirection ? "Capture" : "Playback") << " " << functionName + << " error: " << error; return stringStream.str(); } @@ -158,7 +151,6 @@ string AlsaCtlPortConfig::formatAlsaError(StreamDirection streamDirection, bool AlsaCtlPortConfig::isStreamEnabled(StreamDirection streamDirection) const { return _portConfig.isStreamEnabled[streamDirection] != 0; - } bool AlsaCtlPortConfig::isDeviceUpdateNeeded(const PortConfig &portConfig) const diff --git a/base/AlsaCtlPortConfig.hpp b/base/AlsaCtlPortConfig.hpp index a5783d2..bf58b86 100644 --- a/base/AlsaCtlPortConfig.hpp +++ b/base/AlsaCtlPortConfig.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2015, Intel Corporation + * Copyright (c) 2011-2017, Intel Corporation * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, @@ -45,23 +45,22 @@ class AlsaCtlPortConfig : public AlsaSubsystemObject struct PortConfig { uint8_t isStreamEnabled[2]; /**< [1] == Capture stream, [0] == Playback stream */ - uint8_t format; /**< S16LE,... */ - uint8_t channelNumber; /**< 1 == Mono.. */ - uint16_t sampleRate; /**< 16000, 48000... */ + uint8_t format; /**< S16LE,... */ + uint8_t channelNumber; /**< 1 == Mono.. */ + uint16_t sampleRate; /**< 16000, 48000... */ } __attribute__((packed)); public: /** Structure to convert alsa formats in tinyalsa formats */ struct FormatTranslation { - uint8_t formatAsNumerical; /**< Tiny alsa format value */ + uint8_t formatAsNumerical; /**< Tiny alsa format value */ std::string formatAsString; /**< Litteral value */ }; AlsaCtlPortConfig(const std::string &mappingValue, CInstanceConfigurableElement *instanceConfigurableElement, - const CMappingContext &contVext, - core::log::Logger& logger, + const CMappingContext &contVext, core::log::Logger &logger, const PortConfig &defaultPortConfig); protected: @@ -120,9 +119,8 @@ class AlsaCtlPortConfig : public AlsaSubsystemObject * * @return the string containing the error formatted */ - std::string formatAlsaError(StreamDirection streamDirection, - const std::string &functionName, - const std::string &error); + std::string formatAlsaError(StreamDirection streamDirection, const std::string &functionName, + const std::string &error); private: /** diff --git a/base/AlsaMappingKeys.hpp b/base/AlsaMappingKeys.hpp index b7f682d..848512b 100644 --- a/base/AlsaMappingKeys.hpp +++ b/base/AlsaMappingKeys.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2014, Intel Corporation + * Copyright (c) 2011-2017, Intel Corporation * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, @@ -44,4 +44,4 @@ enum AlsaItemType NbAlsaItemTypes }; -static const int gNbAlsaAmends (AlsaAmendEnd - AlsaAmend1 + 1); +static const int gNbAlsaAmends(AlsaAmendEnd - AlsaAmend1 + 1); diff --git a/base/AlsaSubsystem.hpp b/base/AlsaSubsystem.hpp index 17194f9..92a5aa2 100644 --- a/base/AlsaSubsystem.hpp +++ b/base/AlsaSubsystem.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2015, Intel Corporation + * Copyright (c) 2011-2017, Intel Corporation * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, @@ -41,7 +41,7 @@ class AlsaSubsystem : public CSubsystem { public: - AlsaSubsystem(const std::string &name, core::log::Logger& logger) : CSubsystem(name, logger) + AlsaSubsystem(const std::string &name, core::log::Logger &logger) : CSubsystem(name, logger) { // Provide mapping keys to upper layer addContextMappingKey("Card"); diff --git a/base/AlsaSubsystemObject.cpp b/base/AlsaSubsystemObject.cpp index f9df48a..e146358 100644 --- a/base/AlsaSubsystemObject.cpp +++ b/base/AlsaSubsystemObject.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2015, Intel Corporation + * Copyright (c) 2011-2017, Intel Corporation * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, @@ -46,26 +46,20 @@ const char AlsaSubsystemObject::_soundCardPath[] = "/proc/asound/"; AlsaSubsystemObject::AlsaSubsystemObject(const string &mappingValue, CInstanceConfigurableElement *instanceConfigurableElement, - const CMappingContext &context, - core::log::Logger& logger) - : base(instanceConfigurableElement, logger, mappingValue), - _cardName(context.getItem(AlsaCard)), + const CMappingContext &context, core::log::Logger &logger) + : base(instanceConfigurableElement, logger, mappingValue), _cardName(context.getItem(AlsaCard)), _cardIndex(getCardNumberByName(context.getItem(AlsaCard))) { - } AlsaSubsystemObject::AlsaSubsystemObject(const string &mappingValue, CInstanceConfigurableElement *instanceConfigurableElement, - core::log::Logger& logger, - uint32_t firstAmendKey, - uint32_t nbAmendKeys, - const CMappingContext &context) + core::log::Logger &logger, uint32_t firstAmendKey, + uint32_t nbAmendKeys, const CMappingContext &context) : base(instanceConfigurableElement, logger, mappingValue, firstAmendKey, nbAmendKeys, context), _cardName(context.getItem(AlsaCard)), _cardIndex(getCardNumberByName(context.getItem(AlsaCard))) { - } int32_t AlsaSubsystemObject::getCardNumberByName(const string &cardName) { diff --git a/base/AlsaSubsystemObject.hpp b/base/AlsaSubsystemObject.hpp index 56a5454..8421d6f 100644 --- a/base/AlsaSubsystemObject.hpp +++ b/base/AlsaSubsystemObject.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2015, Intel Corporation + * Copyright (c) 2011-2017, Intel Corporation * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, @@ -42,13 +42,10 @@ class AlsaSubsystemObject : public CFormattedSubsystemObject public: AlsaSubsystemObject(const std::string &mappingValue, CInstanceConfigurableElement *instanceConfigurableElement, - const CMappingContext &context, - core::log::Logger& logger); + const CMappingContext &context, core::log::Logger &logger); AlsaSubsystemObject(const std::string &strMappingValue, CInstanceConfigurableElement *instanceConfigurableElement, - core::log::Logger& logger, - uint32_t firstAmendKey, - uint32_t nbAmendKeys, + core::log::Logger &logger, uint32_t firstAmendKey, uint32_t nbAmendKeys, const CMappingContext &context); protected: diff --git a/base/AmixerControl.cpp b/base/AmixerControl.cpp index 7549639..ffd2faa 100644 --- a/base/AmixerControl.cpp +++ b/base/AmixerControl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2015, Intel Corporation + * Copyright (c) 2011-2017, Intel Corporation * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, @@ -44,14 +44,9 @@ AmixerControl::AmixerControl(const std::string &mappingValue, CInstanceConfigurableElement *instanceConfigurableElement, - const CMappingContext &context, - core::log::Logger& logger) - : base(mappingValue, instanceConfigurableElement, logger, - AlsaAmend1, - gNbAlsaAmends, - context), - _scalarSize(0), - _hasWrongElementTypeError(false), + const CMappingContext &context, core::log::Logger &logger) + : base(mappingValue, instanceConfigurableElement, logger, AlsaAmend1, gNbAlsaAmends, context), + _scalarSize(0), _hasWrongElementTypeError(false), _isDebugEnabled(context.iSet(AlsaDebugEnable)) { // Check we are able to handle elements (no exception support, defer the error) @@ -78,15 +73,10 @@ AmixerControl::AmixerControl(const std::string &mappingValue, AmixerControl::AmixerControl(const std::string &mappingValue, CInstanceConfigurableElement *instanceConfigurableElement, - const CMappingContext &context, - core::log::Logger& logger, + const CMappingContext &context, core::log::Logger &logger, uint32_t scalarSize) - : base(mappingValue, instanceConfigurableElement, logger, - AlsaAmend1, - gNbAlsaAmends, - context), - _scalarSize(scalarSize), - _hasWrongElementTypeError(false), + : base(mappingValue, instanceConfigurableElement, logger, AlsaAmend1, gNbAlsaAmends, context), + _scalarSize(scalarSize), _hasWrongElementTypeError(false), _isDebugEnabled(context.iSet(AlsaDebugEnable)) { } diff --git a/base/AmixerControl.hpp b/base/AmixerControl.hpp index a1d0cf9..9b7b7b9 100644 --- a/base/AmixerControl.hpp +++ b/base/AmixerControl.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2015, Intel Corporation + * Copyright (c) 2011-2017, Intel Corporation * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, @@ -52,8 +52,7 @@ class AmixerControl : public AlsaSubsystemObject */ AmixerControl(const std::string &mappingValue, CInstanceConfigurableElement *instanceConfigurableElement, - const CMappingContext &context, - core::log::Logger& logger); + const CMappingContext &context, core::log::Logger &logger); /** * AmixerControl Class constructor @@ -65,9 +64,7 @@ class AmixerControl : public AlsaSubsystemObject */ AmixerControl(const std::string &mappingValue, CInstanceConfigurableElement *instanceConfigurableElement, - const CMappingContext &context, - core::log::Logger& logger, - uint32_t scalarSize); + const CMappingContext &context, core::log::Logger &logger, uint32_t scalarSize); protected: virtual bool accessHW(bool receive, std::string &error) = 0; diff --git a/base/AmixerMutableVolume.hpp b/base/AmixerMutableVolume.hpp index a59ebda..9193a43 100644 --- a/base/AmixerMutableVolume.hpp +++ b/base/AmixerMutableVolume.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2015, Intel Corporation + * Copyright (c) 2011-2017, Intel Corporation * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, @@ -74,8 +74,7 @@ class AmixerMutableVolume : public SubsystemObjectBase */ AmixerMutableVolume(const std::string &mappingValue, CInstanceConfigurableElement *instConfigElement, - const CMappingContext &context, - core::log::Logger& logger) + const CMappingContext &context, core::log::Logger &logger) : SubsystemObjectBase(mappingValue, instConfigElement, context, logger), _volumeLevelConfigurableElement(NULL) { @@ -113,9 +112,7 @@ int AmixerMutableVolume::fromBlackboard() assert(volumeSize <= sizeof(MutableVolume)); // Be aware that this code does not work in big endian if volumeSize < sizeof(MutableVolume) - MutableVolume volume = { - false, 0 - }; + MutableVolume volume = {false, 0}; this->blackboardRead(&volume, volumeSize); // Take care of sign extension @@ -130,8 +127,6 @@ void AmixerMutableVolume::toBlackboard(int volumeLevel) assert(volumeSize <= sizeof(MutableVolume)); // Be aware that this code does not work in big endian if volumeSize < sizeof(MutableVolume) - const MutableVolume volume = { - false, volumeLevel - }; + const MutableVolume volume = {false, volumeLevel}; this->blackboardWrite(&volume, volumeSize); } diff --git a/legacy/LegacyAlsaCtlPortConfig.cpp b/legacy/LegacyAlsaCtlPortConfig.cpp index 604cdb0..fce6010 100644 --- a/legacy/LegacyAlsaCtlPortConfig.cpp +++ b/legacy/LegacyAlsaCtlPortConfig.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2015, Intel Corporation + * Copyright (c) 2011-2017, Intel Corporation * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, @@ -38,20 +38,14 @@ #define base AlsaCtlPortConfig const AlsaCtlPortConfig::PortConfig LegacyAlsaCtlPortConfig::_defaultPortConfig = { - { false, false }, - SND_PCM_FORMAT_S16_LE, - 2, - 48000 -}; + {false, false}, SND_PCM_FORMAT_S16_LE, 2, 48000}; const uint32_t LegacyAlsaCtlPortConfig::_latencyMicroSeconds = 500000; LegacyAlsaCtlPortConfig::LegacyAlsaCtlPortConfig( - const std::string &mappingValue, - CInstanceConfigurableElement *instanceConfigurableElement, - const CMappingContext &context, - core::log::Logger& logger) - : base(mappingValue, instanceConfigurableElement, context, logger, _defaultPortConfig) + const std::string &mappingValue, CInstanceConfigurableElement *instanceConfigurableElement, + const CMappingContext &context, core::log::Logger &logger) + : base(mappingValue, instanceConfigurableElement, context, logger, _defaultPortConfig) { // Init stream handle array _streamHandle[Playback] = NULL; @@ -63,11 +57,10 @@ LegacyAlsaCtlPortConfig::LegacyAlsaCtlPortConfig( // Create device name std::ostringstream streamName; - streamName << "hw:" << snd_card_get_index(cardIndex.c_str()) - << "," << context.getItem(AlsaCtlDevice); + streamName << "hw:" << snd_card_get_index(cardIndex.c_str()) << "," + << context.getItem(AlsaCtlDevice); _streamName = streamName.str(); - } bool LegacyAlsaCtlPortConfig::doOpenStream(StreamDirection streamDirection, std::string &error) @@ -76,10 +69,9 @@ bool LegacyAlsaCtlPortConfig::doOpenStream(StreamDirection streamDirection, std: int32_t errorId; if ((errorId = snd_pcm_open( - &streamHandle, - _streamName.c_str(), - streamDirection == Capture ? SND_PCM_STREAM_CAPTURE : SND_PCM_STREAM_PLAYBACK, - 0)) < 0) { + &streamHandle, _streamName.c_str(), + streamDirection == Capture ? SND_PCM_STREAM_CAPTURE : SND_PCM_STREAM_PLAYBACK, 0)) < + 0) { error = formatAlsaError(streamDirection, "open", snd_strerror(errorId)); @@ -88,13 +80,9 @@ bool LegacyAlsaCtlPortConfig::doOpenStream(StreamDirection streamDirection, std: const AlsaCtlPortConfig::PortConfig &portConfig = getPortConfig(); - if ((errorId = snd_pcm_set_params(streamHandle, - static_cast<_snd_pcm_format>(portConfig.format), - SND_PCM_ACCESS_RW_INTERLEAVED, - portConfig.channelNumber, - portConfig.sampleRate, - 0, - _latencyMicroSeconds)) < 0) { + if ((errorId = snd_pcm_set_params(streamHandle, static_cast<_snd_pcm_format>(portConfig.format), + SND_PCM_ACCESS_RW_INTERLEAVED, portConfig.channelNumber, + portConfig.sampleRate, 0, _latencyMicroSeconds)) < 0) { error = formatAlsaError(streamDirection, "set params", snd_strerror(errorId)); diff --git a/legacy/LegacyAlsaCtlPortConfig.hpp b/legacy/LegacyAlsaCtlPortConfig.hpp index 242a635..49a4dd3 100644 --- a/legacy/LegacyAlsaCtlPortConfig.hpp +++ b/legacy/LegacyAlsaCtlPortConfig.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2015, Intel Corporation + * Copyright (c) 2011-2017, Intel Corporation * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, @@ -47,8 +47,7 @@ class LegacyAlsaCtlPortConfig : public AlsaCtlPortConfig */ LegacyAlsaCtlPortConfig(const std::string &mappingValue, CInstanceConfigurableElement *instanceConfigurableElement, - const CMappingContext &context, - core::log::Logger& logger); + const CMappingContext &context, core::log::Logger &logger); protected: // Stream operations diff --git a/legacy/LegacyAlsaSubsystem.cpp b/legacy/LegacyAlsaSubsystem.cpp index e6bf8d4..8c89ed1 100644 --- a/legacy/LegacyAlsaSubsystem.cpp +++ b/legacy/LegacyAlsaSubsystem.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2015, Intel Corporation + * Copyright (c) 2011-2017, Intel Corporation * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, @@ -36,27 +36,19 @@ #include "AmixerMutableVolume.hpp" #include -LegacyAlsaSubsystem::LegacyAlsaSubsystem(const std::string &name, core::log::Logger& logger) : - AlsaSubsystem(name, logger) +LegacyAlsaSubsystem::LegacyAlsaSubsystem(const std::string &name, core::log::Logger &logger) + : AlsaSubsystem(name, logger) { // Provide creators to upper layer addSubsystemObjectFactory( - new TSubsystemObjectFactory("Control", 1 << AlsaCard) - ); + new TSubsystemObjectFactory("Control", 1 << AlsaCard)); addSubsystemObjectFactory( - new TSubsystemObjectFactory( - "ByteControl", 1 << AlsaCard) - ); - - addSubsystemObjectFactory( - new TSubsystemObjectFactory< - AmixerMutableVolume >("Volume", 1 << AlsaCard) - ); + new TSubsystemObjectFactory("ByteControl", 1 << AlsaCard)); + addSubsystemObjectFactory(new TSubsystemObjectFactory>( + "Volume", 1 << AlsaCard)); - addSubsystemObjectFactory( - new TSubsystemObjectFactory( - "PortConfig", (1 << AlsaCard) | (1 << AlsaCtlDevice)) - ); + addSubsystemObjectFactory(new TSubsystemObjectFactory( + "PortConfig", (1 << AlsaCard) | (1 << AlsaCtlDevice))); } diff --git a/legacy/LegacyAlsaSubsystem.hpp b/legacy/LegacyAlsaSubsystem.hpp index bd00640..729ba7b 100644 --- a/legacy/LegacyAlsaSubsystem.hpp +++ b/legacy/LegacyAlsaSubsystem.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2015, Intel Corporation + * Copyright (c) 2011-2017, Intel Corporation * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, @@ -36,5 +36,5 @@ class LegacyAlsaSubsystem : public AlsaSubsystem { public: - LegacyAlsaSubsystem(const std::string &name, core::log::Logger& logger); + LegacyAlsaSubsystem(const std::string &name, core::log::Logger &logger); }; diff --git a/legacy/LegacyAlsaSubsystemBuilder.cpp b/legacy/LegacyAlsaSubsystemBuilder.cpp index 1578847..53bff7c 100644 --- a/legacy/LegacyAlsaSubsystemBuilder.cpp +++ b/legacy/LegacyAlsaSubsystemBuilder.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2015, Intel Corporation + * Copyright (c) 2011-2017, Intel Corporation * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, @@ -31,8 +31,7 @@ #include #include "LegacyAlsaSubsystem.hpp" -extern "C" -{ +extern "C" { /** * Alsa subsystem builder * This function is called when the PFW parses a subsystem structure XML of type "ALSA". diff --git a/legacy/LegacyAmixerControl.cpp b/legacy/LegacyAmixerControl.cpp index 9171400..cc1e8a8 100644 --- a/legacy/LegacyAmixerControl.cpp +++ b/legacy/LegacyAmixerControl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2015, Intel Corporation + * Copyright (c) 2011-2017, Intel Corporation * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, @@ -46,23 +46,20 @@ /* from sound/asound.h, header is not compatible with alsa/asoundlib.h */ -struct snd_ctl_tlv { - unsigned int numid; /* control element numeric identification */ - unsigned int length; /* in bytes aligned to 4 */ - unsigned char tlv[]; /* first TLV */ +struct snd_ctl_tlv +{ + unsigned int numid; /* control element numeric identification */ + unsigned int length; /* in bytes aligned to 4 */ + unsigned char tlv[]; /* first TLV */ }; - #define base AmixerControl -LegacyAmixerControl::LegacyAmixerControl( - const std::string &mappingValue, - CInstanceConfigurableElement *instanceConfigurableElement, - const CMappingContext &context, - core::log::Logger& logger) +LegacyAmixerControl::LegacyAmixerControl(const std::string &mappingValue, + CInstanceConfigurableElement *instanceConfigurableElement, + const CMappingContext &context, core::log::Logger &logger) : base(mappingValue, instanceConfigurableElement, context, logger) { - } bool LegacyAmixerControl::accessHW(bool receive, std::string &error) @@ -145,8 +142,7 @@ bool LegacyAmixerControl::accessHW(bool receive, std::string &error) // Get info if ((ret = snd_ctl_elem_info(sndCtrl, info)) < 0) { - error = "ALSA: Unable to get element info " + controlName + - ": " + snd_strerror(ret); + error = "ALSA: Unable to get element info " + controlName + ": " + snd_strerror(ret); // Close sound control snd_ctl_close(sndCtrl); @@ -183,8 +179,7 @@ bool LegacyAmixerControl::accessHW(bool receive, std::string &error) if (receive) { // Special hook for TLV Bytes Control - if ((eType == SND_CTL_ELEM_TYPE_BYTES) && - snd_ctl_elem_info_is_tlv_readable(info)) { + if ((eType == SND_CTL_ELEM_TYPE_BYTES) && snd_ctl_elem_info_is_tlv_readable(info)) { std::vector rawTlv(sizeof(struct snd_ctl_tlv) + elementCount); @@ -194,8 +189,7 @@ bool LegacyAmixerControl::accessHW(bool receive, std::string &error) rawTlv.size()); if (ret < 0) { - error = "ALSA: Unable to read element " + controlName + - ": " + snd_strerror(ret); + error = "ALSA: Unable to read element " + controlName + ": " + snd_strerror(ret); } else { blackboardWrite(tlv->tlv, elementCount); @@ -210,8 +204,7 @@ bool LegacyAmixerControl::accessHW(bool receive, std::string &error) // Read element if ((ret = snd_ctl_elem_read(sndCtrl, control)) < 0) { - error = "ALSA: Unable to read element " + controlName + - ": " + snd_strerror(ret); + error = "ALSA: Unable to read element " + controlName + ": " + snd_strerror(ret); // Close sound control snd_ctl_close(sndCtrl); @@ -229,9 +222,11 @@ bool LegacyAmixerControl::accessHW(bool receive, std::string &error) // The "info" method has been shadowed by a local variable this->info() << "Reading alsa element " << controlName << ": " << std::accumulate(first, last, std::string{}, - [](const std::string& a, std::vector::value_type b) { - return a.empty() ? std::to_string(b) : a + ',' + std::to_string(b); - }); + [](const std::string &a, + std::vector::value_type b) { + return a.empty() ? std::to_string(b) + : a + ',' + std::to_string(b); + }); } blackboardWrite(data, elementCount); @@ -263,8 +258,8 @@ bool LegacyAmixerControl::accessHW(bool receive, std::string &error) if (isDebugEnabled()) { // The "info" method has been shadowed by a local variable - this->info() << "Reading alsa element " << controlName - << ", index " << index << " with value " << value; + this->info() << "Reading alsa element " << controlName << ", index " << index + << " with value " << value; } // Write data to blackboard (beware this code is OK on Little Endian machines only) @@ -275,8 +270,7 @@ bool LegacyAmixerControl::accessHW(bool receive, std::string &error) } else { // Special hook for TLV Bytes Control - if ((eType == SND_CTL_ELEM_TYPE_BYTES) && - snd_ctl_elem_info_is_tlv_writable(info)) { + if ((eType == SND_CTL_ELEM_TYPE_BYTES) && snd_ctl_elem_info_is_tlv_writable(info)) { std::vector rawTlv(sizeof(struct snd_ctl_tlv) + elementCount); @@ -290,8 +284,7 @@ bool LegacyAmixerControl::accessHW(bool receive, std::string &error) ret = snd_ctl_elem_tlv_write(sndCtrl, id, reinterpret_cast(tlv)); if (ret < 0) { - error = "ALSA: Unable to write element " + controlName + - ": " + snd_strerror(ret); + error = "ALSA: Unable to write element " + controlName + ": " + snd_strerror(ret); } // Close sound control @@ -310,10 +303,11 @@ bool LegacyAmixerControl::accessHW(bool receive, std::string &error) // The "info" method has been shadowed by a local variable this->info() << "Writing alsa element " << controlName << ": " << std::accumulate(begin(rawData), end(rawData), std::string{}, - [](const std::string& a, std::vector::value_type b) { - return a.empty() ? std::to_string(b) : a + ',' + std::to_string(b); - }); - + [](const std::string &a, + std::vector::value_type b) { + return a.empty() ? std::to_string(b) + : a + ',' + std::to_string(b); + }); } snd_ctl_elem_set_bytes(control, rawData.data(), elementCount); @@ -328,8 +322,8 @@ bool LegacyAmixerControl::accessHW(bool receive, std::string &error) if (isDebugEnabled()) { // The "info" method has been shadowed by a local variable - this->info() << "Writing alsa element " << controlName - << ", index " << index << " with value " << value; + this->info() << "Writing alsa element " << controlName << ", index " << index + << " with value " << value; } switch (eType) { @@ -347,7 +341,7 @@ bool LegacyAmixerControl::accessHW(bool receive, std::string &error) break; default: error = "ALSA: Unknown control element type while writing alsa element " + - controlName; + controlName; return false; } } @@ -356,9 +350,7 @@ bool LegacyAmixerControl::accessHW(bool receive, std::string &error) // Write element if ((ret = snd_ctl_elem_write(sndCtrl, control)) < 0) { - error = "ALSA: Unable to write element " + controlName + - ": " + snd_strerror(ret); - + error = "ALSA: Unable to write element " + controlName + ": " + snd_strerror(ret); // Close sound control snd_ctl_close(sndCtrl); diff --git a/legacy/LegacyAmixerControl.hpp b/legacy/LegacyAmixerControl.hpp index 95a66f6..f98d1f3 100644 --- a/legacy/LegacyAmixerControl.hpp +++ b/legacy/LegacyAmixerControl.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2015, Intel Corporation + * Copyright (c) 2011-2017, Intel Corporation * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, @@ -45,8 +45,7 @@ class LegacyAmixerControl : public AmixerControl */ LegacyAmixerControl(const std::string &mappingValue, CInstanceConfigurableElement *instanceConfigurableElement, - const CMappingContext &context, - core::log::Logger& logger); + const CMappingContext &context, core::log::Logger &logger); protected: virtual bool accessHW(bool receive, std::string &error); diff --git a/tinyalsa/TinyAlsaCtlPortConfig.cpp b/tinyalsa/TinyAlsaCtlPortConfig.cpp index 51de876..723d73a 100644 --- a/tinyalsa/TinyAlsaCtlPortConfig.cpp +++ b/tinyalsa/TinyAlsaCtlPortConfig.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2016, Intel Corporation + * Copyright (c) 2011-2017, Intel Corporation * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, @@ -43,34 +43,28 @@ const int TinyAlsaCtlPortConfig::_nbRingBuffer = 2; const AlsaCtlPortConfig::FormatTranslation pcmFormatTranslationTable[] = { // TinyAlsa Value, // Litteral Value, // Alsa Value - { std::numeric_limits::max(), "PCM_FORMAT_S8" }, // SND_PCM_FORMAT_S8 - { std::numeric_limits::max(), "PCM_FORMAT_U8" }, // SND_PCM_FORMAT_U8 - { PCM_FORMAT_S16_LE , "PCM_FORMAT_S16_LE" }, // SND_PCM_FORMAT_S16_LE - { std::numeric_limits::max(), "PCM_FORMAT_S16_BE" }, // SND_PCM_FORMAT_S16_BE - { std::numeric_limits::max(), "PCM_FORMAT_U16_LE" }, // SND_PCM_FORMAT_U16_LE - { std::numeric_limits::max(), "PCM_FORMAT_U16_BE" }, // SND_PCM_FORMAT_U16_BE - { PCM_FORMAT_S24_LE , "PCM_FORMAT_S24_LE" }, // SND_PCM_FORMAT_S24_LE - { std::numeric_limits::max(), "PCM_FORMAT_S24_BE" }, // SND_PCM_FORMAT_S24_BE - { std::numeric_limits::max(), "PCM_FORMAT_U24_LE" }, // SND_PCM_FORMAT_U24_LE - { std::numeric_limits::max(), "PCM_FORMAT_U24_BE" }, // SND_PCM_FORMAT_U24_BE - { PCM_FORMAT_S32_LE , "PCM_FORMAT_S32_LE" } // SND_PCM_FORMAT_S32_LE + {std::numeric_limits::max(), "PCM_FORMAT_S8"}, // SND_PCM_FORMAT_S8 + {std::numeric_limits::max(), "PCM_FORMAT_U8"}, // SND_PCM_FORMAT_U8 + {PCM_FORMAT_S16_LE, "PCM_FORMAT_S16_LE"}, // SND_PCM_FORMAT_S16_LE + {std::numeric_limits::max(), "PCM_FORMAT_S16_BE"}, // SND_PCM_FORMAT_S16_BE + {std::numeric_limits::max(), "PCM_FORMAT_U16_LE"}, // SND_PCM_FORMAT_U16_LE + {std::numeric_limits::max(), "PCM_FORMAT_U16_BE"}, // SND_PCM_FORMAT_U16_BE + {PCM_FORMAT_S24_LE, "PCM_FORMAT_S24_LE"}, // SND_PCM_FORMAT_S24_LE + {std::numeric_limits::max(), "PCM_FORMAT_S24_BE"}, // SND_PCM_FORMAT_S24_BE + {std::numeric_limits::max(), "PCM_FORMAT_U24_LE"}, // SND_PCM_FORMAT_U24_LE + {std::numeric_limits::max(), "PCM_FORMAT_U24_BE"}, // SND_PCM_FORMAT_U24_BE + {PCM_FORMAT_S32_LE, "PCM_FORMAT_S32_LE"} // SND_PCM_FORMAT_S32_LE }; const size_t pcmFormatTranslationTableSize = sizeof(pcmFormatTranslationTable) / sizeof(pcmFormatTranslationTable[0]); const AlsaCtlPortConfig::PortConfig TinyAlsaCtlPortConfig::_defaultPortConfig = { - { false, false }, - PCM_FORMAT_S16_LE, - 2, - 48000 -}; + {false, false}, PCM_FORMAT_S16_LE, 2, 48000}; TinyAlsaCtlPortConfig::TinyAlsaCtlPortConfig( - const std::string &mappingValue, - CInstanceConfigurableElement *instanceConfigurableElement, - const CMappingContext &context, - core::log::Logger& logger) + const std::string &mappingValue, CInstanceConfigurableElement *instanceConfigurableElement, + const CMappingContext &context, core::log::Logger &logger) : base(mappingValue, instanceConfigurableElement, context, logger, _defaultPortConfig) { // Init stream handle array @@ -109,19 +103,17 @@ bool TinyAlsaCtlPortConfig::doOpenStream(StreamDirection streamDirection, std::s pcmConfig.format = static_cast(format); - pcmConfig.period_size = _periodTimeMs * pcmConfig.rate / _msPerSec; - pcmConfig.period_count = _nbRingBuffer; - pcmConfig.start_threshold = 0; - pcmConfig.stop_threshold = 0; + pcmConfig.period_size = _periodTimeMs * pcmConfig.rate / _msPerSec; + pcmConfig.period_count = _nbRingBuffer; + pcmConfig.start_threshold = 0; + pcmConfig.stop_threshold = 0; pcmConfig.silence_threshold = 0; - pcmConfig.silence_size = 0; - pcmConfig.avail_min = 0; + pcmConfig.silence_size = 0; + pcmConfig.avail_min = 0; // Open and configure - streamHandle = pcm_open(getCardNumber(), - getDeviceNumber(), - streamDirection == Capture ? PCM_IN : PCM_OUT, - &pcmConfig); + streamHandle = pcm_open(getCardNumber(), getDeviceNumber(), + streamDirection == Capture ? PCM_IN : PCM_OUT, &pcmConfig); // Prepare the stream if (!pcm_is_ready(streamHandle) || (pcm_prepare(streamHandle) != 0)) { diff --git a/tinyalsa/TinyAlsaCtlPortConfig.hpp b/tinyalsa/TinyAlsaCtlPortConfig.hpp index 328f697..bde39ff 100644 --- a/tinyalsa/TinyAlsaCtlPortConfig.hpp +++ b/tinyalsa/TinyAlsaCtlPortConfig.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2015, Intel Corporation + * Copyright (c) 2011-2017, Intel Corporation * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, @@ -47,8 +47,7 @@ class TinyAlsaCtlPortConfig : public AlsaCtlPortConfig */ TinyAlsaCtlPortConfig(const std::string &mappingValue, CInstanceConfigurableElement *instanceConfigurableElement, - const CMappingContext &context, - core::log::Logger& logger); + const CMappingContext &context, core::log::Logger &logger); protected: // Stream operations diff --git a/tinyalsa/TinyAlsaSubsystem.cpp b/tinyalsa/TinyAlsaSubsystem.cpp index 70b4ad5..a33ebca 100644 --- a/tinyalsa/TinyAlsaSubsystem.cpp +++ b/tinyalsa/TinyAlsaSubsystem.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2015, Intel Corporation + * Copyright (c) 2011-2017, Intel Corporation * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, @@ -37,29 +37,22 @@ #include "AmixerMutableVolume.hpp" #include -TinyAlsaSubsystem::TinyAlsaSubsystem(const std::string &name, core::log::Logger& logger) : - AlsaSubsystem(name, logger), mMixers() +TinyAlsaSubsystem::TinyAlsaSubsystem(const std::string &name, core::log::Logger &logger) + : AlsaSubsystem(name, logger), mMixers() { // Provide creators to upper layer addSubsystemObjectFactory( - new TSubsystemObjectFactory("Control", 1 << AlsaCard) - ); + new TSubsystemObjectFactory("Control", 1 << AlsaCard)); addSubsystemObjectFactory( - new TSubsystemObjectFactory( - "ByteControl", 1 << AlsaCard) - ); + new TSubsystemObjectFactory("ByteControl", 1 << AlsaCard)); addSubsystemObjectFactory( - new TSubsystemObjectFactory< - AmixerMutableVolume >("Volume", 1 << AlsaCard) - ); + new TSubsystemObjectFactory>("Volume", + 1 << AlsaCard)); - - addSubsystemObjectFactory( - new TSubsystemObjectFactory( - "PortConfig", (1 << AlsaCard) | (1 << AlsaCtlDevice)) - ); + addSubsystemObjectFactory(new TSubsystemObjectFactory( + "PortConfig", (1 << AlsaCard) | (1 << AlsaCtlDevice))); } TinyAlsaSubsystem::~TinyAlsaSubsystem() diff --git a/tinyalsa/TinyAlsaSubsystem.hpp b/tinyalsa/TinyAlsaSubsystem.hpp index d5d302c..fa2e7d7 100644 --- a/tinyalsa/TinyAlsaSubsystem.hpp +++ b/tinyalsa/TinyAlsaSubsystem.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2015, Intel Corporation + * Copyright (c) 2011-2017, Intel Corporation * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, @@ -38,7 +38,7 @@ class TinyAlsaSubsystem : public AlsaSubsystem { public: - TinyAlsaSubsystem(const std::string &name, core::log::Logger& logger); + TinyAlsaSubsystem(const std::string &name, core::log::Logger &logger); ~TinyAlsaSubsystem(); /** diff --git a/tinyalsa/TinyAlsaSubsystemBuilder.cpp b/tinyalsa/TinyAlsaSubsystemBuilder.cpp index d627b1c..1fdfd32 100644 --- a/tinyalsa/TinyAlsaSubsystemBuilder.cpp +++ b/tinyalsa/TinyAlsaSubsystemBuilder.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2015, Intel Corporation + * Copyright (c) 2011-2017, Intel Corporation * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, @@ -31,15 +31,14 @@ #include #include "TinyAlsaSubsystem.hpp" -extern "C" -{ +extern "C" { /** * TinyAmixer subsystem builder * This function is called when the PFW parses a subsystem structure XML of type "ALSA". * It will then create an TinyAMixer Subsystem */ void PARAMETER_FRAMEWORK_PLUGIN_ENTRYPOINT_V1(CSubsystemLibrary *subsystemLibrary, - core::log::Logger&) + core::log::Logger &logger) { subsystemLibrary->addElementBuilder( "ALSA", new TLoggingElementBuilderTemplate(logger)); diff --git a/tinyalsa/TinyAmixerControl.cpp b/tinyalsa/TinyAmixerControl.cpp index 6d76db4..22ea61e 100644 --- a/tinyalsa/TinyAmixerControl.cpp +++ b/tinyalsa/TinyAmixerControl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2016, Intel Corporation + * Copyright (c) 2011-2017, Intel Corporation * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, @@ -47,8 +47,7 @@ extern "C" void __gcov_flush(); TinyAmixerControl::TinyAmixerControl(const std::string &mappingValue, CInstanceConfigurableElement *instanceConfigurableElement, - const CMappingContext &context, - core::log::Logger& logger) + const CMappingContext &context, core::log::Logger &logger) : base(mappingValue, instanceConfigurableElement, context, logger) { #ifdef __USE_GCOV__ @@ -58,8 +57,7 @@ TinyAmixerControl::TinyAmixerControl(const std::string &mappingValue, TinyAmixerControl::TinyAmixerControl(const std::string &mappingValue, CInstanceConfigurableElement *instanceConfigurableElement, - const CMappingContext &context, - core::log::Logger& logger, + const CMappingContext &context, core::log::Logger &logger, uint32_t scalarSize) : base(mappingValue, instanceConfigurableElement, context, logger, scalarSize) { @@ -100,8 +98,8 @@ bool TinyAmixerControl::accessHW(bool receive, std::string &error) // Open alsa mixer // getMixerHandle is non-const; we need to forcefully remove the constness // then, we need to cast the generic subsystem into a TinyAlsaSubsystem. - mixer = static_cast( - const_cast(getSubsystem()))->getMixerHandle(cardIndex); + mixer = static_cast(const_cast(getSubsystem())) + ->getMixerHandle(cardIndex); if (!mixer) { @@ -112,7 +110,7 @@ bool TinyAmixerControl::accessHW(bool receive, std::string &error) // Get control handle if (isdigit(controlName[0])) { int32_t controlNumber = 0; - convertTo(controlName,controlNumber); + convertTo(controlName, controlNumber); mixerControl = mixer_get_ctl(mixer, controlNumber); } else { @@ -150,7 +148,6 @@ bool TinyAmixerControl::accessHW(bool receive, std::string &error) } else { success = writeControl(mixerControl, elementCount, error); - } return success; diff --git a/tinyalsa/TinyAmixerControl.hpp b/tinyalsa/TinyAmixerControl.hpp index e1fc4dd..09dc446 100644 --- a/tinyalsa/TinyAmixerControl.hpp +++ b/tinyalsa/TinyAmixerControl.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2015, Intel Corporation + * Copyright (c) 2011-2017, Intel Corporation * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, @@ -48,8 +48,7 @@ class TinyAmixerControl : public AmixerControl */ TinyAmixerControl(const std::string &mappingValue, CInstanceConfigurableElement *instanceConfigurableElement, - const CMappingContext &context, - core::log::Logger& logger); + const CMappingContext &context, core::log::Logger &logger); /** * TinyAMixerControl Class constructor @@ -61,8 +60,7 @@ class TinyAmixerControl : public AmixerControl */ TinyAmixerControl(const std::string &mappingValue, CInstanceConfigurableElement *instanceConfigurableElement, - const CMappingContext &context, - core::log::Logger& logger, + const CMappingContext &context, core::log::Logger &logger, uint32_t scalarSize); protected: @@ -86,8 +84,7 @@ class TinyAmixerControl : public AmixerControl * * @return true if no error */ - virtual bool readControl(struct mixer_ctl *mixerControl, - size_t elementCount, + virtual bool readControl(struct mixer_ctl *mixerControl, size_t elementCount, std::string &error) = 0; /** @@ -99,7 +96,6 @@ class TinyAmixerControl : public AmixerControl * * @return true if no error */ - virtual bool writeControl(struct mixer_ctl *mixerControl, - size_t elementCount, + virtual bool writeControl(struct mixer_ctl *mixerControl, size_t elementCount, std::string &error) = 0; }; diff --git a/tinyalsa/TinyAmixerControlArray.cpp b/tinyalsa/TinyAmixerControlArray.cpp index 7b40097..0408559 100644 --- a/tinyalsa/TinyAmixerControlArray.cpp +++ b/tinyalsa/TinyAmixerControlArray.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2015, Intel Corporation + * Copyright (c) 2011-2017, Intel Corporation * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, @@ -41,16 +41,13 @@ #define maxLogLine 64 TinyAmixerControlArray::TinyAmixerControlArray( - const std::string &mappingValue, - CInstanceConfigurableElement *instanceConfigurableElement, - const CMappingContext &context, - core::log::Logger& logger) - : base(mappingValue, instanceConfigurableElement, context, logger, _byteScalarSize) + const std::string &mappingValue, CInstanceConfigurableElement *instanceConfigurableElement, + const CMappingContext &context, core::log::Logger &logger) + : base(mappingValue, instanceConfigurableElement, context, logger, _byteScalarSize) { } -int TinyAmixerControlArray::doGetArrayMixer(struct mixer_ctl *mixerControl, - void *array, +int TinyAmixerControlArray::doGetArrayMixer(struct mixer_ctl *mixerControl, void *array, size_t elementCount) { int ret = mixer_ctl_get_array(mixerControl, array, elementCount); @@ -62,8 +59,7 @@ int TinyAmixerControlArray::doGetArrayMixer(struct mixer_ctl *mixerControl, return ret; } -int TinyAmixerControlArray::doSetArrayMixer(struct mixer_ctl *mixerControl, - const void *array, +int TinyAmixerControlArray::doSetArrayMixer(struct mixer_ctl *mixerControl, const void *array, size_t elementCount) { if (isDebugEnabled()) { @@ -83,24 +79,22 @@ int TinyAmixerControlArray::setArrayMixer(struct mixer_ctl *mixerControl, size_t return doSetArrayMixer(mixerControl, getBlackboardLocation(), elementCount); } -bool TinyAmixerControlArray::readControl(struct mixer_ctl *mixerControl, - size_t elementCount, +bool TinyAmixerControlArray::readControl(struct mixer_ctl *mixerControl, size_t elementCount, std::string &error) { int err; if ((err = getArrayMixer(mixerControl, elementCount)) < 0) { - error = "Failed to read value in mixer control: " + getControlName() + ": " + - strerror(-err); + error = + "Failed to read value in mixer control: " + getControlName() + ": " + strerror(-err); return false; } return true; } -bool TinyAmixerControlArray::writeControl(struct mixer_ctl *mixerControl, - size_t elementCount, +bool TinyAmixerControlArray::writeControl(struct mixer_ctl *mixerControl, size_t elementCount, std::string &error) { int err; @@ -108,8 +102,8 @@ bool TinyAmixerControlArray::writeControl(struct mixer_ctl *mixerControl, // Write element if ((err = setArrayMixer(mixerControl, elementCount)) < 0) { - error = "Failed to write value in mixer control: " + getControlName() + ": " + - strerror(-err); + error = + "Failed to write value in mixer control: " + getControlName() + ": " + strerror(-err); return false; } @@ -122,8 +116,7 @@ void TinyAmixerControlArray::displayAndCleanString(std::stringstream &stringValu stringValue.str(std::string()); } -void TinyAmixerControlArray::logControlValues(bool receive, - const void *array, +void TinyAmixerControlArray::logControlValues(bool receive, const void *array, size_t elementCount) const { const unsigned char *buffer = reinterpret_cast(array); diff --git a/tinyalsa/TinyAmixerControlArray.hpp b/tinyalsa/TinyAmixerControlArray.hpp index 01d87d1..eb15f49 100644 --- a/tinyalsa/TinyAmixerControlArray.hpp +++ b/tinyalsa/TinyAmixerControlArray.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2015, Intel Corporation + * Copyright (c) 2011-2017, Intel Corporation * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, @@ -47,16 +47,13 @@ class TinyAmixerControlArray : public TinyAmixerControl */ TinyAmixerControlArray(const std::string &mappingValue, CInstanceConfigurableElement *instanceConfigurableElement, - const CMappingContext &context, - core::log::Logger& logger); + const CMappingContext &context, core::log::Logger &logger); protected: - virtual bool readControl(struct mixer_ctl *mixerControl, - size_t elementCount, + virtual bool readControl(struct mixer_ctl *mixerControl, size_t elementCount, std::string &error); - virtual bool writeControl(struct mixer_ctl *mixerControl, - size_t elementCount, + virtual bool writeControl(struct mixer_ctl *mixerControl, size_t elementCount, std::string &error); /** diff --git a/tinyalsa/TinyAmixerControlValue.cpp b/tinyalsa/TinyAmixerControlValue.cpp index c57bc14..93de20c 100644 --- a/tinyalsa/TinyAmixerControlValue.cpp +++ b/tinyalsa/TinyAmixerControlValue.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2015, Intel Corporation + * Copyright (c) 2011-2017, Intel Corporation * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, @@ -40,16 +40,13 @@ #define base TinyAmixerControl TinyAmixerControlValue::TinyAmixerControlValue( - const std::string &mappingValue, - CInstanceConfigurableElement *instanceConfigurableElement, - const CMappingContext &context, - core::log::Logger& logger) + const std::string &mappingValue, CInstanceConfigurableElement *instanceConfigurableElement, + const CMappingContext &context, core::log::Logger &logger) : base(mappingValue, instanceConfigurableElement, context, logger) { } -bool TinyAmixerControlValue::readControl(struct mixer_ctl *mixerControl, - size_t elementCount, +bool TinyAmixerControlValue::readControl(struct mixer_ctl *mixerControl, size_t elementCount, std::string &error) { uint32_t elementNumber; @@ -67,8 +64,8 @@ bool TinyAmixerControlValue::readControl(struct mixer_ctl *mixerControl, if (isDebugEnabled()) { - info() << "Reading alsa element " << getControlName() - << ", index " << elementNumber << " with value " << value; + info() << "Reading alsa element " << getControlName() << ", index " << elementNumber + << " with value " << value; } toBlackboard(value); @@ -76,8 +73,7 @@ bool TinyAmixerControlValue::readControl(struct mixer_ctl *mixerControl, return true; } -bool TinyAmixerControlValue::writeControl(struct mixer_ctl *mixerControl, - size_t elementCount, +bool TinyAmixerControlValue::writeControl(struct mixer_ctl *mixerControl, size_t elementCount, std::string &error) { uint32_t elementNumber; @@ -93,8 +89,8 @@ bool TinyAmixerControlValue::writeControl(struct mixer_ctl *mixerControl, if (isDebugEnabled()) { - info() << "Writing alsa element " << getControlName() - << ", index " << elementNumber << " with value " << value; + info() << "Writing alsa element " << getControlName() << ", index " << elementNumber + << " with value " << value; } // Write element diff --git a/tinyalsa/TinyAmixerControlValue.hpp b/tinyalsa/TinyAmixerControlValue.hpp index 427f3db..e8d69a6 100644 --- a/tinyalsa/TinyAmixerControlValue.hpp +++ b/tinyalsa/TinyAmixerControlValue.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011-2015, Intel Corporation + * Copyright (c) 2011-2017, Intel Corporation * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, @@ -47,15 +47,12 @@ class TinyAmixerControlValue : public TinyAmixerControl */ TinyAmixerControlValue(const std::string &mappingValue, CInstanceConfigurableElement *instanceConfigurableElement, - const CMappingContext &context, - core::log::Logger& logger); + const CMappingContext &context, core::log::Logger &logger); protected: - virtual bool readControl(struct mixer_ctl *mixerControl, - size_t elementCount, + virtual bool readControl(struct mixer_ctl *mixerControl, size_t elementCount, std::string &error); - virtual bool writeControl(struct mixer_ctl *mixerControl, - size_t elementCount, + virtual bool writeControl(struct mixer_ctl *mixerControl, size_t elementCount, std::string &error); };