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

Commit

Permalink
Merge pull request #17 from 01org/adapt-to-v3-api
Browse files Browse the repository at this point in the history
Update to Parameter Framework 3.0 API

PF 3.0 provides a new logging API and a new entry-point API.

It also makes it necessary to compile using C++11.

This patch update the filesystem plugin to let it compile against the new PF.
  • Loading branch information
dawagner committed Oct 20, 2015
2 parents 13be58c + 14ff848 commit 251c537
Show file tree
Hide file tree
Showing 28 changed files with 146 additions and 122 deletions.
20 changes: 8 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2011-2014, Intel Corporation
# Copyright (c) 2011-2015, Intel Corporation
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
Expand Down Expand Up @@ -31,23 +31,19 @@ cmake_minimum_required(VERSION 2.8)

project(parameter-framework-plugins-alsa)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wall -Wextra")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Werror -Wall -Wextra")

#
# Find PFW libraries and include directories
#
find_path(PFW_CORE_ROOT_DIR NAMES include/parameter/plugin/Subsystem.h)
find_path(PFW_INCLUDE_ROOT NAMES parameter/plugin/Plugin.h)

find_library(PFW_CORE_LIBRARY NAMES parameter
HINTS ${PFW_CORE_ROOT_DIR}/lib)
find_library(PFW_CORE_LIBRARY NAMES parameter)

find_path(PFW_CORE_INCLUDE_DIR NAMES Subsystem.h
HINTS ${PFW_CORE_ROOT_DIR}/include/parameter/plugin)
find_path(PFW_XMLSERIALIZER_INCLUDE_DIR NAMES XmlSink.h
HINTS ${PFW_CORE_ROOT_DIR}/include/xmlserializer)

set(PFW_INCLUDE_DIRS ${PFW_CORE_INCLUDE_DIR} ${PFW_XMLSERIALIZER_INCLUDE_DIR})
set(PFW_LIBRARIES ${PFW_CORE_LIBRARY})
set(PFW_INCLUDE_DIRS
${PFW_INCLUDE_ROOT}/parameter/plugin
${PFW_INCLUDE_ROOT}/xmlserializer
${PFW_INCLUDE_ROOT}/utility)

#
# Find (regular) alsa-lib
Expand Down
6 changes: 4 additions & 2 deletions base/AlsaCtlPortConfig.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011-2014, Intel Corporation
* Copyright (c) 2011-2015, Intel Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
Expand Down Expand Up @@ -43,10 +43,12 @@ using std::string;
AlsaCtlPortConfig::AlsaCtlPortConfig(const string &mappingValue,
CInstanceConfigurableElement *instanceConfigurableElement,
const CMappingContext &context,
core::log::Logger& logger,
const PortConfig &defaultPortConfig)
: base(mappingValue,
instanceConfigurableElement,
context),
context,
logger),
_device(context.getItemAsInteger(AlsaCtlDevice)),
_portConfig(defaultPortConfig)
{
Expand Down
5 changes: 3 additions & 2 deletions base/AlsaCtlPortConfig.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011-2014, Intel Corporation
* Copyright (c) 2011-2015, Intel Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
Expand Down Expand Up @@ -60,7 +60,8 @@ class AlsaCtlPortConfig : public AlsaSubsystemObject

AlsaCtlPortConfig(const std::string &mappingValue,
CInstanceConfigurableElement *instanceConfigurableElement,
const CMappingContext &context,
const CMappingContext &contVext,
core::log::Logger& logger,
const PortConfig &defaultPortConfig);

protected:
Expand Down
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-2014, Intel Corporation
* Copyright (c) 2011-2015, 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) : CSubsystem(name)
AlsaSubsystem(const std::string &name, core::log::Logger& logger) : CSubsystem(name, logger)
{
// Provide mapping keys to upper layer
addContextMappingKey("Card");
Expand Down
17 changes: 12 additions & 5 deletions base/AlsaSubsystemObject.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011-2014, Intel Corporation
* Copyright (c) 2011-2015, Intel Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
Expand Down Expand Up @@ -30,6 +30,7 @@
#include "AlsaSubsystemObject.hpp"
#include "MappingContext.h"
#include "AlsaMappingKeys.hpp"
#include <convert.hpp>

#include <limits.h>
#include <unistd.h>
Expand All @@ -45,8 +46,9 @@ const char AlsaSubsystemObject::_soundCardPath[] = "/proc/asound/";

AlsaSubsystemObject::AlsaSubsystemObject(const string &mappingValue,
CInstanceConfigurableElement *instanceConfigurableElement,
const CMappingContext &context)
: base(instanceConfigurableElement, mappingValue),
const CMappingContext &context,
core::log::Logger& logger)
: base(instanceConfigurableElement, logger, mappingValue),
_cardName(context.getItem(AlsaCard)),
_cardIndex(getCardNumberByName(context.getItem(AlsaCard)))
{
Expand All @@ -55,10 +57,11 @@ AlsaSubsystemObject::AlsaSubsystemObject(const string &mappingValue,

AlsaSubsystemObject::AlsaSubsystemObject(const string &mappingValue,
CInstanceConfigurableElement *instanceConfigurableElement,
core::log::Logger& logger,
uint32_t firstAmendKey,
uint32_t nbAmendKeys,
const CMappingContext &context)
: base(instanceConfigurableElement, mappingValue, firstAmendKey, nbAmendKeys, context),
: base(instanceConfigurableElement, logger, mappingValue, firstAmendKey, nbAmendKeys, context),
_cardName(context.getItem(AlsaCard)),
_cardIndex(getCardNumberByName(context.getItem(AlsaCard)))
{
Expand Down Expand Up @@ -89,6 +92,10 @@ int32_t AlsaSubsystemObject::getCardNumberByName(const string &cardName)
}

// Extract card number from link (Example: 5 from card5)
return asInteger(numberFilepath + strlen("card"));
int32_t cardNumber = 0;
if (convertTo(numberFilepath + strlen("card"), cardNumber)) {
return cardNumber;
}

return -1; // A negative value indicates a failure
}
6 changes: 4 additions & 2 deletions base/AlsaSubsystemObject.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011-2014, Intel Corporation
* Copyright (c) 2011-2015, Intel Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
Expand Down Expand Up @@ -42,9 +42,11 @@ class AlsaSubsystemObject : public CFormattedSubsystemObject
public:
AlsaSubsystemObject(const std::string &mappingValue,
CInstanceConfigurableElement *instanceConfigurableElement,
const CMappingContext &context);
const CMappingContext &context,
core::log::Logger& logger);
AlsaSubsystemObject(const std::string &strMappingValue,
CInstanceConfigurableElement *instanceConfigurableElement,
core::log::Logger& logger,
uint32_t firstAmendKey,
uint32_t nbAmendKeys,
const CMappingContext &context);
Expand Down
22 changes: 12 additions & 10 deletions base/AmixerControl.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011-2014, Intel Corporation
* Copyright (c) 2011-2015, Intel Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
Expand Down Expand Up @@ -35,7 +35,6 @@
#include "ParameterBlockType.h"
#include "MappingContext.h"
#include "AlsaMappingKeys.hpp"
#include "AutoLog.h"
#include <string.h>
#include <string>
#include <ctype.h>
Expand All @@ -45,8 +44,9 @@

