Skip to content

Commit

Permalink
Audio channel test. Made a QWidget version rather than MythUI for the…
Browse files Browse the repository at this point in the history
… time being as otherwise the audio test can't be started from the QWidget settings. The new test plays sound for 3s on each speaker. An individual speaker can be selected. The test now goes in a clockwise fashion on all speakers.

Amended AudioOutput class so it can go without having to read the user settings, which during the audiotest haven't been saved yet
  • Loading branch information
jyavenard committed Dec 8, 2010
1 parent 00cd344 commit 21cfaf6
Show file tree
Hide file tree
Showing 20 changed files with 233 additions and 1,320 deletions.
4 changes: 2 additions & 2 deletions mythtv/libs/libmyth/audio/audiooutput.cpp
Expand Up @@ -48,11 +48,11 @@ AudioOutput *AudioOutput::OpenAudio(
const QString &main_device, const QString &passthru_device,
AudioFormat format, int channels, int codec, int samplerate,
AudioOutputSource source, bool set_initial_vol, bool passthru,
int upmixer_startup)
int upmixer_startup, AudioOutputSettings *custom)
{
AudioSettings settings(
main_device, passthru_device, format, channels, codec, samplerate,
source, set_initial_vol, passthru, upmixer_startup);
source, set_initial_vol, passthru, upmixer_startup, custom);

