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

Commit 251c537

Browse files
committed
Merge pull request #17 from 01org/adapt-to-v3-api
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.
2 parents 13be58c + 14ff848 commit 251c537

28 files changed

+146
-122
lines changed

CMakeLists.txt

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2011-2014, Intel Corporation
1+
# Copyright (c) 2011-2015, Intel Corporation
22
# All rights reserved.
33
#
44
# Redistribution and use in source and binary forms, with or without modification,
@@ -31,23 +31,19 @@ cmake_minimum_required(VERSION 2.8)
3131

3232
project(parameter-framework-plugins-alsa)
3333

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

3636
#
3737
# Find PFW libraries and include directories
3838
#
39-
find_path(PFW_CORE_ROOT_DIR NAMES include/parameter/plugin/Subsystem.h)
39+
find_path(PFW_INCLUDE_ROOT NAMES parameter/plugin/Plugin.h)
4040

41-
find_library(PFW_CORE_LIBRARY NAMES parameter
42-
HINTS ${PFW_CORE_ROOT_DIR}/lib)
41+
find_library(PFW_CORE_LIBRARY NAMES parameter)
4342

44-
find_path(PFW_CORE_INCLUDE_DIR NAMES Subsystem.h
45-
HINTS ${PFW_CORE_ROOT_DIR}/include/parameter/plugin)
46-
find_path(PFW_XMLSERIALIZER_INCLUDE_DIR NAMES XmlSink.h
47-
HINTS ${PFW_CORE_ROOT_DIR}/include/xmlserializer)
48-
49-
set(PFW_INCLUDE_DIRS ${PFW_CORE_INCLUDE_DIR} ${PFW_XMLSERIALIZER_INCLUDE_DIR})
50-
set(PFW_LIBRARIES ${PFW_CORE_LIBRARY})
43+
set(PFW_INCLUDE_DIRS
44+
${PFW_INCLUDE_ROOT}/parameter/plugin
45+
${PFW_INCLUDE_ROOT}/xmlserializer
46+
${PFW_INCLUDE_ROOT}/utility)
5147

5248
#
5349
# Find (regular) alsa-lib

