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 : qAsConst(vect))
80 if (value != it.m_name)
108 if (settings ==
nullptr)
110 settings->CheckConfiguration();
121 rescan->setLabel(tr(
"Rescan"));
122 rescan->setHelpText(tr(
"Rescan for available audio devices. "
123 "Current entry will be checked and "
124 "capability entries populated."));
145 advancedSettings->setLabel(tr(
"Advanced Audio Settings"));
146 advancedSettings->setHelpText(tr(
"Enable extra audio settings. Under most "
147 "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 : qAsConst(*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 : qAsConst(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_format(hd ? settings.BestSupportedFormat() :
FORMAT_S16)
626 true,
false, 0, &settings);
634 static_cast<QEvent::Type
>(QEvent::registerEventType());
652 errMsg = tr(
"Unable to create AudioOutput.");
667 std::array<std::array<int,8>,7> smptelayout {{
672 { 0, 2, 1, 5, 4, 3 },
673 { 0, 2, 1, 6, 4, 5, 3 },
674 { 0, 2, 1, 7, 5, 4, 6, 3 },
679 char *frames =
new (std::align_val_t(16))
char[
m_channels * 1024_UZ *
sizeof(int32_t)];
703 channel =
"frontleft";
706 channel =
"frontright";
716 channel =
"surroundleft";
718 channel =
"rearright";
720 channel =
"rearleft";
724 channel =
"surroundright";
726 channel =
"surroundleft";
728 channel =
"rearright";
732 channel =
"surroundright";
734 channel =
"surroundleft";
737 channel =
"surroundright";
740 QCoreApplication::postEvent(
743 LOG(VB_AUDIO, LOG_INFO, QString(
"AudioTest: %1 (%2->%3)")
744 .arg(channel).arg(i).arg(
current));
756 LOG(VB_AUDIO, LOG_ERR,
"AddData() Audio buffer "
757 "overflow, audio data lost!");
763 std::this_thread::sleep_for(500ms);
781 setLabel(tr(
"Audio Configuration Testing"));
782 setHelpText(tr(
"Will play a test pattern on all configured "
852 "supported by your audio card. This will be "
853 "a good place to start troubleshooting "
854 "potential errors"));
872 const QString &passthrough,
922 else if (this->sender() ==
m_lfe)
928 else if (this->sender() ==
m_center)
965 QString msg = tr(
"Audio device is invalid or not useable.");
981 return QObject::event(
event);
985 return GroupSetting::event(
event);
987 QString channel = cce->m_channel;
989 if (!cce->m_fulltest)
990 return GroupSetting::event(
event);
1001 if (channel ==
"frontleft")
1005 else if (channel ==
"frontright")
1009 else if (channel ==
"center")
1013 else if (channel ==
"lfe")
1017 else if (channel ==
"surroundleft")
1021 else if (channel ==
"surroundright")
1025 else if (channel ==
"rearleft")
1029 else if (channel ==
"rearright")
1049 return GroupSetting::event(
event);
1057 gc->setLabel(tr(
"Use internal volume controls"));
1061 gc->setHelpText(tr(
"If enabled, MythTV will control the PCM and "
1062 "master mixer volume. Disable this option if you "
1063 "prefer to control the volume externally (for "
1064 "example, using your amplifier) or if you use an "
1065 "external mixer program."));
1077 gc->setLabel(tr(
"Mixer device"));
1080 QDir dev(
"/dev",
"mixer*", QDir::Name, QDir::System);
1083 dev.setPath(
"/dev/sound");
1090 gc->addSelection(
"ALSA:default",
"ALSA:default");
1093 gc->addSelection(
"DirectX:",
"DirectX:");
1094 gc->addSelection(
"Windows:",
"Windows:");
1097 gc->addSelection(
"OpenSLES:",
"OpenSLES:");
1099 #if !defined(_WIN32)
1100 gc->addSelection(tr(
"software"),
"software");
1103 gc->setHelpText(tr(
"Setting the mixer device to \"%1\" lets MythTV control "
1104 "the volume of all audio at the expense of a slight "
1106 .arg(tr(
"software")));
1113 QT_TR_NOOP(
"Master")};
1119 gc->setLabel(tr(
"Mixer controls"));
1122 gc->addSelection(tr(control), control);
1124 gc->setHelpText(tr(
"Changing the volume adjusts the selected mixer."));
1133 gs->setLabel(tr(
"Master mixer volume"));
1137 gs->setHelpText(tr(
"Initial volume for the Master mixer. This affects "
1138 "all sound created by the audio device. Note: Do not "
1139 "set this too low."));
1147 gs->setLabel(tr(
"PCM mixer volume"));
1151 gs->setHelpText(tr(
"Initial volume for PCM output. Using the volume "
1152 "keys in MythTV will adjust this parameter."));
1160 gc->setLabel(tr(
"Stereo PCM Only"));
1162 gc->setValue(
false);
1164 gc->setHelpText(tr(
"Enable if your amplifier or sound decoder only "
1165 "supports 2 channel PCM (typically an old HDMI 1.0 "
1166 "device). Multichannel audio will be re-encoded to "
1167 "AC-3 when required"));
1175 gc->setLabel(tr(
"Override SRC quality"));
1177 gc->setValue(
false);
1179 gc->setHelpText(tr(
"Enable to override audio sample rate "
1180 "conversion quality."));
1188 gc->setLabel(tr(
"Sample rate conversion"));
1190 gc->addSelection(tr(
"Disabled",
"Sample rate conversion"),
"-1");
1191 gc->addSelection(tr(
"Fastest",
"Sample rate conversion"),
"0");
1192 gc->addSelection(tr(
"Good",
"Sample rate conversion"),
"1",
true);
1193 gc->addSelection(tr(
"Best",
"Sample rate conversion"),
"2");
1195 gc->setHelpText(tr(
"Set the quality of audio sample-rate "
1196 "conversion. \"%1\" (default) provides the best "
1197 "compromise between CPU usage and quality. \"%2\" "
1198 "lets the audio device handle sample-rate conversion.")
1199 .arg(tr(
"Good",
"Sample rate conversion"),
1200 tr(
"Disabled",
"Sample rate conversion")));
1209 gc->setLabel(tr(
"Force audio device output to 48kHz"));
1210 gc->setValue(
false);
1212 gc->setHelpText(tr(
"Force audio sample rate to 48kHz. Some audio devices "
1213 "will report various rates, but they ultimately "
1222 gc->setLabel(tr(
"Separate digital output device"));
1224 gc->setValue(
false);
1226 gc->setHelpText(tr(
"Use a distinct digital output device from default. "
1227 "(default is not checked)"));
1236 gc->setLabel(tr(
"Digital output device"));
1239 gc->addSelection(QCoreApplication::translate(
"(Common)",
"Default"),
1242 gc->addSelection(
"DirectX:Primary Sound Driver");
1244 gc->addSelection(
"ALSA:iec958:{ AES0 0x02 }",
1245 "ALSA:iec958:{ AES0 0x02 }");
1246 gc->addSelection(
"ALSA:hdmi",
"ALSA:hdmi");
1247 gc->addSelection(
"ALSA:plughw:0,3",
"ALSA:plughw:0,3");
1250 gc->setHelpText(tr(
"Audio output device to use for digital audio. This "
1251 "value is currently only used with ALSA and DirectX "
1260 gc->setLabel(tr(
"SPDIF 48kHz rate override"));
1262 gc->setValue(
false);
1264 gc->setHelpText(tr(
"ALSA only. By default, let ALSA determine the "
1265 "passthrough sampling rate. If checked set the sampling "
1266 "rate to 48kHz for passthrough. (default is not "
1275 gc->setLabel(tr(
"HBR passthrough support"));
1279 gc->setHelpText(tr(
"HBR support is required for TrueHD and DTS-HD "
1280 "passthrough. If unchecked, Myth will limit the "
1281 "passthrough bitrate to 6.144Mbit/s. This will "
1282 "disable True-HD passthrough, however will allow "
1283 "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="")