11/*
2- * Copyright (c) 2011-2015 , Intel Corporation
2+ * Copyright (c) 2011-2017 , Intel Corporation
33 * All rights reserved.
44 *
55 * Redistribution and use in source and binary forms, with or without modification,
3838#define base AlsaCtlPortConfig
3939
4040const AlsaCtlPortConfig::PortConfig LegacyAlsaCtlPortConfig::_defaultPortConfig = {
41- { false , false },
42- SND_PCM_FORMAT_S16_LE,
43- 2 ,
44- 48000
45- };
41+ {false , false }, SND_PCM_FORMAT_S16_LE, 2 , 48000 };
4642
4743const uint32_t LegacyAlsaCtlPortConfig::_latencyMicroSeconds = 500000 ;
4844
4945LegacyAlsaCtlPortConfig::LegacyAlsaCtlPortConfig (
50- const std::string &mappingValue,
51- CInstanceConfigurableElement *instanceConfigurableElement,
52- const CMappingContext &context,
53- core::log::Logger& logger)
54- : base(mappingValue, instanceConfigurableElement, context, logger, _defaultPortConfig)
46+ const std::string &mappingValue, CInstanceConfigurableElement *instanceConfigurableElement,
47+ const CMappingContext &context, core::log::Logger &logger)
48+ : base(mappingValue, instanceConfigurableElement, context, logger, _defaultPortConfig)
5549{
5650 // Init stream handle array
5751 _streamHandle[Playback] = NULL ;
@@ -63,11 +57,10 @@ LegacyAlsaCtlPortConfig::LegacyAlsaCtlPortConfig(
6357 // Create device name
6458 std::ostringstream streamName;
6559
66- streamName << " hw:" << snd_card_get_index (cardIndex.c_str ())
67- << " , " << context.getItem (AlsaCtlDevice);
60+ streamName << " hw:" << snd_card_get_index (cardIndex.c_str ()) << " , "
61+ << context.getItem (AlsaCtlDevice);
6862
6963 _streamName = streamName.str ();
70-
7164}
7265
7366bool LegacyAlsaCtlPortConfig::doOpenStream (StreamDirection streamDirection, std::string &error)
@@ -76,10 +69,9 @@ bool LegacyAlsaCtlPortConfig::doOpenStream(StreamDirection streamDirection, std:
7669 int32_t errorId;
7770
7871 if ((errorId = snd_pcm_open (
79- &streamHandle,
80- _streamName.c_str (),
81- streamDirection == Capture ? SND_PCM_STREAM_CAPTURE : SND_PCM_STREAM_PLAYBACK,
82- 0 )) < 0 ) {
72+ &streamHandle, _streamName.c_str (),
73+ streamDirection == Capture ? SND_PCM_STREAM_CAPTURE : SND_PCM_STREAM_PLAYBACK, 0 )) <
74+ 0 ) {
8375
8476 error = formatAlsaError (streamDirection, " open" , snd_strerror (errorId));
8577
@@ -88,13 +80,9 @@ bool LegacyAlsaCtlPortConfig::doOpenStream(StreamDirection streamDirection, std:
8880
8981 const AlsaCtlPortConfig::PortConfig &portConfig = getPortConfig ();
9082
91- if ((errorId = snd_pcm_set_params (streamHandle,
92- static_cast <_snd_pcm_format>(portConfig.format ),
93- SND_PCM_ACCESS_RW_INTERLEAVED,
94- portConfig.channelNumber ,
95- portConfig.sampleRate ,
96- 0 ,
97- _latencyMicroSeconds)) < 0 ) {
83+ if ((errorId = snd_pcm_set_params (streamHandle, static_cast <_snd_pcm_format>(portConfig.format ),
84+ SND_PCM_ACCESS_RW_INTERLEAVED, portConfig.channelNumber ,
85+ portConfig.sampleRate , 0 , _latencyMicroSeconds)) < 0 ) {
9886
9987 error = formatAlsaError (streamDirection, " set params" , snd_strerror (errorId));
10088
0 commit comments