@@ -146,21 +146,28 @@ AudioSampleFormat get_sample_format(QAudioFormat& native_format){
146146}
147147
148148
149+ std::string format_to_str (const QAudioFormat& format){
150+ std::string str;
151+ str += " Preferred Format:\n " ;
152+ str += " Channels: " + std::to_string (format.channelCount ()) + " \n " ;
153+ str += " Sample Rate: " + std::to_string (format.sampleRate ()) + " \n " ;
154+ #if QT_VERSION_MAJOR == 5
155+ str += " Sample Format: " + std::to_string (format.sampleType ()) + " \n " ;
156+ #else
157+ str += " Sample Format: " + std::to_string (format.sampleFormat ()) + " \n " ;
158+ #endif
159+ return str;
160+ }
161+
162+
149163// Return a list of our formats that are supported by this device.
150164// "preferred_index" is set to the index of the list that is preferred by the device.
151165// If no preferred format matches our formats, -1 is returned.
152166std::vector<AudioChannelFormat> supported_input_formats (int & preferred_index, const NativeAudioInfo& info, const std::string& display_name){
153167 QAudioFormat preferred_format = info.preferredFormat ();
154168
155169 std::string str = display_name + " \n " ;
156- str += " Preferred Format:\n " ;
157- str += " Channels: " + std::to_string (preferred_format.channelCount ()) + " \n " ;
158- str += " Sample Rate: " + std::to_string (preferred_format.sampleRate ()) + " \n " ;
159- #if QT_VERSION_MAJOR == 5
160- str += " Sample Format: " + std::to_string (preferred_format.sampleType ()) + " \n " ;
161- #else
162- str += " Sample Format: " + std::to_string (preferred_format.sampleFormat ()) + " \n " ;
163- #endif
170+ str += format_to_str (preferred_format);
164171 global_logger_tagged ().log (str);
165172
166173// preferred_format.setSampleSize(16);
@@ -420,19 +427,31 @@ std::vector<AudioDeviceInfo> AudioDeviceInfo::all_output_devices(){
420427 Data& data = *list.back ().m_body ;
421428
422429 std::string name = device.deviceName ().toStdString ();
430+
431+ std::string str = name + " \n " ;
432+ str += format_to_str (device.preferredFormat ());
433+ global_logger_tagged ().log (str);
434+
423435 data.device_name = name;
424436 data.display_name = std::move (name);
425437 data.info = std::move (device);
426438
427439 data.supported_formats = supported_output_formats (data.preferred_format_index , data.info );
440+
428441 }
429442#elif QT_VERSION_MAJOR == 6
430443 for (NativeAudioInfo& device : QMediaDevices::audioOutputs ()){
431444 list.emplace_back ();
432445 Data& data = *list.back ().m_body ;
433446
447+ std::string name = device.description ().toStdString ();
448+
449+ std::string str = name + " \n " ;
450+ str += format_to_str (device.preferredFormat ());
451+ global_logger_tagged ().log (str);
452+
434453 data.device_name = device.id ().toStdString ();
435- data.display_name = device. description (). toStdString ( );
454+ data.display_name = std::move (name );
436455 data.info = std::move (device);
437456
438457 data.supported_formats = supported_output_formats (data.preferred_format_index , data.info );
0 commit comments