mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-04 05:13:11 +02:00
rm old AudioDevice interface
This commit is contained in:
parent
bf5c70501d
commit
9b131ee4af
2 changed files with 0 additions and 382 deletions
|
@ -1,273 +0,0 @@
|
|||
//
|
||||
// AudioDeviceScriptingInterface.cpp
|
||||
// interface/src/scripting
|
||||
//
|
||||
// Created by Brad Hefta-Gaub on 3/23/14.
|
||||
// Copyright 2014 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#include "AudioClient.h"
|
||||
/*
|
||||
#include "AudioDeviceScriptingInterface.h"
|
||||
#include "SettingsScriptingInterface.h"
|
||||
|
||||
AudioDeviceScriptingInterface* AudioDeviceScriptingInterface::getInstance() {
|
||||
static AudioDeviceScriptingInterface sharedInstance;
|
||||
return &sharedInstance;
|
||||
}
|
||||
|
||||
QStringList AudioDeviceScriptingInterface::inputAudioDevices() const {
|
||||
return _inputAudioDevices;
|
||||
}
|
||||
|
||||
QStringList AudioDeviceScriptingInterface::outputAudioDevices() const {
|
||||
return _outputAudioDevices;
|
||||
}
|
||||
|
||||
bool AudioDeviceScriptingInterface::muted()
|
||||
{
|
||||
return getMuted();
|
||||
}
|
||||
|
||||
AudioDeviceScriptingInterface::AudioDeviceScriptingInterface(): QAbstractListModel(nullptr) {
|
||||
connect(DependencyManager::get<AudioClient>().data(), &AudioClient::muteToggled,
|
||||
this, &AudioDeviceScriptingInterface::muteToggled);
|
||||
connect(DependencyManager::get<AudioClient>().data(), &AudioClient::deviceChanged,
|
||||
this, &AudioDeviceScriptingInterface::onDeviceChanged, Qt::QueuedConnection);
|
||||
connect(DependencyManager::get<AudioClient>().data(), &AudioClient::currentInputDeviceChanged,
|
||||
this, &AudioDeviceScriptingInterface::onCurrentInputDeviceChanged, Qt::QueuedConnection);
|
||||
connect(DependencyManager::get<AudioClient>().data(), &AudioClient::currentOutputDeviceChanged,
|
||||
this, &AudioDeviceScriptingInterface::onCurrentOutputDeviceChanged, Qt::QueuedConnection);
|
||||
//fill up model
|
||||
onDeviceChanged();
|
||||
//set up previously saved device
|
||||
SettingsScriptingInterface* settings = SettingsScriptingInterface::getInstance();
|
||||
const QString inDevice = settings->getValue("audio_input_device").toString();
|
||||
if (inDevice != _currentInputDevice) {
|
||||
setInputDeviceAsync(inDevice);
|
||||
}
|
||||
const QString outDevice = settings->getValue("audio_output_device").toString();
|
||||
if (outDevice != _currentOutputDevice) {
|
||||
setOutputDeviceAsync(outDevice);
|
||||
}
|
||||
}
|
||||
|
||||
bool AudioDeviceScriptingInterface::setInputDevice(const QString& deviceName) {
|
||||
bool result;
|
||||
QMetaObject::invokeMethod(DependencyManager::get<AudioClient>().data(), "switchInputToAudioDevice",
|
||||
Qt::BlockingQueuedConnection,
|
||||
Q_RETURN_ARG(bool, result),
|
||||
Q_ARG(const QString&, deviceName));
|
||||
return result;
|
||||
}
|
||||
|
||||
bool AudioDeviceScriptingInterface::setOutputDevice(const QString& deviceName) {
|
||||
bool result;
|
||||
QMetaObject::invokeMethod(DependencyManager::get<AudioClient>().data(), "switchOutputToAudioDevice",
|
||||
Qt::BlockingQueuedConnection,
|
||||
Q_RETURN_ARG(bool, result),
|
||||
Q_ARG(const QString&, deviceName));
|
||||
return result;
|
||||
}
|
||||
|
||||
bool AudioDeviceScriptingInterface::setDeviceFromMenu(const QString& deviceMenuName) {
|
||||
QAudio::Mode mode;
|
||||
|
||||
if (deviceMenuName.indexOf("for Output") != -1) {
|
||||
mode = QAudio::AudioOutput;
|
||||
} else if (deviceMenuName.indexOf("for Input") != -1) {
|
||||
mode = QAudio::AudioInput;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (ScriptingAudioDeviceInfo di: _devices) {
|
||||
if (mode == di.mode && deviceMenuName.contains(di.name)) {
|
||||
if (mode == QAudio::AudioOutput) {
|
||||
setOutputDeviceAsync(di.name);
|
||||
} else {
|
||||
setInputDeviceAsync(di.name);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void AudioDeviceScriptingInterface::setInputDeviceAsync(const QString& deviceName) {
|
||||
QMetaObject::invokeMethod(DependencyManager::get<AudioClient>().data(), "switchInputToAudioDevice",
|
||||
Qt::QueuedConnection,
|
||||
Q_ARG(const QString&, deviceName));
|
||||
}
|
||||
|
||||
void AudioDeviceScriptingInterface::setOutputDeviceAsync(const QString& deviceName) {
|
||||
QMetaObject::invokeMethod(DependencyManager::get<AudioClient>().data(), "switchOutputToAudioDevice",
|
||||
Qt::QueuedConnection,
|
||||
Q_ARG(const QString&, deviceName));
|
||||
}
|
||||
|
||||
QString AudioDeviceScriptingInterface::getInputDevice() {
|
||||
return DependencyManager::get<AudioClient>()->getDeviceName(QAudio::AudioInput);
|
||||
}
|
||||
|
||||
QString AudioDeviceScriptingInterface::getOutputDevice() {
|
||||
return DependencyManager::get<AudioClient>()->getDeviceName(QAudio::AudioOutput);
|
||||
}
|
||||
|
||||
QString AudioDeviceScriptingInterface::getDefaultInputDevice() {
|
||||
return DependencyManager::get<AudioClient>()->getDefaultDeviceName(QAudio::AudioInput);
|
||||
}
|
||||
|
||||
QString AudioDeviceScriptingInterface::getDefaultOutputDevice() {
|
||||
return DependencyManager::get<AudioClient>()->getDefaultDeviceName(QAudio::AudioOutput);
|
||||
}
|
||||
|
||||
QVector<QString> AudioDeviceScriptingInterface::getInputDevices() {
|
||||
return DependencyManager::get<AudioClient>()->getDeviceNames(QAudio::AudioInput);
|
||||
}
|
||||
|
||||
QVector<QString> AudioDeviceScriptingInterface::getOutputDevices() {
|
||||
return DependencyManager::get<AudioClient>()->getDeviceNames(QAudio::AudioOutput);
|
||||
}
|
||||
|
||||
float AudioDeviceScriptingInterface::getInputVolume() {
|
||||
return DependencyManager::get<AudioClient>()->getInputVolume();
|
||||
}
|
||||
|
||||
void AudioDeviceScriptingInterface::setInputVolume(float volume) {
|
||||
DependencyManager::get<AudioClient>()->setInputVolume(volume);
|
||||
}
|
||||
|
||||
void AudioDeviceScriptingInterface::setReverb(bool reverb) {
|
||||
DependencyManager::get<AudioClient>()->setReverb(reverb);
|
||||
}
|
||||
|
||||
void AudioDeviceScriptingInterface::setReverbOptions(const AudioEffectOptions* options) {
|
||||
DependencyManager::get<AudioClient>()->setReverbOptions(options);
|
||||
}
|
||||
|
||||
void AudioDeviceScriptingInterface::toggleMute() {
|
||||
DependencyManager::get<AudioClient>()->toggleMute();
|
||||
}
|
||||
|
||||
void AudioDeviceScriptingInterface::setMuted(bool muted)
|
||||
{
|
||||
bool lMuted = getMuted();
|
||||
if (lMuted == muted)
|
||||
return;
|
||||
|
||||
toggleMute();
|
||||
lMuted = getMuted();
|
||||
emit mutedChanged(lMuted);
|
||||
}
|
||||
|
||||
bool AudioDeviceScriptingInterface::getMuted() {
|
||||
return DependencyManager::get<AudioClient>()->isMuted();
|
||||
}
|
||||
|
||||
QVariant AudioDeviceScriptingInterface::data(const QModelIndex& index, int role) const {
|
||||
//sanity
|
||||
if (!index.isValid() || index.row() >= _devices.size())
|
||||
return QVariant();
|
||||
|
||||
|
||||
if (role == Qt::DisplayRole || role == DisplayNameRole) {
|
||||
return _devices.at(index.row()).name;
|
||||
} else if (role == SelectedRole) {
|
||||
return _devices.at(index.row()).selected;
|
||||
} else if (role == AudioModeRole) {
|
||||
return (int)_devices.at(index.row()).mode;
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
int AudioDeviceScriptingInterface::rowCount(const QModelIndex& parent) const {
|
||||
Q_UNUSED(parent)
|
||||
return _devices.size();
|
||||
}
|
||||
|
||||
QHash<int, QByteArray> AudioDeviceScriptingInterface::roleNames() const {
|
||||
QHash<int, QByteArray> roles;
|
||||
roles.insert(DisplayNameRole, "devicename");
|
||||
roles.insert(SelectedRole, "devicechecked");
|
||||
roles.insert(AudioModeRole, "devicemode");
|
||||
return roles;
|
||||
}
|
||||
|
||||
void AudioDeviceScriptingInterface::onDeviceChanged()
|
||||
{
|
||||
beginResetModel();
|
||||
_outputAudioDevices.clear();
|
||||
_devices.clear();
|
||||
_currentOutputDevice = getOutputDevice();
|
||||
for (QString name: getOutputDevices()) {
|
||||
ScriptingAudioDeviceInfo di;
|
||||
di.name = name;
|
||||
di.selected = (name == _currentOutputDevice);
|
||||
di.mode = QAudio::AudioOutput;
|
||||
_devices.append(di);
|
||||
_outputAudioDevices.append(name);
|
||||
}
|
||||
emit outputAudioDevicesChanged(_outputAudioDevices);
|
||||
|
||||
_inputAudioDevices.clear();
|
||||
_currentInputDevice = getInputDevice();
|
||||
for (QString name: getInputDevices()) {
|
||||
ScriptingAudioDeviceInfo di;
|
||||
di.name = name;
|
||||
di.selected = (name == _currentInputDevice);
|
||||
di.mode = QAudio::AudioInput;
|
||||
_devices.append(di);
|
||||
_inputAudioDevices.append(name);
|
||||
}
|
||||
emit inputAudioDevicesChanged(_inputAudioDevices);
|
||||
|
||||
endResetModel();
|
||||
emit deviceChanged();
|
||||
}
|
||||
|
||||
void AudioDeviceScriptingInterface::onCurrentInputDeviceChanged(const QString& name)
|
||||
{
|
||||
currentDeviceUpdate(name, QAudio::AudioInput);
|
||||
//we got a signal that device changed. Save it now
|
||||
SettingsScriptingInterface* settings = SettingsScriptingInterface::getInstance();
|
||||
settings->setValue("audio_input_device", name);
|
||||
emit currentInputDeviceChanged(name);
|
||||
}
|
||||
|
||||
void AudioDeviceScriptingInterface::onCurrentOutputDeviceChanged(const QString& name)
|
||||
{
|
||||
currentDeviceUpdate(name, QAudio::AudioOutput);
|
||||
//we got a signal that device changed. Save it now
|
||||
SettingsScriptingInterface* settings = SettingsScriptingInterface::getInstance();
|
||||
settings->setValue("audio_output_device", name);
|
||||
emit currentOutputDeviceChanged(name);
|
||||
}
|
||||
|
||||
void AudioDeviceScriptingInterface::currentDeviceUpdate(const QString& name, QAudio::Mode mode)
|
||||
{
|
||||
QVector<int> role;
|
||||
role.append(SelectedRole);
|
||||
|
||||
for (int i = 0; i < _devices.size(); i++) {
|
||||
ScriptingAudioDeviceInfo di = _devices.at(i);
|
||||
if (di.mode != mode) {
|
||||
continue;
|
||||
}
|
||||
if (di.selected && di.name != name ) {
|
||||
di.selected = false;
|
||||
_devices[i] = di;
|
||||
emit dataChanged(index(i, 0), index(i, 0), role);
|
||||
}
|
||||
if (di.name == name) {
|
||||
di.selected = true;
|
||||
_devices[i] = di;
|
||||
emit dataChanged(index(i, 0), index(i, 0), role);
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
|
@ -1,109 +0,0 @@
|
|||
//
|
||||
// AudioDeviceScriptingInterface.h
|
||||
// interface/src/scripting
|
||||
//
|
||||
// Created by Brad Hefta-Gaub on 3/22/14.
|
||||
// Copyright 2014 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#ifndef hifi_AudioDeviceScriptingInterface_h
|
||||
#define hifi_AudioDeviceScriptingInterface_h
|
||||
|
||||
/*
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QVector>
|
||||
#include <QAbstractListModel>
|
||||
#include <QAudio>
|
||||
|
||||
class AudioEffectOptions;
|
||||
|
||||
struct ScriptingAudioDeviceInfo {
|
||||
QString name;
|
||||
bool selected;
|
||||
QAudio::Mode mode;
|
||||
};
|
||||
|
||||
class AudioDeviceScriptingInterface : public QAbstractListModel {
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(QStringList inputAudioDevices READ inputAudioDevices NOTIFY inputAudioDevicesChanged)
|
||||
Q_PROPERTY(QStringList outputAudioDevices READ outputAudioDevices NOTIFY outputAudioDevicesChanged)
|
||||
Q_PROPERTY(bool muted READ muted WRITE setMuted NOTIFY mutedChanged)
|
||||
|
||||
public:
|
||||
static AudioDeviceScriptingInterface* getInstance();
|
||||
|
||||
QStringList inputAudioDevices() const;
|
||||
QStringList outputAudioDevices() const;
|
||||
bool muted();
|
||||
|
||||
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override;
|
||||
int rowCount(const QModelIndex& parent = QModelIndex()) const override;
|
||||
QHash<int, QByteArray> roleNames() const override;
|
||||
|
||||
enum Roles {
|
||||
DisplayNameRole = Qt::UserRole,
|
||||
SelectedRole,
|
||||
AudioModeRole
|
||||
};
|
||||
|
||||
private slots:
|
||||
void onDeviceChanged();
|
||||
void onCurrentInputDeviceChanged(const QString& name);
|
||||
void onCurrentOutputDeviceChanged(const QString& name);
|
||||
void currentDeviceUpdate(const QString& name, QAudio::Mode mode);
|
||||
|
||||
public slots:
|
||||
bool setInputDevice(const QString& deviceName);
|
||||
bool setOutputDevice(const QString& deviceName);
|
||||
bool setDeviceFromMenu(const QString& deviceMenuName);
|
||||
|
||||
QString getInputDevice();
|
||||
QString getOutputDevice();
|
||||
|
||||
QString getDefaultInputDevice();
|
||||
QString getDefaultOutputDevice();
|
||||
|
||||
QVector<QString> getInputDevices();
|
||||
QVector<QString> getOutputDevices();
|
||||
|
||||
float getInputVolume();
|
||||
void setInputVolume(float volume);
|
||||
void setReverb(bool reverb);
|
||||
void setReverbOptions(const AudioEffectOptions* options);
|
||||
|
||||
bool getMuted();
|
||||
void toggleMute();
|
||||
|
||||
void setMuted(bool muted);
|
||||
|
||||
void setInputDeviceAsync(const QString& deviceName);
|
||||
void setOutputDeviceAsync(const QString& deviceName);
|
||||
private:
|
||||
AudioDeviceScriptingInterface();
|
||||
|
||||
signals:
|
||||
void muteToggled();
|
||||
void deviceChanged();
|
||||
void currentInputDeviceChanged(const QString& name);
|
||||
void currentOutputDeviceChanged(const QString& name);
|
||||
void mutedChanged(bool muted);
|
||||
void inputAudioDevicesChanged(QStringList inputAudioDevices);
|
||||
void outputAudioDevicesChanged(QStringList outputAudioDevices);
|
||||
|
||||
private:
|
||||
QVector<ScriptingAudioDeviceInfo> _devices;
|
||||
|
||||
QStringList _inputAudioDevices;
|
||||
QStringList _outputAudioDevices;
|
||||
|
||||
QString _currentInputDevice;
|
||||
QString _currentOutputDevice;
|
||||
};
|
||||
*/
|
||||
|
||||
#endif // hifi_AudioDeviceScriptingInterface_h
|
Loading…
Reference in a new issue