Go to the documentation of this file.
12 #include <QCoreApplication>
18 #include "mythconfig.h"
28 #include "libavformat/avformat.h"
36 QString dflt =
"OpenSLES:";
38 QString dflt =
"ALSA:default";
39 #elif USING_PULSEOUTPUT
40 QString dflt =
"PulseAudio:default";
42 QString dflt =
"CoreAudio:";
44 QString dflt =
"Windows:";
46 QString dflt =
"NULL";
74 for (
const auto & it : qAsConst(vect))
76 if (value != it.m_name)
104 if (settings ==
nullptr)
106 settings->CheckConfiguration();
117 rescan->setLabel(tr(
"Rescan"));
118 rescan->setHelpText(tr(
"Rescan for available audio devices. "
119 "Current entry will be checked and "
120 "capability entries populated."));
141 advancedSettings->setLabel(tr(
"Advanced Audio Settings"));
142 advancedSettings->setHelpText(tr(
"Enable extra audio settings. Under most "
143 "usage all options should be left alone"));
200 QString msg = tr(
"%1 is invalid or not useable.").arg(name);
204 LOG(VB_GENERAL, LOG_ERR, QString(
"Audio device %1 isn't usable")
213 QString pt_msg = tr(
"Passthrough device is invalid or not useable. Check "
214 "configuration in Advanced Settings:") +
219 LOG(VB_GENERAL, LOG_ERR, QString(
"Audio device %1 isn't usable")
242 for (
const auto & dev : qAsConst(*list))
274 bool restore,
bool AC3)
276 int max_speakers = 8;
277 int realmax_speakers = 8;
279 bool invalid =
false;
312 LOG(VB_AUDIO, LOG_ERR, QString(
"Update not found (%1)").arg(out));
320 settingsdigital = bForceDigital ?
322 .m_settings : settings;
340 if (max_speakers > 2 && !bLPCM)
342 if (max_speakers == 2 && bAC3)
369 if (cur_speakers > max_speakers)
371 LOG(VB_AUDIO, LOG_INFO, QString(
"Reset device %1").arg(out));
372 cur_speakers = max_speakers;
378 for (
int i = 1; i <= max_speakers; i++)
388 txt = QCoreApplication::translate(
"(Common)",
"Stereo");
391 txt = QCoreApplication::translate(
"(Common)",
"5.1");
394 txt = QCoreApplication::translate(
"(Common)",
"7.1");
435 QString name =
"MaxChannels";
439 gc->setLabel(tr(
"Speaker configuration"));
441 gc->addSelection(QCoreApplication::translate(
"(Common)",
"Stereo"),
444 gc->setHelpText(tr(
"Select the maximum number of audio "
445 "channels supported by your receiver "
454 gc->setLabel(tr(
"Upconvert stereo to 5.1 surround"));
458 gc->setHelpText(tr(
"If enabled, MythTV will upconvert stereo "
459 "to 5.1 audio. You can enable or disable "
460 "the upconversion during playback at any time."));
468 gc->setLabel(tr(
"Upmix Quality"));
470 gc->addSelection(tr(
"Passive"),
"0");
471 gc->addSelection(tr(
"Hall",
"Upmix Quality"),
"3");
472 gc->addSelection(tr(
"Good",
"Upmix Quality"),
"1");
473 gc->addSelection(tr(
"Best",
"Upmix Quality"),
"2",
true);
475 gc->setHelpText(tr(
"Set the audio surround-upconversion quality."));
484 gc->setLabel(tr(
"Dolby Digital"));
488 gc->setHelpText(tr(
"Enable if your amplifier or sound decoder "
489 "supports AC-3/Dolby Digital. You must use a digital "
490 "connection. Uncheck if using an analog connection."));
498 gc->setLabel(tr(
"DTS"));
502 gc->setHelpText(tr(
"Enable if your amplifier or sound decoder supports "
503 "DTS. You must use a digital connection. Uncheck "
504 "if using an analog connection"));
512 gc->setLabel(tr(
"E-AC-3"));
516 gc->setHelpText(tr(
"Enable if your amplifier or sound decoder supports "
517 "E-AC-3 (DD+). You must use a HDMI connection."));
525 gc->setLabel(tr(
"TrueHD"));
529 gc->setHelpText(tr(
"Enable if your amplifier or sound decoder supports "
530 "Dolby TrueHD. You must use a HDMI connection."));
538 gc->setLabel(tr(
"DTS-HD"));
542 gc->setHelpText(tr(
"Enable if your amplifier or sound decoder supports "
543 "DTS-HD. You must use a HDMI connection."));
558 LOG(VB_GENERAL, LOG_ERR,
559 QString(
"Passthru device %1 isn't usable "
560 "Check audio configuration").arg(name));
573 const QDir& dir,
bool absPath =
true)
576 QFileInfoList entries = dir.entryInfoList();
577 for (
const auto & fi : qAsConst(entries))
591 QString passthrough =
600 : QEvent(kEventType),
601 m_channel(
std::move(channame)),
607 QString
main, QString passthrough,
612 m_parent(parent), m_channels(channels), m_device(
std::move(
main)),
613 m_passthrough(
std::move(passthrough)), m_hd(hd)
622 true,
false, 0, &settings);
630 static_cast<QEvent::Type
>(QEvent::registerEventType());
648 errMsg = tr(
"Unable to create AudioOutput.");
663 std::array<std::array<int,8>,7> smptelayout {{
668 { 0, 2, 1, 5, 4, 3 },
669 { 0, 2, 1, 6, 4, 5, 3 },
670 { 0, 2, 1, 7, 5, 4, 6, 3 },
675 char *frames_in =
new char[
static_cast<unsigned long>(
m_channels) * 1024 *
sizeof(int32_t) + 15];
676 char *frames =
reinterpret_cast<char *
>(
reinterpret_cast<long>(frames_in + 15) & ~0xf);
700 channel =
"frontleft";
703 channel =
"frontright";
713 channel =
"surroundleft";
715 channel =
"rearright";
717 channel =
"rearleft";
721 channel =
"surroundright";
723 channel =
"surroundleft";
725 channel =
"rearright";
729 channel =
"surroundright";
731 channel =
"surroundleft";
734 channel =
"surroundright";
737 QCoreApplication::postEvent(
740 LOG(VB_AUDIO, LOG_INFO, QString(
"AudioTest: %1 (%2->%3)")
741 .arg(channel).arg(i).arg(
current));
753 LOG(VB_AUDIO, LOG_ERR,
"AddData() Audio buffer "
754 "overflow, audio data lost!");
760 std::this_thread::sleep_for(500ms);
778 setLabel(tr(
"Audio Configuration Testing"));
779 setHelpText(tr(
"Will play a test pattern on all configured "
849 "supported by your audio card. This will be "
850 "a good place to start troubleshooting "
851 "potential errors"));
869 const QString &passthrough,
919 else if (this->sender() ==
m_lfe)
925 else if (this->sender() ==
m_center)
962 QString msg = tr(
"Audio device is invalid or not useable.");
978 return QObject::event(
event);
982 return GroupSetting::event(
event);
984 QString channel = cce->m_channel;
986 if (!cce->m_fulltest)
987 return GroupSetting::event(
event);
998 if (channel ==
"frontleft")
1002 else if (channel ==
"frontright")
1006 else if (channel ==
"center")
1010 else if (channel ==
"lfe")
1014 else if (channel ==
"surroundleft")
1018 else if (channel ==
"surroundright")
1022 else if (channel ==
"rearleft")
1026 else if (channel ==
"rearright")
1046 return GroupSetting::event(
event);
1054 gc->setLabel(tr(
"Use internal volume controls"));
1058 gc->setHelpText(tr(
"If enabled, MythTV will control the PCM and "
1059 "master mixer volume. Disable this option if you "
1060 "prefer to control the volume externally (for "
1061 "example, using your amplifier) or if you use an "
1062 "external mixer program."));
1074 gc->setLabel(tr(
"Mixer device"));
1077 QDir dev(
"/dev",
"mixer*", QDir::Name, QDir::System);
1080 dev.setPath(
"/dev/sound");
1087 gc->addSelection(
"ALSA:default",
"ALSA:default");
1090 gc->addSelection(
"DirectX:",
"DirectX:");
1091 gc->addSelection(
"Windows:",
"Windows:");
1094 gc->addSelection(
"OpenSLES:",
"OpenSLES:");
1096 #if !defined(_WIN32)
1097 gc->addSelection(tr(
"software"),
"software");
1100 gc->setHelpText(tr(
"Setting the mixer device to \"%1\" lets MythTV control "
1101 "the volume of all audio at the expense of a slight "
1103 .arg(tr(
"software")));
1110 QT_TR_NOOP(
"Master")};
1116 gc->setLabel(tr(
"Mixer controls"));
1119 gc->addSelection(tr(control), control);
1121 gc->setHelpText(tr(
"Changing the volume adjusts the selected mixer."));
1130 gs->setLabel(tr(
"Master mixer volume"));
1134 gs->setHelpText(tr(
"Initial volume for the Master mixer. This affects "
1135 "all sound created by the audio device. Note: Do not "
1136 "set this too low."));
1144 gs->setLabel(tr(
"PCM mixer volume"));
1148 gs->setHelpText(tr(
"Initial volume for PCM output. Using the volume "
1149 "keys in MythTV will adjust this parameter."));
1157 gc->setLabel(tr(
"Stereo PCM Only"));
1159 gc->setValue(
false);
1161 gc->setHelpText(tr(
"Enable if your amplifier or sound decoder only "
1162 "supports 2 channel PCM (typically an old HDMI 1.0 "
1163 "device). Multichannel audio will be re-encoded to "
1164 "AC-3 when required"));
1172 gc->setLabel(tr(
"Override SRC quality"));
1174 gc->setValue(
false);
1176 gc->setHelpText(tr(
"Enable to override audio sample rate "
1177 "conversion quality."));
1185 gc->setLabel(tr(
"Sample rate conversion"));
1187 gc->addSelection(tr(
"Disabled",
"Sample rate conversion"),
"-1");
1188 gc->addSelection(tr(
"Fastest",
"Sample rate conversion"),
"0");
1189 gc->addSelection(tr(
"Good",
"Sample rate conversion"),
"1",
true);
1190 gc->addSelection(tr(
"Best",
"Sample rate conversion"),
"2");
1192 gc->setHelpText(tr(
"Set the quality of audio sample-rate "
1193 "conversion. \"%1\" (default) provides the best "
1194 "compromise between CPU usage and quality. \"%2\" "
1195 "lets the audio device handle sample-rate conversion.")
1196 .arg(tr(
"Good",
"Sample rate conversion"))
1197 .arg(tr(
"Disabled",
"Sample rate conversion")));
1206 gc->setLabel(tr(
"Force audio device output to 48kHz"));
1207 gc->setValue(
false);
1209 gc->setHelpText(tr(
"Force audio sample rate to 48kHz. Some audio devices "
1210 "will report various rates, but they ultimately "
1219 gc->setLabel(tr(
"Separate digital output device"));
1221 gc->setValue(
false);
1223 gc->setHelpText(tr(
"Use a distinct digital output device from default. "
1224 "(default is not checked)"));
1233 gc->setLabel(tr(
"Digital output device"));
1236 gc->addSelection(QCoreApplication::translate(
"(Common)",
"Default"),
1239 gc->addSelection(
"DirectX:Primary Sound Driver");
1241 gc->addSelection(
"ALSA:iec958:{ AES0 0x02 }",
1242 "ALSA:iec958:{ AES0 0x02 }");
1243 gc->addSelection(
"ALSA:hdmi",
"ALSA:hdmi");
1244 gc->addSelection(
"ALSA:plughw:0,3",
"ALSA:plughw:0,3");
1247 gc->setHelpText(tr(
"Audio output device to use for digital audio. This "
1248 "value is currently only used with ALSA and DirectX "
1257 gc->setLabel(tr(
"SPDIF 48kHz rate override"));
1259 gc->setValue(
false);
1261 gc->setHelpText(tr(
"ALSA only. By default, let ALSA determine the "
1262 "passthrough sampling rate. If checked set the sampling "
1263 "rate to 48kHz for passthrough. (default is not "
1272 gc->setLabel(tr(
"HBR passthrough support"));
1276 gc->setHelpText(tr(
"HBR support is required for TrueHD and DTS-HD "
1277 "passthrough. If unchecked, Myth will limit the "
1278 "passthrough bitrate to 6.144Mbit/s. This will "
1279 "disable True-HD passthrough, however will allow "
1280 "DTS-HD content to be sent as DTS-HD Hi-Res. (default "
QString GetError(void) const
MythScreenStack * GetMainStack()
QString m_lastAudioDevice
bool IsSupportedChannels(int channels)
void togglequality(const QString &)
void start(QThread::Priority p=QThread::InheritPriority)
Tell MThread to start running the thread in the near future.
void SetBusyPopupMessage(const QString &message)
ButtonStandardSetting * m_surroundleft
static HostCheckBoxSetting * Audio48kOverride()
static HostCheckBoxSetting * TrueHDPassThrough()
static HostComboBoxSetting * MixerControl()
static HostComboBoxSetting * MaxAudioChannels()
AudioTestThread(QObject *parent, QString main, QString passthrough, int channels, AudioOutputSettings &settings, bool hd)
static const std::array< const char *, 2 > kMixerControlControls
bool wait(std::chrono::milliseconds time=std::chrono::milliseconds::max())
Wait for the MThread to exit, with a maximum timeout.
static HostCheckBoxSetting * SRCQualityOverride()
static char * GeneratePinkFrames(char *frames, int channels, int channel, int count, int bits=16)
void UpdateVisibility(StandardSetting *)
static HostSpinBoxSetting * MixerVolume()
HostComboBoxSetting * m_passThroughDeviceOverride
static HostCheckBoxSetting * PassThroughOverride()
GroupSetting * GetGroupSettings(void) const
HostCheckBoxSetting * m_trueHDPassThrough
void edit(MythScreenType *screen) override
#define LOG(_MASK_, _LEVEL_, _QSTRING_)
void RunProlog(void)
Sets up a thread, call this if you reimplement run().
void addTargetedChild(const QString &value, StandardSetting *setting)
Screen in which all other widgets are contained and rendered.
static HostSpinBoxSetting * PCMVolume()
ButtonStandardSetting * m_frontleft
virtual std::chrono::milliseconds LengthLastData(void) const
static HostComboBoxSetting * PassThroughOutputDevice()
ButtonStandardSetting * m_surroundright
QDateTime current(bool stripped)
Returns current Date and Time in UTC.
bool haveChanged()
Return true if the setting have changed or any of its children.
VERBOSE_PREAMBLE Most true
TransMythUICheckBoxSetting * m_hd
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)
HostCheckBoxSetting * m_ac3PassThrough
virtual void Drain(void)=0
AudioDeviceComboBox(AudioConfigSettings *parent)
void edit(MythScreenType *screen) override
static HostCheckBoxSetting * EAC3PassThrough()
ChannelChangedEvent(QString channame, bool fulltest)
void setChanged(bool changed)
static HostCheckBoxSetting * MPCM()
static HostCheckBoxSetting * HBRPassthrough()
bool event(QEvent *event) override
virtual void addChild(StandardSetting *child)
void run() override
Runs the Qt event loop unless we have a QRunnable, in which case we run the runnable run instead.
void Load(void) override
Load data which will ultimately be displayed on-screen or used to determine what appears on-screen (S...
virtual void Pause(bool paused)=0
GroupSetting * m_triggerDigital
void setChannel(int channel)
ButtonStandardSetting * m_frontright
static HostCheckBoxSetting * MythControlsVolume()
int BestSupportedChannels()
int canPassthrough() const
HostComboBoxSetting * m_maxAudioChannels
HostCheckBoxSetting * m_mpcm
AudioOutputSettings m_settings
void CheckConfiguration(void)
virtual void setHelpText(const QString &str)
AudioOutput::ADCVect m_devices
void RunEpilog(void)
Cleans up a thread's resources, call this if you reimplement run().
static AudioDeviceConfig * GetAudioDeviceConfig(QString &name, const QString &desc, bool willsuspendpa=false)
static HostComboBoxSetting * MixerDevice()
virtual QString getValue(void) const
bool canFeature(DigitalFeature arg) const
return DigitalFeature mask.
AudioDeviceComboBox * m_outputDevice
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
AudioOutputSettings UpdateCapabilities(bool restore=true, bool AC3=false)
AudioConfigSettings * m_parent
void setMPCMEnabled(bool flag)
ADCMap & AudioDeviceMap(void)
void setFeature(DigitalFeature arg)
set the provided digital feature possible values are:
int GetNumSetting(const QString &key, int defaultval=0)
AudioOutput::ADCVect & AudioDeviceVect(void)
bool IsInvalid() const
return true if class instance is marked invalid.
static HostComboBoxSetting * SRCQuality()
static HostCheckBoxSetting * DTSPassThrough()
virtual void setLabel(QString str)
HostCheckBoxSetting * m_dtsPassThrough
AudioOutput * m_audioOutput
~AudioTestThread() override
bool GetBoolSetting(const QString &key, bool defaultval=false)
virtual bool AddFrames(void *buffer, int frames, std::chrono::milliseconds timecode)=0
Add frames to the audiobuffer for playback.
static HostCheckBoxSetting * DTSHDPassThrough()
void valueChanged(const QString &newValue)
AudioConfigScreen(MythScreenStack *parent, const char *name, GroupSetting *groupSetting)
virtual void setEnabled(bool enabled)
void addSelection(const QString &label, QString value=QString(), bool select=false)
ButtonStandardSetting * m_center
void UpdateCapabilities(const QString &main, const QString &passthrough, int channels, const AudioOutputSettings &settings)
HostComboBoxSetting * m_audioUpmixType
AudioOutputSettings UpdateCapabilitiesAC3(void)
static HostCheckBoxSetting * AC3PassThrough()
Dialog asking for user confirmation. Ok and optional Cancel button.
void Init(void) override
Used after calling Load() to assign data to widgets and other UI initilisation which is prohibited in...
ButtonStandardSetting * m_startButton
static HostCheckBoxSetting * AudioUpmix()
HostCheckBoxSetting * m_passThroughOverride
HostCheckBoxSetting * m_eac3PassThrough
void Load(void) override
Load data which will ultimately be displayed on-screen or used to determine what appears on-screen (S...
AudioOutputSettings m_settings
This is a wrapper around QThread that does several additional things.
MythMainWindow * GetMythMainWindow(void)
bool isRunning(void) const
void AudioDescriptionHelp(StandardSetting *setting)
ButtonStandardSetting * m_rearleft
void Init(void) override
Used after calling Load() to assign data to widgets and other UI initilisation which is prohibited in...
static HostComboBoxSetting * AudioUpmixType()
ButtonStandardSetting * m_lfe
AudioFormat BestSupportedFormat()
ButtonStandardSetting * m_rearright
void SetBestSupportedChannels(int channels)
Force set the greatest number of channels supported by the audio device.
HostCheckBoxSetting * m_dtsHDPassThrough
QVector< AudioDeviceConfig > ADCVect
virtual void AddScreen(MythScreenType *screen, bool allowFade=true)
MythConfirmationDialog * ShowOkPopup(const QString &message, bool showCancel)
Non-blocking version of MythPopupBox::showOkPopup()
static HostCheckBoxSetting * SPDIFRateOverride()
HostCheckBoxSetting * m_audioUpmix
static void fillSelectionsFromDir(HostComboBoxSetting *comboBox, const QDir &dir, bool absPath=true)
static ADCVect * GetOutputList(void)
QString GetSetting(const QString &key, const QString &defaultval="")