base/AlsaCtlPortConfig.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2011-2014, Intel Corporation
2+
* Copyright (c) 2011-2015, Intel Corporation
33
* All rights reserved.
44
*
55
* Redistribution and use in source and binary forms, with or without modification,
@@ -43,10 +43,12 @@ using std::string;
4343
AlsaCtlPortConfig::AlsaCtlPortConfig(const string &mappingValue,
4444
CInstanceConfigurableElement *instanceConfigurableElement,
4545
const CMappingContext &context,
46+
core::log::Logger& logger,
4647
const PortConfig &defaultPortConfig)
4748
: base(mappingValue,
4849
instanceConfigurableElement,
49-
context),
50+
context,
51+
logger),
5052
_device(context.getItemAsInteger(AlsaCtlDevice)),
5153
_portConfig(defaultPortConfig)
5254
{

base/AlsaCtlPortConfig.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2011-2014, Intel Corporation
2+
* Copyright (c) 2011-2015, Intel Corporation
33
* All rights reserved.
44
*
55
* Redistribution and use in source and binary forms, with or without modification,
@@ -60,7 +60,8 @@ class AlsaCtlPortConfig : public AlsaSubsystemObject
6060

6161
AlsaCtlPortConfig(const std::string &mappingValue,
6262
CInstanceConfigurableElement *instanceConfigurableElement,
63-
const CMappingContext &context,
63+
const CMappingContext &contVext,
64+
core::log::Logger& logger,
6465
const PortConfig &defaultPortConfig);
6566

6667
protected:

base/AlsaSubsystem.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2011-2014, Intel Corporation
2+
* Copyright (c) 2011-2015, Intel Corporation
33
* All rights reserved.
44
*
55
* Redistribution and use in source and binary forms, with or without modification,
@@ -41,7 +41,7 @@
4141
class AlsaSubsystem : public CSubsystem
4242
{
4343
public:
44-
AlsaSubsystem(const std::string &name) : CSubsystem(name)
44+
AlsaSubsystem(const std::string &name, core::log::Logger& logger) : CSubsystem(name, logger)
4545
{
4646
// Provide mapping keys to upper layer
4747
addContextMappingKey("Card");

base/AlsaSubsystemObject.cpp

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2011-2014, Intel Corporation
2+
* Copyright (c) 2011-2015, Intel Corporation
33
* All rights reserved.
44
*
55
* Redistribution and use in source and binary forms, with or without modification,
@@ -30,6 +30,7 @@
3030
#include "AlsaSubsystemObject.hpp"
3131
#include "MappingContext.h"
3232
#include "AlsaMappingKeys.hpp"
33+
#include <convert.hpp>
3334

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

4647
AlsaSubsystemObject::AlsaSubsystemObject(const string &mappingValue,
4748
CInstanceConfigurableElement *instanceConfigurableElement,
48-
const CMappingContext &context)
49-
: base(instanceConfigurableElement, mappingValue),
49+
const CMappingContext &context,
50+
core::log::Logger& logger)
51+
: base(instanceConfigurableElement, logger, mappingValue),
5052
_cardName(context.getItem(AlsaCard)),
5153
_cardIndex(getCardNumberByName(context.getItem(AlsaCard)))
5254
{
@@ -55,10 +57,11 @@ AlsaSubsystemObject::AlsaSubsystemObject(const string &mappingValue,
5557

5658
AlsaSubsystemObject::AlsaSubsystemObject(const string &mappingValue,
5759
CInstanceConfigurableElement *instanceConfigurableElement,
60+
core::log::Logger& logger,
5861
uint32_t firstAmendKey,
5962
uint32_t nbAmendKeys,
6063
const CMappingContext &context)
61-
: base(instanceConfigurableElement, mappingValue, firstAmendKey, nbAmendKeys, context),
64+
: base(instanceConfigurableElement, logger, mappingValue, firstAmendKey, nbAmendKeys, context),
6265
_cardName(context.getItem(AlsaCard)),
6366
_cardIndex(getCardNumberByName(context.getItem(AlsaCard)))
6467
{
@@ -89,6 +92,10 @@ int32_t AlsaSubsystemObject::getCardNumberByName(const string &cardName)
8992
}
9093

9194
// Extract card number from link (Example: 5 from card5)
92-
return asInteger(numberFilepath + strlen("card"));
95+
int32_t cardNumber = 0;
96+
if (convertTo(numberFilepath + strlen("card"), cardNumber)) {
97+
return cardNumber;
98+
}
9399

100+
return -1; // A negative value indicates a failure
94101
}

base/AlsaSubsystemObject.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2011-2014, Intel Corporation
2+
* Copyright (c) 2011-2015, Intel Corporation
33
* All rights reserved.
44
*
55
* Redistribution and use in source and binary forms, with or without modification,
@@ -42,9 +42,11 @@ class AlsaSubsystemObject : public CFormattedSubsystemObject
4242
public:
4343
AlsaSubsystemObject(const std::string &mappingValue,
4444
CInstanceConfigurableElement *instanceConfigurableElement,
45-
const CMappingContext &context);
45+
const CMappingContext &context,
46+
core::log::Logger& logger);
4647
AlsaSubsystemObject(const std::string &strMappingValue,
4748
CInstanceConfigurableElement *instanceConfigurableElement,
49+
core::log::Logger& logger,
4850
uint32_t firstAmendKey,
4951
uint32_t nbAmendKeys,
5052
const CMappingContext &context);

base/AmixerControl.cpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2011-2014, Intel Corporation
2+
* Copyright (c) 2011-2015, Intel Corporation
33
* All rights reserved.
44
*
55
* Redistribution and use in source and binary forms, with or without modification,
@@ -35,7 +35,6 @@
3535
#include "ParameterBlockType.h"
3636
#include "MappingContext.h"
3737
#include "AlsaMappingKeys.hpp"
38-
#include "AutoLog.h"
3938
#include <string.h>
4039
#include <string>
4140
#include <ctype.h>
@@ -45,8 +44,9 @@
4544

4645
AmixerControl::AmixerControl(const std::string &mappingValue,
4746
CInstanceConfigurableElement *instanceConfigurableElement,
48-
const CMappingContext &context)
49-
: base(mappingValue, instanceConfigurableElement,
47+
const CMappingContext &context,
48+
core::log::Logger& logger)
49+
: base(mappingValue, instanceConfigurableElement, logger,
5050
AlsaAmend1,
5151
gNbAlsaAmends,
5252
context),
@@ -87,7 +87,7 @@ AmixerControl::AmixerControl(const std::string &mappingValue,
8787

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

9999
AmixerControl::AmixerControl(const std::string &mappingValue,
100100
CInstanceConfigurableElement *instanceConfigurableElement,
101-
const CMappingContext &context, uint32_t scalarSize)
102-
: base(mappingValue, instanceConfigurableElement,
101+
const CMappingContext &context,
102+
core::log::Logger& logger,
103+
uint32_t scalarSize)
104+
: base(mappingValue, instanceConfigurableElement, logger,
103105
AlsaAmend1,
104106
gNbAlsaAmends,
105107
context),
@@ -114,9 +116,9 @@ void AmixerControl::logControlInfo(bool receive) const
114116
if (_isDebugEnabled) {
115117

116118
std::string controlName = getFormattedMappingValue();
117-
log_info("%s ALSA Element Instance: %s\t\t(Control Element: %s)",
118-
receive ? "Reading" : "Writing",
119-
getConfigurableElement()->getPath().c_str(), controlName.c_str());
119+
info() << (receive ? "Reading" : "Writing")
120+
<< " ALSA Element Instance: " << getConfigurableElement()->getPath()
121+
<< "\t\t(Control Element: " << controlName << ")";
120122
}
121123
}
122124

base/AmixerControl.hpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2011-2014, Intel Corporation
2+
* Copyright (c) 2011-2015, Intel Corporation
33
* All rights reserved.
44
*
55
* Redistribution and use in source and binary forms, with or without modification,
@@ -52,7 +52,8 @@ class AmixerControl : public AlsaSubsystemObject
5252
*/
5353
AmixerControl(const std::string &mappingValue,
5454
CInstanceConfigurableElement *instanceConfigurableElement,
55-
const CMappingContext &context);
55+
const CMappingContext &context,
56+
core::log::Logger& logger);
5657

5758
/**
5859
* AmixerControl Class constructor
@@ -64,7 +65,9 @@ class AmixerControl : public AlsaSubsystemObject
6465
*/
6566
AmixerControl(const std::string &mappingValue,
6667
CInstanceConfigurableElement *instanceConfigurableElement,
67-
const CMappingContext &context, uint32_t scalarSize);
68+
const CMappingContext &context,
69+
core::log::Logger& logger,
70+
uint32_t scalarSize);
6871

