Commit bb878c92 authored by yanmorin's avatar yanmorin
Browse files

Debugging and adding new VARIANT/8000 variable with default tone in list audiodevice

parent 00909b05
......@@ -26,7 +26,7 @@
#include "Request.hpp" // don't know if it's a good idea for this class to know request...
ConfigurationManagerImpl::ConfigurationManagerImpl()
: mSession(0)
: mSession(0), mRateMode("8000")
{}
ConfigurationManagerImpl::~ConfigurationManagerImpl()
......@@ -88,12 +88,14 @@ ConfigurationManagerImpl::add(const ConfigEntry &entry)
void
ConfigurationManagerImpl::addAudioDevice(QString index,
QString hostApiName,
QString deviceName)
QString deviceName,
QString defaultRate)
{
AudioDevice device;
device.index = index;
device.hostApiName = hostApiName;
device.deviceName = deviceName;
device.defaultRate = defaultRate;
add(device);
}
......@@ -107,12 +109,14 @@ ConfigurationManagerImpl::add(const AudioDevice &entry)
void
ConfigurationManagerImpl::addAudioDeviceIn(QString index,
QString hostApiName,
QString deviceName)
QString deviceName,
QString defaultRate)
{
AudioDevice device;
device.index = index;
device.hostApiName = hostApiName;
device.deviceName = deviceName;
device.defaultRate = defaultRate;
addIn(device);
}
......@@ -126,12 +130,14 @@ ConfigurationManagerImpl::addIn(const AudioDevice &entry)
void
ConfigurationManagerImpl::addAudioDeviceOut(QString index,
QString hostApiName,
QString deviceName)
QString deviceName,
QString defaultRate)
{
AudioDevice device;
device.index = index;
device.hostApiName = hostApiName;
device.deviceName = deviceName;
device.defaultRate = defaultRate;
addOut(device);
}
......@@ -222,13 +228,15 @@ ConfigurationManagerImpl::reloadSoundDriver() {
Request *r;
r = mSession->list("audiodevicein");
QObject::connect(r, SIGNAL(parsedEntry(QString, QString, QString, QString, QString)),
this, SLOT(addAudioDeviceIn(QString, QString, QString)));
this, SLOT(addAudioDeviceIn(QString, QString, QString, QString)));
QObject::connect(r, SIGNAL(parsedEntry(const QString& )),
this, SLOT(setRateMode(const QString& )));
QObject::connect(r, SIGNAL(success(QString, QString)),
this, SIGNAL(audioDevicesInUpdated()));
r = mSession->list("audiodeviceout");
QObject::connect(r, SIGNAL(parsedEntry(QString, QString, QString, QString, QString)),
this, SLOT(addAudioDeviceOut(QString, QString, QString)));
this, SLOT(addAudioDeviceOut(QString, QString, QString, QString)));
QObject::connect(r, SIGNAL(success(QString, QString)),
this, SIGNAL(audioDevicesOutUpdated()));
......
......@@ -35,6 +35,7 @@ public:
QString index;
QString hostApiName;
QString deviceName;
QString defaultRate;
};
struct Ringtone
......@@ -166,13 +167,16 @@ public:
public slots:
void add(const ConfigEntry &entry);
void addAudioDevice(QString index, QString hostApiName, QString deviceName);
void addAudioDevice(QString index, QString hostApiName, QString deviceName, QString defaultRate);
void add(const AudioDevice &entry);
void addAudioDeviceIn(QString index, QString hostApiName, QString deviceName);
void addAudioDeviceIn(QString index, QString hostApiName, QString deviceName, QString defaultRate);
void setRateMode(const QString& rateMode) { mRateMode = rateMode; }
const QString& getRateMode() { return mRateMode; }
void addIn(const AudioDevice &entry);
void addAudioDeviceOut(QString index, QString hostApiName, QString deviceName);
void addAudioDeviceOut(QString index, QString hostApiName, QString deviceName, QString defaultRate);
void addOut(const AudioDevice &entry);
void addRingtone(QString index, QString filename);
......@@ -194,6 +198,7 @@ private:
std::list< Codec > mCodecs;
Session *mSession;
QString mRateMode; // VARIANT or number
};
#endif
......@@ -163,6 +163,7 @@ ConfigurationPanel::generate()
cboDriverChoiceOut->setCurrentItem(ConfigurationManager::instance().get(AUDIO_SECTION, AUDIO_DEFAULT_DEVICEOUT).toUInt());
cboDriverChoiceIn->setCurrentItem(ConfigurationManager::instance().get(AUDIO_SECTION, AUDIO_DEFAULT_DEVICEIN).toUInt());
//preference tab
updateSkins();
}
......
......@@ -242,7 +242,7 @@ PhoneLineManagerImpl::handleEvents()
QObject::connect(r, SIGNAL(parsedEntry(QString, QString, QString, QString, QString)),
&ConfigurationManager::instance(), SLOT(addAudioDevice(QString,
QString,
QString)));
QString, QString)));
QObject::connect(r, SIGNAL(success(QString, QString)),
&ConfigurationManager::instance(), SIGNAL(audioDevicesUpdated()));
*/
......@@ -250,7 +250,10 @@ PhoneLineManagerImpl::handleEvents()
QObject::connect(r, SIGNAL(parsedEntry(QString, QString, QString, QString, QString)),
&ConfigurationManager::instance(), SLOT(addAudioDeviceIn(QString,
QString,
QString)));
QString, QString)));
QObject::connect(r, SIGNAL(parsedEntry(const QString& )),
&ConfigurationManager::instance(), SLOT(setRateMode(const QString& )));
QObject::connect(r, SIGNAL(success(QString, QString)),
&ConfigurationManager::instance(), SIGNAL(audioDevicesInUpdated()));
......@@ -258,7 +261,7 @@ PhoneLineManagerImpl::handleEvents()
QObject::connect(r, SIGNAL(parsedEntry(QString, QString, QString, QString, QString)),
&ConfigurationManager::instance(), SLOT(addAudioDeviceOut(QString,
QString,
QString)));
QString, QString)));
QObject::connect(r, SIGNAL(success(QString, QString)),
&ConfigurationManager::instance(), SIGNAL(audioDevicesOutUpdated()));
......
......@@ -84,10 +84,13 @@ Request::onEntry(const QString &code, const QString &message)
if(args.size() >= 1) {
arg1 = *args.begin();
args.pop_front();
}
}
if(args.size() >= 1) {
arg2 = *args.begin();
args.pop_front();
} else { // if we have only one argument, we send a signal with one parameter
emit parsedEntry(arg1);
return;
}
if(args.size() >= 1) {
arg3 = *args.begin();
......
......@@ -43,6 +43,7 @@ signals:
void error(QString, QString);
void success(QString, QString);
void entry(QString, QString);
void parsedEntry(const QString& );
void parsedEntry(QString, QString, QString, QString, QString);
public:
......
......@@ -315,4 +315,6 @@ SFLLcd::mousePressEvent( QMouseEvent *e)
if (e && e->button() == Qt::MidButton) {
emit midClicked();
}
// pass the event to the widget
QWidget::mousePressEvent( e );
}
......@@ -233,7 +233,7 @@ SFLPhoneWindow::askResendStatus(QString message)
void
SFLPhoneWindow::mousePressEvent(QMouseEvent *e)
{
mLastPos = e->pos();
mLastPos = e->pos(); // this is relative to the widget
}
void
......
......@@ -515,16 +515,21 @@ ManagerImpl::playDtmf(char code)
// fast return, no sound, so no dtmf
if (audiolayer==0 || _dtmfKey == 0) { return false; }
int outChannel = audiolayer->getOutChannel();
int size = pulselen * (audiolayer->getSampleRate()/1000);
// this buffer is for mono
int16* _buf = new int16[size];
// number of int16 sampling in one pulselen depends on samplerate
/** size (n sampling) = time_ms * sampling/s
---------------------
ms/s
*/
int size = (int)(pulselen * ((float)audiolayer->getSampleRate()/1000));
// this buffer is for mono or stereo
int16* _buf = new int16[size*outChannel];
bool returnValue = false;
// Handle dtmf
_dtmfKey->startTone(code);
// copy the sound...
// copy the sound
if ( _dtmfKey->generateDTMF(_buf, size * outChannel) ) {
// Put buffer to urgentRingBuffer
......@@ -1039,7 +1044,7 @@ ManagerImpl::initConfigFile (void)
fill_config_int(CONFIG_ZEROCONF, CONFIG_ZEROCONF_DEFAULT_STR);
initConfigAccount();
_exist = createSettingsPath();
_setupLoaded = (_exist == 2 ) ? false : true;
}
......@@ -1083,7 +1088,7 @@ ManagerImpl::selectAudioDriver (void)
int noDeviceIn = getConfigInt(AUDIO, DRIVER_NAME_IN);
int noDeviceOut = getConfigInt(AUDIO, DRIVER_NAME_OUT);
int sampleRate = getConfigInt(AUDIO, DRIVER_SAMPLE_RATE);
#ifdef USE_SAMPLERATE
#ifndef USE_SAMPLERATE
sampleRate = 8000;
#else
if (sampleRate <=0 ) {
......@@ -1438,52 +1443,47 @@ ManagerImpl::getAudioDeviceList(const std::string& sequenceId, int ioDeviceMask)
const char *hostApiName;
const char *deviceName;
int deviceIsSupported = false;
int deviceRate = audiolayer->getSampleRate();
double deviceRate;
for (int index = 0; index < sys.deviceCount(); index++ ) {
portaudio::Device& device = sys.deviceByIndex(index);
deviceIsSupported = false;
// TODO, put this code into AudioDriver()
if (ioDeviceMask == AudioLayer::InputDevice && !device.isOutputOnlyDevice()) {
//portaudio::DirectionSpecificStreamParameters inputParameters(device, device.maxInputChannels(), portaudio::INT16, true, 0.0, NULL);
//portaudio::DirectionSpecificStreamParameters outputParameters = portaudio::DirectionSpecificStreamParameters::null();
//portaudio::StreamParameters tmp = portaudio::StreamParameters(inputParameters, outputParameters, deviceRate, 0, paNoFlag);
//if (tmp.isSupported()) {
deviceIsSupported = true;
//}
} else if (ioDeviceMask == AudioLayer::OutputDevice && !device.isInputOnlyDevice()) {
//portaudio::DirectionSpecificStreamParameters inputParameters = portaudio::DirectionSpecificStreamParameters::null();
//portaudio::DirectionSpecificStreamParameters outputParameters(device, device.maxOutputChannels(), portaudio::INT16, true, 0.0, NULL);
//portaudio::StreamParameters tmp = portaudio::StreamParameters(inputParameters, outputParameters, deviceRate, 0, paNoFlag);
//if (tmp.isSupported()) {
deviceIsSupported = true;
//}
} else if (device.isFullDuplexDevice()) {
//portaudio::DirectionSpecificStreamParameters inputParameters(device, device.maxInputChannels(), portaudio::INT16, true, 0.0, NULL);
//portaudio::DirectionSpecificStreamParameters outputParameters(device, device.maxOutputChannels(), portaudio::INT16, true, 0.0, NULL);
//portaudio::StreamParameters tmp = portaudio::StreamParameters(inputParameters, outputParameters, deviceRate, 0, paNoFlag);
//if (tmp.isSupported()) {
deviceIsSupported = true;
//}
}
if (deviceIsSupported) {
hostApiName = device.hostApi().name();
deviceName = device.name();
deviceRate = device.defaultSampleRate();
tk.clear();
std::ostringstream str; str << index; tk.push_back(str.str());
tk.push_back(deviceName);
tk.push_back(std::string(hostApiName));
std::ostringstream rate; rate << (int)deviceRate; tk.push_back(rate.str());
_gui->sendMessage("100", sequenceId, tk);
}
}
returnValue = true;
std::ostringstream rate;
#ifdef USE_SAMPLERATE
rate << "VARIABLE";
#else
rate << "8000";
#endif
tk.clear();
tk.push_back(rate.str());
_gui->sendMessage("101", sequenceId, tk);
} catch (...) {
returnValue = false;
}
audiolayer->startStream();
//audiolayer->startStream();
return returnValue;
}
......
Supports Markdown
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