Skip to content
This repository has been archived by the owner on Aug 5, 2022. It is now read-only.

tinyalsa: Fix tinyalsa plugin build issue for Android. #31

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
94 changes: 94 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -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'
...
11 changes: 11 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 &&
Expand Down
24 changes: 8 additions & 16 deletions base/AlsaCtlPortConfig.cpp
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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));

Expand Down Expand Up @@ -144,21 +138,19 @@ 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();
}

bool AlsaCtlPortConfig::isStreamEnabled(StreamDirection streamDirection) const
{
return _portConfig.isStreamEnabled[streamDirection] != 0;

}

bool AlsaCtlPortConfig::isDeviceUpdateNeeded(const PortConfig &portConfig) const
Expand Down
18 changes: 8 additions & 10 deletions base/AlsaCtlPortConfig.hpp
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
/**
Expand Down
4 changes: 2 additions & 2 deletions base/AlsaMappingKeys.hpp
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -44,4 +44,4 @@ enum AlsaItemType
NbAlsaItemTypes
};

static const int gNbAlsaAmends (AlsaAmendEnd - AlsaAmend1 + 1);
static const int gNbAlsaAmends(AlsaAmendEnd - AlsaAmend1 + 1);
4 changes: 2 additions & 2 deletions base/AlsaSubsystem.hpp
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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");
Expand Down
16 changes: 5 additions & 11 deletions base/AlsaSubsystemObject.cpp
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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)
{
Expand Down
9 changes: 3 additions & 6 deletions base/AlsaSubsystemObject.hpp
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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:
Expand Down
24 changes: 7 additions & 17 deletions base/AmixerControl.cpp
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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)
Expand All @@ -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))
{
}
Expand Down
9 changes: 3 additions & 6 deletions base/AmixerControl.hpp
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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
Expand All @@ -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;
Expand Down
Loading