19#include "libavcodec/defs.h"
20#include "libavutil/avutil.h"
23#define LOC QString("AOS: ")
27 5512, 8000, 11025, 16000, 22050, 32000, 44100,
28 48000, 88200, 96000, 176400, 192000
38 m_srIt(kStdRates.begin()),
39 m_sfIt(kStdFormats.begin())
82 LOG(VB_AUDIO, LOG_INFO,
LOC +
83 QString(
"Sample rate %1 is supported").arg(rate));
88 if (
m_rates.empty() && rate == 48000)
91#ifdef __cpp_lib_ranges_contains
92 return std::ranges::contains(
m_rates, rate);
112 auto it = std::ranges::find_if(
m_rates,
113 [rate](
const auto entry){
return entry >= rate; } );
134 LOG(VB_AUDIO, LOG_INFO,
LOC +
144#ifdef __cpp_lib_ranges_contains
145 return std::ranges::contains(
m_formats, format);
183 case FORMAT_FLT:
return "32 bit floating point";
185 default:
return "unknown";
209 switch (av_get_packed_sample_fmt(format))
215 case AV_SAMPLE_FMT_S32:
242 default:
return AV_SAMPLE_FMT_NONE;
249 LOG(VB_AUDIO, LOG_INFO,
LOC + QString(
"%1 channel(s) are supported")
258#ifdef __cpp_lib_ranges_contains
259 return std::ranges::contains(
m_channels, channels);
262 [channels](
const auto entry)
263 {
return entry == channels; } );
292 std::back_inserter(tmp),
293 [channels](
int value){
return channels > value; } );
350 LOG(VB_AUDIO, LOG_INFO,
LOC +
"may be AC3 or DTS capable");
410 if (max_channels > 2 && !bLPCM)
412 if (max_channels == 2 && (bAC3 || bDTS))
415 cur_channels = std::min(cur_channels, max_channels);
447static const std::array<featureStruct,7>
feature {{
461 for (
const auto & [flag, name] :
feature)
464 tmp += QString::fromStdString(name);
466 return tmp.join(
",");
480 case AV_CODEC_ID_AC3:
483 case AV_CODEC_ID_EAC3:
484 samplerate = samplerate * 4;
485 log =
"Dolby Digital Plus (E-AC3)";
487 case AV_CODEC_ID_DTS:
488 switch(codec_profile)
490 case AV_PROFILE_DTS_ES:
493 case AV_PROFILE_DTS_96_24:
496 case AV_PROFILE_DTS_HD_HRA:
498 log =
"DTS-HD High-Res";
500 case AV_PROFILE_DTS_HD_MA:
509 log =
"DTS-HD High-Res";
518 case AV_CODEC_ID_TRUEHD:
534 log =
"TrueHD: Unsupported samplerate";
557 m_eld =
eld(ba->constData(), ba->size());
567 return eldc < chan ? eldc : chan;
576 return eldc < chan ? eldc : chan;
static const std::array< featureStruct, 7 > feature
std::array< const int, 12 > rate_array
std::array< const AudioFormat, 6 > format_array
bool IsSupportedChannels(int channels)
QString FeaturesToString(void) const
AudioOutputSettings * GetUsers(bool newcopy=false)
Returns capabilities supported by the audio device amended to take into account the digital audio opt...
int BestSupportedChannels()
static int SampleSize(AudioFormat format)
AudioFormat BestSupportedFormat()
void setELD(QByteArray *ba)
set ELD data
bool canFeature(DigitalFeature arg) const
return DigitalFeature mask.
std::vector< AudioFormat > m_formats
AudioFormat GetNextFormat()
int BestSupportedChannelsELD()
Reports best supported channel number, restricted to ELD range.
static const format_array kStdFormats
void AddSupportedRate(int rate)
rate_array::iterator m_srIt
int GetMaxHDRate() const
return the highest iec958 rate supported.
static AVSampleFormat FormatToAVSampleFormat(AudioFormat format)
Return AudioFormat closest equivalent to AVSampleFormat Note that FORMAT_S24LSB and FORMAT_S24 have n...
bool IsSupportedRate(int rate)
format_array::iterator m_sfIt
std::vector< int > m_rates
AudioOutputSettings(bool invalid=false)
bool hasELD() const
get the ELD flag
void SetBestSupportedChannels(int channels)
Force set the greatest number of channels supported by the audio device.
int NearestSupportedRate(int rate)
AudioOutputSettings * GetCleaned(bool newcopy=false)
Returns capabilities supported by the audio device amended to take into account the digital audio opt...
static AudioFormat AVSampleFormatToFormat(AVSampleFormat format, int bits=0)
Return AVSampleFormat closest equivalent to AudioFormat.
std::vector< int > m_channels
void setPassthrough(int val)
static const char * FormatToString(AudioFormat format)
static int FormatToBits(AudioFormat format)
int BestSupportedPCMChannelsELD()
Reports best supported PCM channel number, restricted to ELD.
void AddSupportedChannels(int channels)
void setFeature(DigitalFeature arg)
set the provided digital feature possible values are:
void SortSupportedChannels()
static QString GetPassthroughParams(int codec, int codec_profile, int &samplerate, int &channels, bool canDTSHDMA)
Setup samplerate and number of channels for passthrough.
void AddSupportedFormat(AudioFormat format)
static const rate_array kStdRates
bool IsSupportedFormat(AudioFormat format)
bool m_hasEld
will be set to true if we were able to retrieve the device ELD (EDID like Data).
AudioOutputSettings & operator=(const AudioOutputSettings &)
int m_passthrough
passthrough status -1 : no 0: unknown 1: yes
int GetNumSetting(const QString &key, int defaultval=0)
bool GetBoolSetting(const QString &key, bool defaultval=false)
static pid_list_t::iterator find(const PIDInfoMap &map, pid_list_t &list, pid_list_t::iterator begin, pid_list_t::iterator end, bool find_open)
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
None log(str msg, int level=LOGDEBUG)
const DigitalFeature flag