return OpenAudio(settings);
}
Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmyth/audio/audiooutput.h
Expand Up @@ -41,7 +41,7 @@ class MPUBLIC AudioOutput : public VolumeBase, public OutputListeners
const QString &audiodevice, const QString &passthrudevice,
AudioFormat format, int channels, int codec, int samplerate,
AudioOutputSource source, bool set_initial_vol, bool passthru,
int upmixer_startup = 0);
int upmixer_startup = 0, AudioOutputSettings *custom = NULL);
static AudioOutput *OpenAudio(AudioSettings &settings,
bool willsuspendpa = true);
static AudioOutput *OpenAudio(
Expand Down
13 changes: 12 additions & 1 deletion mythtv/libs/libmyth/audio/audiooutputbase.cpp
Expand Up @@ -73,7 +73,7 @@ AudioOutputBase::AudioOutputBase(const AudioSettings &settings) :
pSoundStretch(NULL),
encoder(NULL), upmixer(NULL),
source_channels(-1), source_samplerate(0),
source_bytes_per_frame(0),
source_bytes_per_frame(0), upmix_default(false),
needs_upmix(false), needs_downmix(false),
surround_mode(QUALITY_LOW), old_stretchfactor(1.0f),
volume(80), volumeControl(QString()),
Expand Down Expand Up @@ -144,6 +144,17 @@ AudioOutputBase::~AudioOutputBase()

void AudioOutputBase::InitSettings(const AudioSettings &settings)
{
if (settings.custom)
{
// got a custom audio report already, use it
// this was likely provided by the AudioTest utility
output_settings = new AudioOutputSettings;
*output_settings = *settings.custom;
max_channels = output_settings->BestSupportedChannels();
configured_channels = max_channels;
return;
}

// Ask the subclass what we can send to the device
output_settings = GetOutputSettingsUsers();

Expand Down
2 changes: 1 addition & 1 deletion mythtv/libs/libmyth/audio/audiooutputbase.h
Expand Up @@ -181,8 +181,8 @@ class AudioOutputBase : public AudioOutput, public QThread
int source_channels;
int source_samplerate;
int source_bytes_per_frame;
bool needs_upmix;
bool upmix_default;
bool needs_upmix;
bool needs_downmix;
int surround_mode;
float old_stretchfactor;
Expand Down
4 changes: 2 additions & 2 deletions mythtv/libs/libmyth/audio/audiooutputsettings.cpp
Expand Up @@ -271,7 +271,7 @@ AudioOutputSettings* AudioOutputSettings::GetCleaned(bool newcopy)
aosettings->m_LPCM = (mchannels > 2);
if (mchannels == 2 && m_passthrough >= 0)
{
VERBOSE(VB_AUDIO, LOC + QString("AC3 or DTS capable"));
VERBOSE(VB_AUDIO, LOC + QString("may be AC3 or DTS capable"));
aosettings->AddSupportedChannels(6);
}
aosettings->m_DTS = aosettings->m_AC3 = (m_passthrough >= 0);
Expand Down Expand Up @@ -307,7 +307,7 @@ AudioOutputSettings* AudioOutputSettings::GetUsers(bool newcopy)
gCoreContext->GetNumSetting("DTSPassThru", false);
bool bLPCM = aosettings->m_LPCM &&
(aosettings->m_passthrough == -1 ||
!(bAdv && gCoreContext->GetNumSetting("StereoPCM", false)));
!gCoreContext->GetNumSetting("StereoPCM", false));

if (max_channels > 2 && !bLPCM)
max_channels = 2;
Expand Down
5 changes: 4 additions & 1 deletion mythtv/libs/libmyth/audio/audiooutputsettings.h
Expand Up @@ -61,10 +61,13 @@ class MPUBLIC AudioOutputSettings
bool canDTS() { return m_DTS; };
bool canLPCM() { return m_LPCM; };
bool IsInvalid() { return m_invalid; };
void setAC3(bool b) { m_AC3 = b; };
void setDTS(bool b) { m_DTS = b; };
void setLPCM(bool b) { m_LPCM = b; };
void SetBestSupportedChannels(int channels);

private:
void SortSupportedChannels();
void SetBestSupportedChannels(int channels);

/* passthrough status
* -1 : no
Expand Down
52 changes: 39 additions & 13 deletions mythtv/libs/libmyth/audio/audiosettings.cpp
Expand Up @@ -19,7 +19,8 @@ AudioSettings::AudioSettings() :
use_passthru(false),
source(AUDIOOUTPUT_UNKNOWN),
upmixer(0),
init(false)
init(false),
custom(NULL)
{
}

Expand All @@ -36,19 +37,28 @@ AudioSettings::AudioSettings(const AudioSettings &other) :
upmixer(other.upmixer),
init(true)
{
if (other.custom)
{
// make a copy of it
custom = new AudioOutputSettings;
*custom = *other.custom;
}
else
custom = NULL;
}

AudioSettings::AudioSettings(
const QString &main_device,
const QString &passthru_device,
AudioFormat format,
int channels,
int codec,
int samplerate,
AudioOutputSource source,
bool set_initial_vol,
bool use_passthru,
int upmixer_startup) :
const QString &main_device,
const QString &passthru_device,
AudioFormat format,
int channels,
int codec,
int samplerate,
AudioOutputSource source,
bool set_initial_vol,
bool use_passthru,
int upmixer_startup,
AudioOutputSettings *custom) :
main_device(main_device),
passthru_device(passthru_device),
format(format),
Expand All @@ -61,6 +71,14 @@ AudioSettings::AudioSettings(
upmixer(upmixer_startup),
init(true)
{
if (custom)
{
// make a copy of it
this->custom = new AudioOutputSettings;
*this->custom = *custom;
}
else
this->custom = NULL;
}

AudioSettings::AudioSettings(
Expand All @@ -80,7 +98,8 @@ AudioSettings::AudioSettings(
use_passthru(use_passthru),
source(AUDIOOUTPUT_UNKNOWN),
upmixer(upmixer_startup),
init(true)
init(true),
custom(NULL)
{
}

Expand All @@ -97,8 +116,15 @@ AudioSettings::AudioSettings(
use_passthru(false),
source(AUDIOOUTPUT_UNKNOWN),
upmixer(0),
init(false)
init(false),
custom(NULL)
{
}

AudioSettings::~AudioSettings()
{
if (custom)
delete custom;
}

void AudioSettings::FixPassThrough(void)
Expand Down
57 changes: 30 additions & 27 deletions mythtv/libs/libmyth/audio/audiosettings.h
Expand Up @@ -26,45 +26,48 @@ class MPUBLIC AudioSettings
AudioSettings();
AudioSettings(const AudioSettings &other);
AudioSettings(
const QString &main_device,
const QString &passthru_device,
AudioFormat format,
int channels,
int codec,
int samplerate,
AudioOutputSource source,
bool set_initial_vol,
bool use_passthru,
int upmixer_startup = 0);
const QString &main_device,
const QString &passthru_device,
AudioFormat format,
int channels,
int codec,
int samplerate,
AudioOutputSource source,
bool set_initial_vol,
bool use_passthru,
int upmixer_startup = 0,
AudioOutputSettings *custom = NULL);

AudioSettings(AudioFormat format,
int channels,
int codec,
int samplerate,
bool use_passthru,
int upmixer_startup = 0);
AudioSettings(AudioFormat format,
int channels,
int codec,
int samplerate,
bool use_passthru,
int upmixer_startup = 0);

AudioSettings(const QString &main_device,
const QString &passthru_device = QString::null);

~AudioSettings();
void FixPassThrough(void);
void TrimDeviceType(void);

QString GetMainDevice(void) const;
QString GetPassthruDevice(void) const;

public:
QString main_device;
QString passthru_device;
AudioFormat format;
int channels;
int codec;
int samplerate;
bool set_initial_vol;
bool use_passthru;
AudioOutputSource source;
int upmixer;
bool init;
QString main_device;
QString passthru_device;
AudioFormat format;
int channels;
int codec;
int samplerate;
bool set_initial_vol;
bool use_passthru;
AudioOutputSource source;
int upmixer;
bool init;
AudioOutputSettings *custom;
};

#endif // _AUDIO_SETTINGS_H_
7 changes: 7 additions & 0 deletions mythtv/libs/libmyth/settings.cpp
Expand Up @@ -1346,6 +1346,13 @@ void ButtonSetting::setEnabled(bool fEnabled)
button->setEnabled(fEnabled);
}

void ButtonSetting::setLabel(QString str)
{
if (button)
button->setText(str);
Setting::setLabel(str);
}

void ButtonSetting::setHelpText(const QString &str)
{
if (button)
Expand Down
4 changes: 3 additions & 1 deletion mythtv/libs/libmyth/settings.h
Expand Up @@ -54,7 +54,7 @@ class MPUBLIC Configurable : public QObject
virtual Setting* byName(const QString &name) = 0;

// A label displayed to the user
void setLabel(QString str) { label = str; }
virtual void setLabel(QString str) { label = str; }
QString getLabel(void) const { return label; }
void setLabelAboveWidget(bool l = true) { labelAboveWidget = l; }

Expand Down Expand Up @@ -580,6 +580,8 @@ class MPUBLIC ButtonSetting: public Setting

virtual void setEnabled(bool b);

virtual void setLabel(QString);

virtual void setHelpText(const QString &);

signals:
Expand Down

0 comments on commit 21cfaf6

Please sign in to comment.