13#include <QCoreApplication>
21#include "libmythbase/mythconfig.h"
33#include "libavformat/avformat.h"
41 QString dflt =
"OpenSLES:";
42#elif CONFIG_AUDIO_ALSA
43 QString dflt =
"ALSA:default";
44#elif CONFIG_AUDIO_PULSEOUTPUT
45 QString dflt =
"PulseAudio:default";
46#elif defined(Q_OS_DARWIN)
47 QString dflt =
"CoreAudio:";
49 QString dflt =
"Windows:";
51 QString dflt =
"NULL";
79 for (
const auto & it : std::as_const(vect))
81 if (value != it.m_name)
109 if (settings ==
nullptr)
111 settings->CheckConfiguration();
116 m_passThroughOverride(PassThroughOverride()),
117 m_passThroughDeviceOverride(PassThroughOutputDevice())
125 rescan->setLabel(tr(
"Rescan"));
126 rescan->setHelpText(tr(
"Rescan for available audio devices. "
127 "Current entry will be checked and "
128 "capability entries populated."));
148 advancedSettings->setLabel(tr(
"Advanced Audio Settings"));
149 advancedSettings->setHelpText(tr(
"Enable extra audio settings. Under most "
150 "usage all options should be left alone"));
206 QString msg = tr(
"%1 is invalid or not useable.").arg(name);
210 LOG(VB_GENERAL, LOG_ERR, QString(
"Audio device %1 isn't usable")
219 QString pt_msg = tr(
"Passthrough device is invalid or not useable. Check "
220 "configuration in Advanced Settings:") +
225 LOG(VB_GENERAL, LOG_ERR, QString(
"Audio device %1 isn't usable")
248 for (
const auto & dev : std::as_const(*list))
280 bool restore,
bool AC3)
282 int max_speakers = 8;
283 int realmax_speakers = 8;
285 bool invalid =
false;
318 LOG(VB_AUDIO, LOG_ERR, QString(
"Update not found (%1)").arg(out));
326 settingsdigital = bForceDigital ?
328 .m_settings : settings;
346 if (max_speakers > 2 && !bLPCM)
348 if (max_speakers == 2 && bAC3)
375 if (cur_speakers > max_speakers)
377 LOG(VB_AUDIO, LOG_INFO, QString(
"Reset device %1").arg(out));
378 cur_speakers = max_speakers;
384 for (
int i = 1; i <= max_speakers; i++)
394 txt = QCoreApplication::translate(
"(Common)",
"Stereo");
397 txt = QCoreApplication::translate(
"(Common)",
"5.1");
400 txt = QCoreApplication::translate(
"(Common)",
"7.1");
441 QString name =
"MaxChannels";
445 gc->setLabel(tr(
"Speaker configuration"));
447 gc->addSelection(QCoreApplication::translate(
"(Common)",
"Stereo"),
450 gc->setHelpText(tr(
"Select the maximum number of audio "
451 "channels supported by your receiver "
460 gc->setLabel(tr(
"Upconvert stereo to 5.1 surround"));
464 gc->setHelpText(tr(
"If enabled, MythTV will upconvert stereo "
465 "to 5.1 audio. You can enable or disable "
466 "the upconversion during playback at any time."));
474 gc->setLabel(tr(
"Upmix Quality"));
476 gc->addSelection(tr(
"Passive"),
"0");
477 gc->addSelection(tr(
"Hall",
"Upmix Quality"),
"3");
478 gc->addSelection(tr(
"Good",
"Upmix Quality"),
"1");
479 gc->addSelection(tr(
"Best",
"Upmix Quality"),
"2",
true);
481 gc->setHelpText(tr(
"Set the audio surround-upconversion quality."));
490 gc->setLabel(tr(
"Dolby Digital"));
494 gc->setHelpText(tr(
"Enable if your amplifier or sound decoder "
495 "supports AC-3/Dolby Digital. You must use a digital "
496 "connection. Uncheck if using an analog connection."));
504 gc->setLabel(tr(
"DTS"));
508 gc->setHelpText(tr(
"Enable if your amplifier or sound decoder supports "
509 "DTS. You must use a digital connection. Uncheck "
510 "if using an analog connection"));
518 gc->setLabel(tr(
"E-AC-3"));
522 gc->setHelpText(tr(
"Enable if your amplifier or sound decoder supports "
523 "E-AC-3 (DD+). You must use a HDMI connection."));
531 gc->setLabel(tr(
"TrueHD"));
535 gc->setHelpText(tr(
"Enable if your amplifier or sound decoder supports "
536 "Dolby TrueHD. You must use a HDMI connection."));
544 gc->setLabel(tr(
"DTS-HD"));
548 gc->setHelpText(tr(
"Enable if your amplifier or sound decoder supports "
549 "DTS-HD. You must use a HDMI connection."));
564 LOG(VB_GENERAL, LOG_ERR,
565 QString(
"Passthru device %1 isn't usable "
566 "Check audio configuration").arg(name));
579 const QDir& dir,
bool absPath =
true)
582 QFileInfoList entries = dir.entryInfoList();
583 for (
const auto & fi : std::as_const(entries))
597 QString passthrough =
606 : QEvent(kEventType),
607 m_channel(
std::move(channame)),
613 QString
main, QString passthrough,
618 m_parent(parent), m_channels(channels), m_device(
std::move(
main)),
619 m_passthrough(
std::move(passthrough)), m_hd(hd),
620 m_samplerate(hd ? settings.BestSupportedRate() : 48000),
621 m_format(hd ? settings.BestSupportedFormat() :
FORMAT_S16)
627 true,
false, 0, &settings);
635 static_cast<QEvent::Type
>(QEvent::registerEventType());
658 std::array<std::array<int,8>,7> smptelayout {{
663 { 0, 2, 1, 5, 4, 3 },
664 { 0, 2, 1, 6, 4, 5, 3 },
665 { 0, 2, 1, 7, 5, 4, 6, 3 },
670 char *frames =
new (std::align_val_t(16))
char[
m_channels * 1024_UZ *
sizeof(int32_t)];
694 channel =
"frontleft";
697 channel =
"frontright";
707 channel =
"surroundleft";
709 channel =
"rearright";
711 channel =
"rearleft";
715 channel =
"surroundright";
717 channel =
"surroundleft";
719 channel =
"rearright";
723 channel =
"surroundright";
725 channel =
"surroundleft";
728 channel =
"surroundright";
731 QCoreApplication::postEvent(
734 LOG(VB_AUDIO, LOG_INFO, QString(
"AudioTest: %1 (%2->%3)")
735 .arg(channel).arg(i).arg(
current));
746 LOG(VB_AUDIO, LOG_ERR,
"AddData() Audio buffer "
747 "overflow, audio data lost!");
753 std::this_thread::sleep_for(500ms);
761 ::operator
delete[] (frames, std::align_val_t(16));
771 setLabel(tr(
"Audio Configuration Testing"));
772 setHelpText(tr(
"Will play a test pattern on all configured "
804 QString surroundleft;
858 "supported by your audio card. This will be "
859 "a good place to start troubleshooting "
860 "potential errors"));
878 const QString &passthrough,
928 else if (this->sender() ==
m_lfe)
950 else if (this->sender() ==
m_center)
989 QString msg = tr(
"Audio device is invalid or not useable.");
1005 return QObject::event(
event);
1009 return GroupSetting::event(
event);
1011 QString channel = cce->m_channel;
1013 if (!cce->m_fulltest)
1014 return GroupSetting::event(
event);
1025 if (channel ==
"frontleft")
1029 else if (channel ==
"frontright")
1033 else if (channel ==
"center")
1037 else if (channel ==
"lfe")
1041 else if (channel ==
"surroundleft")
1045 else if (channel ==
"surroundright")
1049 else if (channel ==
"rearleft")
1053 else if (channel ==
"rearright")
1073 return GroupSetting::event(
event);
1081 gc->setLabel(tr(
"Use internal volume controls"));
1085 gc->setHelpText(tr(
"If enabled, MythTV will control the PCM and "
1086 "master mixer volume. Disable this option if you "
1087 "prefer to control the volume externally (for "
1088 "example, using your amplifier) or if you use an "
1089 "external mixer program."));
1101 gc->setLabel(tr(
"Mixer device"));
1104 QDir dev(
"/dev",
"mixer*", QDir::Name, QDir::System);
1107 dev.setPath(
"/dev/sound");
1113#if CONFIG_AUDIO_ALSA
1114 gc->addSelection(
"ALSA:default",
"ALSA:default");
1117 gc->addSelection(
"DirectX:",
"DirectX:");
1118 gc->addSelection(
"Windows:",
"Windows:");
1121 gc->addSelection(
"OpenSLES:",
"OpenSLES:");
1124 gc->addSelection(tr(
"software"),
"software");
1127 gc->setHelpText(tr(
"Setting the mixer device to \"%1\" lets MythTV control "
1128 "the volume of all audio at the expense of a slight "
1130 .arg(tr(
"software")));
1137 QT_TR_NOOP(
"Master")};
1143 gc->setLabel(tr(
"Mixer controls"));
1146 gc->addSelection(tr(control), control);
1148 gc->setHelpText(tr(
"Changing the volume adjusts the selected mixer."));
1157 gs->setLabel(tr(
"Master mixer volume"));
1161 gs->setHelpText(tr(
"Initial volume for the Master mixer. This affects "
1162 "all sound created by the audio device. Note: Do not "
1163 "set this too low."));
1171 gs->setLabel(tr(
"PCM mixer volume"));
1175 gs->setHelpText(tr(
"Initial volume for PCM output. Using the volume "
1176 "keys in MythTV will adjust this parameter."));
1184 gc->setLabel(tr(
"Stereo PCM Only"));
1186 gc->setValue(
false);
1188 gc->setHelpText(tr(
"Enable if your amplifier or sound decoder only "
1189 "supports 2 channel PCM (typically an old HDMI 1.0 "
1190 "device). Multichannel audio will be re-encoded to "
1191 "AC-3 when required"));
1199 gc->setLabel(tr(
"Override SRC quality"));
1201 gc->setValue(
false);
1203 gc->setHelpText(tr(
"Enable to override audio sample rate "
1204 "conversion quality."));
1212 gc->setLabel(tr(
"Sample rate conversion"));
1214 gc->addSelection(tr(
"Disabled",
"Sample rate conversion"),
"-1");
1215 gc->addSelection(tr(
"Fastest",
"Sample rate conversion"),
"0");
1216 gc->addSelection(tr(
"Good",
"Sample rate conversion"),
"1",
true);
1217 gc->addSelection(tr(
"Best",
"Sample rate conversion"),
"2");
1219 gc->setHelpText(tr(
"Set the quality of audio sample-rate "
1220 "conversion. \"%1\" (default) provides the best "
1221 "compromise between CPU usage and quality. \"%2\" "
1222 "lets the audio device handle sample-rate conversion.")
1223 .arg(tr(
"Good",
"Sample rate conversion"),
1224 tr(
"Disabled",
"Sample rate conversion")));
1233 gc->setLabel(tr(
"Force audio device output to 48kHz"));
1234 gc->setValue(
false);
1236 gc->setHelpText(tr(
"Force audio sample rate to 48kHz. Some audio devices "
1237 "will report various rates, but they ultimately "
1246 gc->setLabel(tr(
"Separate digital output device"));
1248 gc->setValue(
false);
1250 gc->setHelpText(tr(
"Use a distinct digital output device from default. "
1251 "(default is not checked)"));
1260 gc->setLabel(tr(
"Digital output device"));
1263 gc->addSelection(QCoreApplication::translate(
"(Common)",
"Default"),
1266 gc->addSelection(
"DirectX:Primary Sound Driver");
1268 gc->addSelection(
"ALSA:iec958:{ AES0 0x02 }",
1269 "ALSA:iec958:{ AES0 0x02 }");
1270 gc->addSelection(
"ALSA:hdmi",
"ALSA:hdmi");
1271 gc->addSelection(
"ALSA:plughw:0,3",
"ALSA:plughw:0,3");
1274 gc->setHelpText(tr(
"Audio output device to use for digital audio. This "
1275 "value is currently only used with ALSA and DirectX "
1284 gc->setLabel(tr(
"SPDIF 48kHz rate override"));
1286 gc->setValue(
false);
1288 gc->setHelpText(tr(
"ALSA only. By default, let ALSA determine the "
1289 "passthrough sampling rate. If checked set the sampling "
1290 "rate to 48kHz for passthrough. (default is not "
1299 gc->setLabel(tr(
"HBR passthrough support"));
1303 gc->setHelpText(tr(
"HBR support is required for TrueHD and DTS-HD "
1304 "passthrough. If unchecked, Myth will limit the "
1305 "passthrough bitrate to 6.144Mbit/s. This will "
1306 "disable True-HD passthrough, however will allow "
1307 "DTS-HD content to be sent as DTS-HD Hi-Res. (default "
void Load(void) override
Load data which will ultimately be displayed on-screen or used to determine what appears on-screen (S...
AudioConfigScreen(MythScreenStack *parent, const char *name, GroupSetting *groupSetting)
void Init(void) override
Used after calling Load() to assign data to widgets and other UI initilisation which is prohibited in...
void UpdateVisibility(StandardSetting *)
AudioDeviceComboBox * m_outputDevice
HostCheckBoxSetting * m_passThroughOverride
ADCMap & AudioDeviceMap(void)
AudioOutputSettings UpdateCapabilitiesAC3(void)
HostComboBoxSetting * m_audioUpmixType
static const std::array< const char *, 2 > kMixerControlControls
static HostComboBoxSetting * PassThroughOutputDevice()
HostCheckBoxSetting * m_trueHDPassThrough
static HostComboBoxSetting * MixerDevice()
static HostCheckBoxSetting * AudioUpmix()
static HostCheckBoxSetting * DTSPassThrough()
static HostCheckBoxSetting * SRCQualityOverride()
static HostCheckBoxSetting * TrueHDPassThrough()
HostCheckBoxSetting * m_dtsPassThrough
void CheckConfiguration(void)
static HostCheckBoxSetting * EAC3PassThrough()
static HostComboBoxSetting * AudioUpmixType()
static HostCheckBoxSetting * AC3PassThrough()
static HostCheckBoxSetting * HBRPassthrough()
HostComboBoxSetting * m_passThroughDeviceOverride
HostCheckBoxSetting * m_dtsHDPassThrough
static HostComboBoxSetting * MixerControl()
static HostCheckBoxSetting * Audio48kOverride()
HostCheckBoxSetting * m_ac3PassThrough
static HostComboBoxSetting * MaxAudioChannels()
QString m_lastAudioDevice
static HostCheckBoxSetting * MPCM()
HostCheckBoxSetting * m_mpcm
GroupSetting * m_triggerDigital
HostCheckBoxSetting * m_eac3PassThrough
static HostCheckBoxSetting * DTSHDPassThrough()
HostComboBoxSetting * m_maxAudioChannels
static HostCheckBoxSetting * MythControlsVolume()
AudioOutput::ADCVect m_devices
AudioOutputSettings UpdateCapabilities(bool restore=true, bool AC3=false)
static HostCheckBoxSetting * SPDIFRateOverride()
static HostSpinBoxSetting * PCMVolume()
void setMPCMEnabled(bool flag)
AudioOutput::ADCVect & AudioDeviceVect(void)
static HostComboBoxSetting * SRCQuality()
static HostSpinBoxSetting * MixerVolume()
HostCheckBoxSetting * m_audioUpmix
static HostCheckBoxSetting * PassThroughOverride()
void AudioDescriptionHelp(StandardSetting *setting)
void edit(MythScreenType *screen) override
AudioConfigSettings * m_parent
AudioDeviceComboBox(AudioConfigSettings *parent)
bool IsSupportedChannels(int channels)
int BestSupportedChannels()
bool canFeature(DigitalFeature arg) const
return DigitalFeature mask.
void SetBestSupportedChannels(int channels)
Force set the greatest number of channels supported by the audio device.
void setFeature(DigitalFeature arg)
set the provided digital feature possible values are:
int canPassthrough() const
bool IsInvalid() const
return true if class instance is marked invalid.
AudioOutputSettings m_settings
virtual void Drain(void)=0
static AudioOutput * OpenAudio(const QString &main_device, const QString &passthru_device, AudioFormat format, int channels, AVCodecID codec, int samplerate, AudioOutputSource source, bool set_initial_vol, bool passthru, int upmixer_startup=0, AudioOutputSettings *custom=nullptr)
virtual std::chrono::milliseconds LengthLastData(void) const
static ADCVect * GetOutputList(void)
QVector< AudioDeviceConfig > ADCVect
static AudioDeviceConfig * GetAudioDeviceConfig(QString &name, const QString &desc, bool willsuspendpa=false)
virtual void Pause(bool paused)=0
bool playPinkNoise(char *frames, int channels, int channel, int count, int bits)
Generates and plays pink noise from a speaker for testing.
void setChannel(int channel)
void run() override
Runs the Qt event loop unless we have a QRunnable, in which case we run the runnable run instead.
AudioTestThread(QObject *parent, QString main, QString passthrough, int channels, AudioOutputSettings &settings, bool hd)
AudioOutput * m_audioOutput
~AudioTestThread() override
ButtonStandardSetting * m_startButton
ButtonStandardSetting * m_frontright
ButtonStandardSetting * m_lfe
ButtonStandardSetting * m_surroundleft
ButtonStandardSetting * m_frontleft
TransMythUICheckBoxSetting * m_hd
ButtonStandardSetting * m_center
ButtonStandardSetting * m_surroundright
void togglequality(const QString &)
ButtonStandardSetting * m_rearright
bool event(QEvent *event) override
ButtonStandardSetting * m_rearleft
AudioOutputSettings m_settings
void UpdateCapabilities(const QString &main, const QString &passthrough, int channels, const AudioOutputSettings &settings)
ChannelChangedEvent(QString channame, bool fulltest)
static const Type kEventType
This is a wrapper around QThread that does several additional things.
bool isRunning(void) const
void RunProlog(void)
Sets up a thread, call this if you reimplement run().
void start(QThread::Priority p=QThread::InheritPriority)
Tell MThread to start running the thread in the near future.
void RunEpilog(void)
Cleans up a thread's resources, call this if you reimplement run().
bool wait(std::chrono::milliseconds time=std::chrono::milliseconds::max())
Wait for the MThread to exit, with a maximum timeout.
Dialog asking for user confirmation.
QString GetSetting(const QString &key, const QString &defaultval="")
int GetNumSetting(const QString &key, int defaultval=0)
bool GetBoolSetting(const QString &key, bool defaultval=false)
MythScreenStack * GetMainStack()
virtual void AddScreen(MythScreenType *screen, bool allowFade=true)
Screen in which all other widgets are contained and rendered.
void SetBusyPopupMessage(const QString &message)
void addSelection(const QString &label, QString value=QString(), bool select=false)
void edit(MythScreenType *screen) override
void Init(void) override
Used after calling Load() to assign data to widgets and other UI initilisation which is prohibited in...
void Load(void) override
Load data which will ultimately be displayed on-screen or used to determine what appears on-screen (S...
GroupSetting * GetGroupSettings(void) const
virtual void addChild(StandardSetting *child)
void addTargetedChild(const QString &value, StandardSetting *setting)
virtual void setHelpText(const QString &str)
bool haveChanged()
Return true if the setting have changed or any of its children.
void valueChanged(const QString &newValue)
virtual QString getValue(void) const
virtual void setEnabled(bool enabled)
virtual void setLabel(QString str)
void setChanged(bool changed)
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
MythConfirmationDialog * ShowOkPopup(const QString &message, bool showCancel)
Non-blocking version of MythPopupBox::showOkPopup()
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
MythMainWindow * GetMythMainWindow(void)
QDateTime current(bool stripped)
Returns current Date and Time in UTC.
uint fillSelectionsFromDir(const QDir &dir, uint minor_min, uint minor_max, const QString &card, const QRegularExpression &driver, bool allow_duplicates, V2CaptureDeviceList *pList, const QString &cardType)
VERBOSE_PREAMBLE Most true