Commit ce653e2d authored by Andreas Cord-Landwehr's avatar Andreas Cord-Landwehr
Browse files

Fix sound volume settings.

parent 13e5adcf
......@@ -38,12 +38,8 @@ public:
OutputDeviceControllerPrivate(OutputDeviceController *parent)
: m_parent(parent)
, m_backend(0)
, m_volume(0)
, m_initialized(false)
{
// use this value only for initialization, will be modified in another thread / another
// static Settings object
//m_volume = Settings::audioOutputVolume(); //TODO currently not use anywhere
m_backend = new QtGStreamerOutputBackend();
}
......@@ -59,6 +55,7 @@ public:
}
m_backend = new QtGStreamerOutputBackend();
m_parent->connect(m_backend, SIGNAL(stateChanged()), m_parent, SLOT(emitChangedState()));
m_volume = m_backend->volume();
m_initialized = true;
}
......@@ -70,7 +67,7 @@ public:
OutputDeviceController *m_parent;
QtGStreamerOutputBackend *m_backend;
int m_volume; // output volume in Db
int m_volume; // volume as cubic value
bool m_initialized;
};
......@@ -94,7 +91,7 @@ OutputDeviceController & OutputDeviceController::self()
void OutputDeviceController::play(const QString& filePath)
{
d->backend()->setUri(filePath);
// d->m_audioOutput->setVolumeDecibel(d->m_volume); //TODO
d->backend()->setVolume(d->m_volume);
d->backend()->play();
emit started();
}
......@@ -127,9 +124,16 @@ OutputDeviceController::State OutputDeviceController::state() const
}
}
void OutputDeviceController::setVolume(int volumenDb)
void OutputDeviceController::setVolume(int volume)
{
d->m_volume = volumenDb;
// backend only accepts volume, when there is a pipeline
// store value here and set it when playing
d->m_volume = volume;
}
int OutputDeviceController::volume() const
{
return d->backend()->volume();
}
void OutputDeviceController::emitChangedState()
......
......@@ -57,10 +57,8 @@ public:
OutputDeviceController::State state() const;
void stop();
QString currentSource() const;
/**
* Set playback volume in decibels.
*/
void setVolume(int volumenDb);
void setVolume(int volume);
int volume() const;
public Q_SLOTS:
void emitChangedState();
......
......@@ -39,6 +39,9 @@ public:
QTime position() const;
void setPosition(const QTime & pos);
/**
* volume as cubic value
*/
int volume() const;
QTime length() const;
......
......@@ -18,11 +18,11 @@
</entry>
<entry name="AudioInputVolume" type="Int">
<label>Audio input volume</label>
<default>90</default>
<default>10</default>
</entry>
<entry name="AudioOutputVolume" type="Int">
<label>Audio output volume</label>
<default>90</default>
<default>10</default>
</entry>
<entry name="TrainingPhraseFont" type="Font">
<label>Font</label>
......
......@@ -28,7 +28,8 @@
#include "models/languagemodel.h"
#include "settings.h"
#include "liblearnerprofile/src/profilemanager.h"
#include <liblearnerprofile/src/learner.h>
#include "liblearnerprofile/src/learner.h"
#include "libsound/src/outputdevicecontroller.h"
#include <KMainWindow>
#include <KAction>
......@@ -73,6 +74,9 @@ MainWindow::MainWindow()
setAutoSaveSettings();
// load saved sound settings
OutputDeviceController::self().setVolume(Settings::audioOutputVolume());
// load resources
m_resourceManager->loadLanguageResources();
m_resourceManager->loadCourseResources();
......
......@@ -46,8 +46,8 @@ SoundDeviceDialogPage::SoundDeviceDialogPage()
// set output volume slider
ui->kcfg_AudioOutputVolume->setTickInterval(0);
ui->kcfg_AudioOutputVolume->setMinimum(-100);
ui->kcfg_AudioOutputVolume->setMaximum(11);
ui->kcfg_AudioOutputVolume->setMinimum(0);
ui->kcfg_AudioOutputVolume->setMaximum(20);
// devices
QStringList devices = CaptureDeviceController::self().devices();
......@@ -87,7 +87,7 @@ void SoundDeviceDialogPage::saveSettings()
{
Settings::setAudioInputDevice(ui->kcfg_AudioInputDevice->itemText(ui->kcfg_AudioInputDevice->currentIndex()));
// Settings::setAudioInputVolume(ui->kcfg_AudioInputVolume->value());
Settings::setAudioOutputVolume(ui->kcfg_AudioOutputVolume->value());
Settings::setAudioOutputVolume((int) ui->kcfg_AudioOutputVolume->value());
OutputDeviceController::self().setVolume(ui->kcfg_AudioOutputVolume->value());
Settings::self()->writeConfig();
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment