List of audio devices fetched on server

parent 0467fbb7
......@@ -27,6 +27,7 @@
#include <mainwindow.h>
#include <stdlib.h>
#include <stdio.h>
#include <gtk/gtk.h>
......@@ -165,6 +166,7 @@ config_window_fill_output_audio_device_list()
{
GtkTreeIter iter;
gchar** list;
gchar** details;
gchar* audioDevice;
gtk_list_store_clear(outputAudioDeviceManagerStore);
......@@ -177,8 +179,10 @@ config_window_fill_output_audio_device_list()
for(audioDevice = list[c]; audioDevice != NULL; audioDevice = list[c])
{
c++;
int index = atoi(audioDevice);
details = dbus_get_audio_device_details(index);
gtk_list_store_append(outputAudioDeviceManagerStore, &iter);
gtk_list_store_set(outputAudioDeviceManagerStore, &iter, 0 , audioDevice, -1);
gtk_list_store_set(outputAudioDeviceManagerStore, &iter, 0, details[0], 1, index, -1);
}
}
......@@ -190,6 +194,7 @@ config_window_fill_input_audio_device_list()
{
GtkTreeIter iter;
gchar** list;
gchar** details;
gchar* audioDevice;
gtk_list_store_clear(inputAudioDeviceManagerStore);
......@@ -202,8 +207,10 @@ config_window_fill_input_audio_device_list()
for(audioDevice = list[c]; audioDevice != NULL; audioDevice = list[c])
{
c++;
int index = atoi(audioDevice);
details = dbus_get_audio_device_details(index);
gtk_list_store_append(inputAudioDeviceManagerStore, &iter);
gtk_list_store_set(inputAudioDeviceManagerStore, &iter, 0 , audioDevice, -1);
gtk_list_store_set(inputAudioDeviceManagerStore, &iter, 0, details[0], 1, index, -1);
}
}
......@@ -213,7 +220,7 @@ config_window_fill_input_audio_device_list()
static void
select_audio_manager(GtkWidget* widget, gpointer data)
{
dbus_set_audio_manager("ALSA");
dbus_set_audio_manager("");
}
/**
......@@ -240,14 +247,14 @@ select_audio_input_device(GtkWidget* widget, gpointer data)
static void
detect_all_audio_settings()
{
// TODO Remember selected entry for each list
// NOW Remember selected entry for each list
// Update lists
config_window_fill_audio_manager_list();
config_window_fill_output_audio_device_list();
config_window_fill_input_audio_device_list();
// Reselect entries or set to default
// TODO Reselect entries or set to default
}
/**
......@@ -812,10 +819,10 @@ create_audio_tab ()
gtk_table_attach(GTK_TABLE(deviceTable), titleLabel, 1, 2, 1, 2, GTK_FILL | GTK_EXPAND, GTK_SHRINK, 0, 0);
gtk_widget_show(titleLabel);
// Set choices of output devices
outputAudioDeviceManagerStore = gtk_list_store_new(1, G_TYPE_STRING);
outputAudioDeviceManagerStore = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_INT);
config_window_fill_output_audio_device_list();
comboBox = gtk_combo_box_new_with_model(GTK_TREE_MODEL(outputAudioDeviceManagerStore));
gtk_combo_box_set_active(GTK_COMBO_BOX(comboBox), 0);
gtk_combo_box_set_active(GTK_COMBO_BOX(comboBox), 1);
gtk_label_set_mnemonic_widget(GTK_LABEL(titleLabel), comboBox);
g_signal_connect(G_OBJECT(comboBox), "changed", G_CALLBACK(select_audio_output_device), comboBox);
......@@ -833,7 +840,7 @@ create_audio_tab ()
gtk_table_attach(GTK_TABLE(deviceTable), titleLabel, 1, 2, 2, 3, GTK_FILL | GTK_EXPAND, GTK_SHRINK, 0, 0);
gtk_widget_show(titleLabel);
// Set choices of output devices
inputAudioDeviceManagerStore = gtk_list_store_new(1, G_TYPE_STRING);
inputAudioDeviceManagerStore = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_INT);
config_window_fill_input_audio_device_list();
comboBox = gtk_combo_box_new_with_model(GTK_TREE_MODEL(inputAudioDeviceManagerStore));
gtk_combo_box_set_active(GTK_COMBO_BOX(comboBox), 0);
......
......@@ -76,27 +76,19 @@ class AudioLayer {
* Get the sample rate of audiolayer
* accessor only
*/
int getIndexIn() { return _indexIn; }
int getIndexOut() { return _indexOut; }
unsigned int getSampleRate() { return _sampleRate; }
unsigned int getFrameSize() { return _frameSize; }
int getDeviceCount();
// NOW
void selectPreferedApi(PaHostApiTypeId apiTypeID, int& outputDeviceIndex, int& inputDeviceIndex);
std::vector<std::string> getAudioDeviceList(PaHostApiTypeId apiTypeID, int ioDeviceMask);
// void setOutputAudioDevice(int index);
// std::vector<std::string> getInputAudioDeviceList();
// void setInputAudioDevice(int index);
// std::vector<AudioDevice*> getAudioDevicesInfo();
AudioDevice* getAudioDeviceInfo(int index, int ioDeviceMask);
enum IODEVICE {InputDevice=0x01, OutputDevice=0x02 };
......
......@@ -1205,6 +1205,7 @@ ManagerImpl::getCodecDetails( const ::DBus::Int32& payload )
return v;
}
/**
* Get list of supported audio manager
*/
......@@ -1246,6 +1247,7 @@ void
ManagerImpl::setAudioOutputDevice(const int index)
{
_debug("Set audio output device");
_audiodriver->openDevice(_audiodriver->getIndexIn(), index, _audiodriver->getSampleRate(), _audiodriver->getFrameSize());
printf("%l audio output set\n", index);
}
......@@ -1267,6 +1269,7 @@ ManagerImpl::setAudioInputDevice(const int index)
{
// TODO
_debug("Set audio input device");
_audiodriver->openDevice(index, _audiodriver->getIndexOut(), _audiodriver->getSampleRate(), _audiodriver->getFrameSize());
printf("%l audio input set\n", index);
}
......@@ -1280,8 +1283,11 @@ ManagerImpl::getCurrentAudioDevicesIndex()
_debug("Get current audio devices index");
std::vector<std::string> v;
v.push_back("6");
v.push_back("12");
char index[10];
sprintf(index, "%d", _audiodriver->getIndexOut());
v.push_back(index);
sprintf(index, "%d", _audiodriver->getIndexIn());
v.push_back(index);
return v;
}
......@@ -1292,15 +1298,24 @@ ManagerImpl::getCurrentAudioDevicesIndex()
std::vector<std::string>
ManagerImpl::getAudioDeviceDetails(const int index)
{
// TODO
_debug("Get audio input device list");
std::vector<std::string> v;
v.push_back("default");
v.push_back("128");
v.push_back("128");
v.push_back("44100");
try
{
portaudio::System& sys = portaudio::System::instance();
portaudio::Device& device = sys.deviceByIndex(index);
char answer[10];
v.push_back(device.name());
sprintf(answer, "%d", device.maxInputChannels());
v.push_back(answer);
sprintf(answer, "%d", device.maxOutputChannels());
v.push_back(answer);
sprintf(answer, "%d", device.defaultSampleRate());
v.push_back(answer);
}
catch (...) {}
return v;
}
......
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