From 0d55d4504e5aedbcde0386d4f18864c1eed9b25d Mon Sep 17 00:00:00 2001 From: trialuser02 Date: Sun, 7 Nov 2010 16:12:23 +0000 Subject: moved oss4 support to separate plugin, fixed some bugs, updated documentation git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@1983 90c681e8-e032-0410-971d-27865f9a5e38 --- src/plugins/Output/oss4/settingsdialog.cpp | 110 +++++++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 src/plugins/Output/oss4/settingsdialog.cpp (limited to 'src/plugins/Output/oss4/settingsdialog.cpp') diff --git a/src/plugins/Output/oss4/settingsdialog.cpp b/src/plugins/Output/oss4/settingsdialog.cpp new file mode 100644 index 000000000..ea4401ae2 --- /dev/null +++ b/src/plugins/Output/oss4/settingsdialog.cpp @@ -0,0 +1,110 @@ +/*************************************************************************** + * Copyright (C) 2010 by Ilya Kotov * + * forkotov02@hotmail.ru * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ +#include +#include +#include + +extern "C" +{ +#ifdef HAVE_SYS_SOUNDCARD_H +#include +#else +#include +#endif +//#include +} +#include +#include +#include +#include +#include +#include +#include +#include +#include "outputoss4.h" +#include "settingsdialog.h" + +SettingsDialog::SettingsDialog (QWidget *parent) : QDialog (parent) +{ + ui.setupUi (this); + setAttribute (Qt::WA_DeleteOnClose); + + + + int mixer_fd = -1; + oss_sysinfo info; + if ((mixer_fd = ::open(DEFAULT_MIXER, O_RDWR)) < 0) + { + qWarning("SettingsDialog: %s", strerror(errno)); + return; + } + if (ioctl(mixer_fd, SNDCTL_SYSINFO, &info) < 0) + { + qWarning("SettingsDialog: ioctl SNDCTL_SYSINFO failed: %s", strerror(errno)); + return; + } + + if (info.numaudios < 1) + { + qWarning("SettingsDialog: no device found"); + return; + } + + m_devices << DEFAULT_DEV; + ui.deviceComboBox->addItem(tr("Default") + " (" + DEFAULT_DEV + ")"); + + for (int i = 0; i < info.numaudios; ++i) + { + oss_audioinfo audio_info; + audio_info.dev = i; + + if (ioctl(mixer_fd, SNDCTL_AUDIOINFO, &audio_info) < 0) + { + qWarning("SettingsDialog: ioctl SNDCTL_AUDIOINFO failed: %s", strerror(errno)); + return; + } + + if (audio_info.caps & PCM_CAP_OUTPUT) + { + m_devices << audio_info.devnode; + ui.deviceComboBox->addItem(QString("%1 (%2)").arg(audio_info.name).arg(audio_info.devnode)); + } + } + QSettings settings(Qmmp::configFile(), QSettings::IniFormat); + ui.deviceComboBox->setEditText(settings.value("OSS4/device", DEFAULT_DEV).toString()); + connect (ui.deviceComboBox, SIGNAL(activated(int)),SLOT(setText(int))); +} + +SettingsDialog::~SettingsDialog() +{} + +void SettingsDialog::setText(int n) +{ + ui.deviceComboBox->setEditText(m_devices.at(n)); +} + +void SettingsDialog::accept() +{ + qDebug("%s", Q_FUNC_INFO); + QSettings settings(Qmmp::configFile(), QSettings::IniFormat); + settings.setValue("OSS4/device", ui.deviceComboBox->currentText ()); + QDialog::accept(); +} + -- cgit v1.2.3-13-gbd6f