Go to the documentation of this file.
13 #include <QCoreApplication>
20 #include "libmythbase/mythconfig.h"
32 #include "libavformat/avformat.h"
40 QString dflt =
"OpenSLES:";
42 QString dflt =
"ALSA:default";
43 #elif USING_PULSEOUTPUT
44 QString dflt =
"PulseAudio:default";
45 #elif defined(Q_OS_DARWIN)
46 QString dflt =
"CoreAudio:";
48 QString dflt =
"Windows:";
50 QString dflt =
"NULL";
78 for (
const auto & it : std::as_const(vect))
80 if (value != it.m_name)
108 if (settings ==
nullptr)
110 settings->CheckConfiguration();
115 m_passThroughOverride(PassThroughOverride()),
116 m_passThroughDeviceOverride(PassThroughOutputDevice())
124 rescan->setLabel(tr(
"Rescan"));
125 rescan->setHelpText(tr(
"Rescan for available audio devices. "
126 "Current entry will be checked and "
127 "capability entries populated."));
147 advancedSettings->setLabel(tr(
"Advanced Audio Settings"));
148 advancedSettings->setHelpText(tr(
"Enable extra audio settings. Under most "
149 "usage all options should be left alone"));
204 QString msg = tr(
"%1 is invalid or not useable.").arg(name);
208 LOG(VB_GENERAL, LOG_ERR, QString(
"Audio device %1 isn't usable")
217 QString pt_msg = tr(
"Passthrough device is invalid or not useable. Check "
218 "configuration in Advanced Settings:") +
223 LOG(VB_GENERAL, LOG_ERR, QString(
"Audio device %1 isn't usable")
246 for (
const auto & dev : std::as_const(*list))
278 bool restore,
bool AC3)
280 int max_speakers = 8;
281 int realmax_speakers = 8;
283 bool invalid =
false;
316 LOG(VB_AUDIO, LOG_ERR, QString(
"Update not found (%1)").arg(out));
324 settingsdigital = bForceDigital ?
326 .m_settings : settings;
344 if (max_speakers > 2 && !bLPCM)
346 if (max_speakers == 2 && bAC3)
373 if (cur_speakers > max_speakers)
375 LOG(VB_AUDIO, LOG_INFO, QString(
"Reset device %1").arg(out));
376 cur_speakers = max_speakers;
382 for (
int i = 1; i <= max_speakers; i++)
392 txt = QCoreApplication::translate(
"(Common)",
"Stereo");
395 txt = QCoreApplication::translate(
"(Common)",
"5.1");
398 txt = QCoreApplication::translate(
"(Common)",
"7.1");
439 QString name =
"MaxChannels";
443 gc->setLabel(tr(
"Speaker configuration"));
445 gc->addSelection(QCoreApplication::translate(
"(Common)",
"Stereo"),
448 gc->setHelpText(tr(
"Select the maximum number of audio "
449 "channels supported by your receiver "
458 gc->setLabel(tr(
"Upconvert stereo to 5.1 surround"));
462 gc->setHelpText(tr(
"If enabled, MythTV will upconvert stereo "
463 "to 5.1 audio. You can enable or disable "
464 "the upconversion during playback at any time."));
472 gc->setLabel(tr(
"Upmix Quality"));
474 gc->addSelection(tr(
"Passive"),
"0");
475 gc->addSelection(tr(
"Hall",
"Upmix Quality"),
"3");
476 gc->addSelection(tr(
"Good",
"Upmix Quality"),
"1");
477 gc->addSelection(tr(
"Best",
"Upmix Quality"),
"2",
true);
479 gc->setHelpText(tr(
"Set the audio surround-upconversion quality."));
488 gc->setLabel(tr(
"Dolby Digital"));
492 gc->setHelpText(tr(
"Enable if your amplifier or sound decoder "
493 "supports AC-3/Dolby Digital. You must use a digital "
494 "connection. Uncheck if using an analog connection."));
502 gc->setLabel(tr(
"DTS"));
506 gc->setHelpText(tr(
"Enable if your amplifier or sound decoder supports "
507 "DTS. You must use a digital connection. Uncheck "
508 "if using an analog connection"));
516 gc->setLabel(tr(
"E-AC-3"));
520 gc->setHelpText(tr(
"Enable if your amplifier or sound decoder supports "
521 "E-AC-3 (DD+). You must use a HDMI connection."));
529 gc->setLabel(tr(
"TrueHD"));
533 gc->setHelpText(tr(
"Enable if your amplifier or sound decoder supports "
534 "Dolby TrueHD. You must use a HDMI connection."));
542 gc->setLabel(tr(
"DTS-HD"));
546 gc->setHelpText(tr(
"Enable if your amplifier or sound decoder supports "
547 "DTS-HD. You must use a HDMI connection."));
562 LOG(VB_GENERAL, LOG_ERR,
563 QString(
"Passthru device %1 isn't usable "
564 "Check audio configuration").arg(name));
577 const QDir& dir,
bool absPath =
true)
580 QFileInfoList entries = dir.entryInfoList();
581 for (
const auto & fi : std::as_const(entries))
595 QString passthrough =
604 : QEvent(kEventType),
605 m_channel(std::move(channame)),
611 QString
main, QString passthrough,
616 m_parent(parent), m_channels(channels), m_device(std::move(
main)),
617 m_passthrough(std::move(passthrough)), m_hd(hd),
618 m_samplerate(hd ? settings.BestSupportedRate() : 48000),
619 m_format(hd ? settings.BestSupportedFormat() :
FORMAT_S16)
625 true,
false, 0, &settings);
633 static_cast<QEvent::Type
>(QEvent::registerEventType());
651 errMsg = tr(
"Unable to create AudioOutput.");
666 std::array<std::array<int,8>,7> smptelayout {{
671 { 0, 2, 1, 5, 4, 3 },
672 { 0, 2, 1, 6, 4, 5, 3 },
673 { 0, 2, 1, 7, 5, 4, 6, 3 },
678 char *frames =
new (std::align_val_t(16))
char[
m_channels * 1024_UZ *
sizeof(int32_t)];
702 channel =
"frontleft";
705 channel =
"frontright";
715 channel =
"surroundleft";
717 channel =
"rearright";
719 channel =
"rearleft";
723 channel =
"surroundright";
725 channel =
"surroundleft";
727 channel =
"rearright";
731 channel =
"surroundright";
733 channel =
"surroundleft";
736 channel =
"surroundright";
739 QCoreApplication::postEvent(
742 LOG(VB_AUDIO, LOG_INFO, QString(
"AudioTest: %1 (%2->%3)")
743 .arg(channel).arg(i).arg(
current));
755 LOG(VB_AUDIO, LOG_ERR,
"AddData() Audio buffer "
756 "overflow, audio data lost!");
762 std::this_thread::sleep_for(500ms);
780 setLabel(tr(
"Audio Configuration Testing"));
781 setHelpText(tr(
"Will play a test pattern on all configured "
813 QString surroundleft;
867 "supported by your audio card. This will be "
868 "a good place to start troubleshooting "
869 "potential errors"));
887 const QString &passthrough,
937 else if (this->sender() ==
m_lfe)
959 else if (this->sender() ==
m_center)
998 QString msg = tr(
"Audio device is invalid or not useable.");
1014 return QObject::event(
event);
1018 return GroupSetting::event(
event);
1020 QString channel = cce->m_channel;
1022 if (!cce->m_fulltest)
1023 return GroupSetting::event(
event);
1034 if (channel ==
"frontleft")
1038 else if (channel ==
"frontright")
1042 else if (channel ==
"center")
1046 else if (channel ==
"lfe")
1050 else if (channel ==
"surroundleft")
1054 else if (channel ==
"surroundright")
1058 else if (channel ==
"rearleft")
1062 else if (channel ==
"rearright")
1082 return GroupSetting::event(
event);
1090 gc->setLabel(tr(
"Use internal volume controls"));
1094 gc->setHelpText(tr(
"If enabled, MythTV will control the PCM and "
1095 "master mixer volume. Disable this option if you "
1096 "prefer to control the volume externally (for "
1097 "example, using your amplifier) or if you use an "
1098 "external mixer program."));
1110 gc->setLabel(tr(
"Mixer device"));
1113 QDir dev(
"/dev",
"mixer*", QDir::Name, QDir::System);
1116 dev.setPath(
"/dev/sound");
1123 gc->addSelection(
"ALSA:default",
"ALSA:default");
1126 gc->addSelection(
"DirectX:",
"DirectX:");
1127 gc->addSelection(
"Windows:",
"Windows:");
1130 gc->addSelection(
"OpenSLES:",
"OpenSLES:");
1132 #if !defined(_WIN32)
1133 gc->addSelection(tr(
"software"),
"software");
1136 gc->setHelpText(tr(
"Setting the mixer device to \"%1\" lets MythTV control "
1137 "the volume of all audio at the expense of a slight "
1139 .arg(tr(
"software")));
1146 QT_TR_NOOP(
"Master")};
1152 gc->setLabel(tr(
"Mixer controls"));
1155 gc->addSelection(tr(control), control);
1157 gc->setHelpText(tr(
"Changing the volume adjusts the selected mixer."));
1166 gs->setLabel(tr(
"Master mixer volume"));
1170 gs->setHelpText(tr(
"Initial volume for the Master mixer. This affects "
1171 "all sound created by the audio device. Note: Do not "
1172 "set this too low."));
1180 gs->setLabel(tr(
"PCM mixer volume"));
1184 gs->setHelpText(tr(
"Initial volume for PCM output. Using the volume "
1185 "keys in MythTV will adjust this parameter."));
1193 gc->setLabel(tr(
"Stereo PCM Only"));
1195 gc->setValue(
false);
1197 gc->setHelpText(tr(
"Enable if your amplifier or sound decoder only "
1198 "supports 2 channel PCM (typically an old HDMI 1.0 "
1199 "device). Multichannel audio will be re-encoded to "
1200 "AC-3 when required"));
1208 gc->setLabel(tr(
"Override SRC quality"));
1210 gc->setValue(
false);
1212 gc->setHelpText(tr(
"Enable to override audio sample rate "
1213 "conversion quality."));
1221 gc->setLabel(tr(
"Sample rate conversion"));
1223 gc->addSelection(tr(
"Disabled",
"Sample rate conversion"),
"-1");
1224 gc->addSelection(tr(
"Fastest",
"Sample rate conversion"),
"0");
1225 gc->addSelection(tr(
"Good",
"Sample rate conversion"),
"1",
true);
1226 gc->addSelection(tr(
"Best",
"Sample rate conversion"),
"2");
1228 gc->setHelpText(tr(
"Set the quality of audio sample-rate "
1229 "conversion. \"%1\" (default) provides the best "
1230 "compromise between CPU usage and quality. \"%2\" "
1231 "lets the audio device handle sample-rate conversion.")
1232 .arg(tr(
"Good",
"Sample rate conversion"),
1233 tr(
"Disabled",
"Sample rate conversion")));
1242 gc->setLabel(tr(
"Force audio device output to 48kHz"));
1243 gc->setValue(
false);
1245 gc->setHelpText(tr(
"Force audio sample rate to 48kHz. Some audio devices "
1246 "will report various rates, but they ultimately "
1255 gc->setLabel(tr(
"Separate digital output device"));
1257 gc->setValue(
false);
1259 gc->setHelpText(tr(
"Use a distinct digital output device from default. "
1260 "(default is not checked)"));
1269 gc->setLabel(tr(
"Digital output device"));
1272 gc->addSelection(QCoreApplication::translate(
"(Common)",
"Default"),
1275 gc->addSelection(
"DirectX:Primary Sound Driver");
1277 gc->addSelection(
"ALSA:iec958:{ AES0 0x02 }",
1278 "ALSA:iec958:{ AES0 0x02 }");
1279 gc->addSelection(
"ALSA:hdmi",
"ALSA:hdmi");
1280 gc->addSelection(
"ALSA:plughw:0,3",
"ALSA:plughw:0,3");
1283 gc->setHelpText(tr(
"Audio output device to use for digital audio. This "
1284 "value is currently only used with ALSA and DirectX "
1293 gc->setLabel(tr(
"SPDIF 48kHz rate override"));
1295 gc->setValue(
false);
1297 gc->setHelpText(tr(
"ALSA only. By default, let ALSA determine the "
1298 "passthrough sampling rate. If checked set the sampling "
1299 "rate to 48kHz for passthrough. (default is not "
1308 gc->setLabel(tr(
"HBR passthrough support"));
1312 gc->setHelpText(tr(
"HBR support is required for TrueHD and DTS-HD "
1313 "passthrough. If unchecked, Myth will limit the "
1314 "passthrough bitrate to 6.144Mbit/s. This will "
1315 "disable True-HD passthrough, however will allow "
1316 "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
static const Type kEventType
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
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="")