6972
protected:
7073
virtual bool accessHW(bool receive, std::string &error) = 0;

base/AmixerMutableVolume.hpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2011-2014, Intel Corporation
2+
* Copyright (c) 2011-2015, Intel Corporation
33
* All rights reserved.
44
*
55
* Redistribution and use in source and binary forms, with or without modification,
@@ -74,8 +74,9 @@ class AmixerMutableVolume : public SubsystemObjectBase
7474
*/
7575
AmixerMutableVolume(const std::string &mappingValue,
7676
CInstanceConfigurableElement *instConfigElement,
77-
const CMappingContext &context)
78-
: SubsystemObjectBase(mappingValue, instConfigElement, context),
77+
const CMappingContext &context,
78+
core::log::Logger& logger)
79+
: SubsystemObjectBase(mappingValue, instConfigElement, context, logger),
7980
_volumeLevelConfigurableElement(NULL)
8081
{
8182
if ((instConfigElement->getType() == CInstanceConfigurableElement::EParameterBlock) &&

legacy/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2011-2014, Intel Corporation
1+
# Copyright (c) 2011-2015, Intel Corporation
22
# All rights reserved.
33
#
44
# Redistribution and use in source and binary forms, with or without modification,
@@ -40,6 +40,6 @@ include_directories(
4040
target_link_libraries(alsa-subsystem
4141
alsabase-subsystem
4242
${ALSA_LIBRARIES}
43-
${PFW_LIBRARIES})
43+
${PFW_CORE_LIBRARY})
4444

4545
install(TARGETS alsa-subsystem LIBRARY DESTINATION lib)

0 commit comments

Comments
 (0)