AmixerControl::AmixerControl(const std::string &mappingValue,
CInstanceConfigurableElement *instanceConfigurableElement,
const CMappingContext &context)
: base(mappingValue, instanceConfigurableElement,
const CMappingContext &context,
core::log::Logger& logger)
: base(mappingValue, instanceConfigurableElement, logger,
AlsaAmend1,
gNbAlsaAmends,
context),
Expand Down Expand Up @@ -87,7 +87,7 @@ AmixerControl::AmixerControl(const std::string &mappingValue,

// If the parameter is a scalar its array size is 0, not 1.
_scalarSize = instanceConfigurableElement->getFootPrint() /
std::max(parameterType->getArrayLength(), 1U);
std::max(parameterType->getArrayLength(), size_t{1});
break;
}
default: {
Expand All @@ -98,8 +98,10 @@ AmixerControl::AmixerControl(const std::string &mappingValue,

AmixerControl::AmixerControl(const std::string &mappingValue,
CInstanceConfigurableElement *instanceConfigurableElement,
const CMappingContext &context, uint32_t scalarSize)
: base(mappingValue, instanceConfigurableElement,
const CMappingContext &context,
core::log::Logger& logger,
uint32_t scalarSize)
: base(mappingValue, instanceConfigurableElement, logger,
AlsaAmend1,
gNbAlsaAmends,
context),
Expand All @@ -114,9 +116,9 @@ void AmixerControl::logControlInfo(bool receive) const
if (_isDebugEnabled) {

std::string controlName = getFormattedMappingValue();
log_info("%s ALSA Element Instance: %s\t\t(Control Element: %s)",
receive ? "Reading" : "Writing",
getConfigurableElement()->getPath().c_str(), controlName.c_str());
info() << (receive ? "Reading" : "Writing")
<< " ALSA Element Instance: " << getConfigurableElement()->getPath()
<< "\t\t(Control Element: " << controlName << ")";
}
}

Expand Down
9 changes: 6 additions & 3 deletions base/AmixerControl.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011-2014, Intel Corporation
* Copyright (c) 2011-2015, Intel Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
Expand Down Expand Up @@ -52,7 +52,8 @@ class AmixerControl : public AlsaSubsystemObject
*/
AmixerControl(const std::string &mappingValue,
CInstanceConfigurableElement *instanceConfigurableElement,
const CMappingContext &context);
const CMappingContext &context,
core::log::Logger& logger);

