mirror of
https://github.com/mudita/MuditaOS.git
synced 2026-01-18 02:48:05 -05:00
Extended volume scale from 10 to 15 point scale Modified volume approximation function for better user experience
80 lines
1.8 KiB
C++
80 lines
1.8 KiB
C++
// Copyright (c) 2017-2023, Mudita Sp. z.o.o. All rights reserved.
|
|
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
|
|
|
|
#pragma once
|
|
|
|
#include "Endpoint.hpp"
|
|
|
|
#include <optional>
|
|
#include <memory>
|
|
#include <functional>
|
|
|
|
namespace audio
|
|
{
|
|
|
|
class AudioDevice : public audio::IOProxy
|
|
{
|
|
|
|
public:
|
|
static constexpr auto minVolume = .0f;
|
|
static constexpr auto maxVolume = 10.0f;
|
|
|
|
enum class RetCode
|
|
{
|
|
Success = 0,
|
|
Failure,
|
|
Disconnected
|
|
};
|
|
|
|
enum class Type
|
|
{
|
|
None,
|
|
Audiocodec,
|
|
Cellular,
|
|
BluetoothA2DP,
|
|
BluetoothHSP,
|
|
BluetoothHFP
|
|
};
|
|
|
|
virtual ~AudioDevice() = default;
|
|
|
|
virtual RetCode Start()
|
|
{
|
|
return RetCode::Success;
|
|
}
|
|
|
|
virtual RetCode Stop()
|
|
{
|
|
return RetCode::Success;
|
|
}
|
|
|
|
virtual RetCode Pause()
|
|
{
|
|
return RetCode::Success;
|
|
}
|
|
|
|
virtual RetCode Resume()
|
|
{
|
|
return RetCode::Success;
|
|
}
|
|
|
|
/// Set device output volume
|
|
/// @param vol desired volume from 0 to 10
|
|
/// @return RetCode::Success if OK, or RetCode::Failure otherwise
|
|
virtual RetCode setOutputVolume(float vol) = 0;
|
|
|
|
/// Set device input gain
|
|
/// @param gain desired input gain from 0 to 100
|
|
/// @return RetCode::Success if OK, or RetCode::Failure otherwise
|
|
virtual RetCode setInputGain(float gain) = 0;
|
|
|
|
auto getSinkFormat() -> AudioFormat override
|
|
{
|
|
return getSourceFormat();
|
|
}
|
|
|
|
private:
|
|
static_assert(maxVolume > 0, "maxVolume needs to be bigger than 0");
|
|
};
|
|
} // namespace audio
|