src/3rdparty/phonon/gstreamer/audiooutput.cpp
changeset 3 41300fa6a67c
parent 0 1918ee327afb
child 30 5dc02b23752f
equal deleted inserted replaced
2:56cd8111b7f7 3:41300fa6a67c
    40         , m_conv(0)
    40         , m_conv(0)
    41 {
    41 {
    42     static int count = 0;
    42     static int count = 0;
    43     m_name = "AudioOutput" + QString::number(count++);
    43     m_name = "AudioOutput" + QString::number(count++);
    44     if (m_backend->isValid()) {
    44     if (m_backend->isValid()) {
    45         g_set_application_name(qApp->applicationName().toUtf8());
       
    46         m_audioBin = gst_bin_new (NULL);
    45         m_audioBin = gst_bin_new (NULL);
    47         gst_object_ref (GST_OBJECT (m_audioBin));
    46         gst_object_ref (GST_OBJECT (m_audioBin));
    48         gst_object_sink (GST_OBJECT (m_audioBin));     
    47         gst_object_sink (GST_OBJECT (m_audioBin));     
    49 
    48 
    50         m_conv = gst_element_factory_make ("audioconvert", NULL);
    49         m_conv = gst_element_factory_make ("audioconvert", NULL);
   135             return false;
   134             return false;
   136     }
   135     }
   137 
   136 
   138     bool success = false;
   137     bool success = false;
   139     const QList<AudioDevice> deviceList = m_backend->deviceManager()->audioOutputDevices();
   138     const QList<AudioDevice> deviceList = m_backend->deviceManager()->audioOutputDevices();
   140     if (m_audioSink &&  newDevice >= 0 && newDevice < deviceList.size()) {
   139     int deviceIdx = -1;
       
   140     for (int i=0; i<deviceList.size(); i++) {
       
   141         if (deviceList.at(i).id == newDevice) {
       
   142             deviceIdx = i;
       
   143             break;
       
   144         }
       
   145     }
       
   146 
       
   147     if (m_audioSink && deviceIdx >= 0) {
   141         // Save previous state
   148         // Save previous state
   142         GstState oldState = GST_STATE(m_audioSink);
   149         GstState oldState = GST_STATE(m_audioSink);
   143         const QByteArray oldDeviceValue = GstHelper::property(m_audioSink, "device");
   150         const QByteArray oldDeviceValue = GstHelper::property(m_audioSink, "device");
   144         const QByteArray deviceId = deviceList.at(newDevice).gstId;
   151         const QByteArray deviceId = deviceList.at(deviceIdx).gstId;
   145         m_device = newDevice;
   152         m_device = newDevice;
   146 
   153 
   147         // We test if the device can be opened by checking if it can go from NULL to READY state
   154         // We test if the device can be opened by checking if it can go from NULL to READY state
   148         gst_element_set_state(m_audioSink, GST_STATE_NULL);
   155         gst_element_set_state(m_audioSink, GST_STATE_NULL);
   149         success = GstHelper::setProperty(m_audioSink, "device", deviceId);
   156         success = GstHelper::setProperty(m_audioSink, "device", deviceId);