/**
* AmixerControl Class constructor
Expand All @@ -64,7 +65,9 @@ class AmixerControl : public AlsaSubsystemObject
*/
AmixerControl(const std::string &mappingValue,
CInstanceConfigurableElement *instanceConfigurableElement,
const CMappingContext &context, 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
7 changes: 4 additions & 3 deletions base/AmixerMutableVolume.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011-2014, Intel Corporation
* Copyright (c) 2011-2015, Intel Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
Expand Down Expand Up @@ -74,8 +74,9 @@ class AmixerMutableVolume : public SubsystemObjectBase
*/
AmixerMutableVolume(const std::string &mappingValue,
CInstanceConfigurableElement *instConfigElement,
const CMappingContext &context)
: SubsystemObjectBase(mappingValue, instConfigElement, context),
const CMappingContext &context,
core::log::Logger& logger)
: SubsystemObjectBase(mappingValue, instConfigElement, context, logger),
_volumeLevelConfigurableElement(NULL)
{
if ((instConfigElement->getType() == CInstanceConfigurableElement::EParameterBlock) &&
Expand Down
4 changes: 2 additions & 2 deletions legacy/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2011-2014, Intel Corporation
# Copyright (c) 2011-2015, Intel Corporation
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without modification,
Expand Down Expand Up @@ -40,6 +40,6 @@ include_directories(
target_link_libraries(alsa-subsystem
alsabase-subsystem
${ALSA_LIBRARIES}
${PFW_LIBRARIES})
${PFW_CORE_LIBRARY})

install(TARGETS alsa-subsystem LIBRARY DESTINATION lib)
7 changes: 4 additions & 3 deletions legacy/LegacyAlsaCtlPortConfig.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011-2014, Intel Corporation
* Copyright (c) 2011-2015, Intel Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
Expand Down Expand Up @@ -49,8 +49,9 @@ const uint32_t LegacyAlsaCtlPortConfig::_latencyMicroSeconds = 500000;
LegacyAlsaCtlPortConfig::LegacyAlsaCtlPortConfig(
const std::string &mappingValue,
CInstanceConfigurableElement *instanceConfigurableElement,
const CMappingContext &context)
: base(mappingValue, instanceConfigurableElement, context, _defaultPortConfig)
const CMappingContext &context,
core::log::Logger& logger)
: base(mappingValue, instanceConfigurableElement, context, logger, _defaultPortConfig)
{
// Init stream handle array
_streamHandle[Playback] = NULL;
Expand Down
5 changes: 3 additions & 2 deletions legacy/LegacyAlsaCtlPortConfig.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011-2014, Intel Corporation
* Copyright (c) 2011-2015, Intel Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
Expand Down Expand Up @@ -47,7 +47,8 @@ class LegacyAlsaCtlPortConfig : public AlsaCtlPortConfig
*/
LegacyAlsaCtlPortConfig(const std::string &mappingValue,
CInstanceConfigurableElement *instanceConfigurableElement,
const CMappingContext &context);
const CMappingContext &context,
core::log::Logger& logger);

protected:
// Stream operations
Expand Down
5 changes: 3 additions & 2 deletions legacy/LegacyAlsaSubsystem.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011-2014, Intel Corporation
* Copyright (c) 2011-2015, Intel Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
Expand Down Expand Up @@ -36,7 +36,8 @@
#include "AmixerMutableVolume.hpp"
#include <string>

LegacyAlsaSubsystem::LegacyAlsaSubsystem(const std::string &name) : AlsaSubsystem(name)
LegacyAlsaSubsystem::LegacyAlsaSubsystem(const std::string &name, core::log::Logger& logger) :
AlsaSubsystem(name, logger)
{
// Provide creators to upper layer
addSubsystemObjectFactory(
Expand Down
4 changes: 2 additions & 2 deletions legacy/LegacyAlsaSubsystem.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011-2014, Intel Corporation
* Copyright (c) 2011-2015, Intel Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
Expand Down Expand Up @@ -36,5 +36,5 @@
class LegacyAlsaSubsystem : public AlsaSubsystem
{
public:
LegacyAlsaSubsystem(const std::string &name);
LegacyAlsaSubsystem(const std::string &name, core::log::Logger& logger);
};
15 changes: 6 additions & 9 deletions legacy/LegacyAlsaSubsystemBuilder.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011-2014, Intel Corporation
* Copyright (c) 2011-2015, Intel Corporation
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
Expand Down Expand Up @@ -27,24 +27,21 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "SubsystemLibrary.h"
#include "NamedElementBuilderTemplate.h"
#include <Plugin.h>
#include <LoggingElementBuilderTemplate.h>
#include "LegacyAlsaSubsystem.hpp"
#include "LegacyAmixerControl.hpp"

extern "C"
{
/**
* Alsa subsystem builder
* This function is called when the PFW parses a subsystem structure XML of type "ALSA".
* It will then create an Amixer Subsystem
*
* @param[in] subsystemLibrary the pointer on the subsystem library
*/
void getALSASubsystemBuilder(CSubsystemLibrary *subsystemLibrary)
void PARAMETER_FRAMEWORK_PLUGIN_ENTRYPOINT_V1(CSubsystemLibrary *subsystemLibrary,
core::log::Logger &logger)
{
subsystemLibrary->addElementBuilder(
"ALSA", new TNamedElementBuilderTemplate<LegacyAlsaSubsystem>
);
"ALSA", new TLoggingElementBuilderTemplate<LegacyAlsaSubsystem>(logger));
}
}
Loading

0 comments on commit 251c537

Please sign in to comment.