From 60e740482040999f31a12d98b2f8261743fba595 Mon Sep 17 00:00:00 2001 From: Chun-Min Chang Date: Fri, 21 Jul 2017 17:58:59 +0800 Subject: [PATCH] Bug 1197045 - part3: Add audio devices information to about:support; r=Felipe MozReview-Commit-ID: Lo3WgXC5ikN --HG-- extra : rebase_source : 9a61a04a6f880e8d99eaa9f7441bcb2e2a6b1e1c --- toolkit/content/aboutSupport.js | 106 +++++++++++++++++- toolkit/content/aboutSupport.xhtml | 85 ++++++++++++++ .../en-US/chrome/global/aboutSupport.dtd | 13 +++ .../chrome/global/aboutSupport.properties | 8 +- toolkit/modules/Troubleshoot.jsm | 45 +++++++- 5 files changed, 252 insertions(+), 5 deletions(-) diff --git a/toolkit/content/aboutSupport.js b/toolkit/content/aboutSupport.js index 2e5b72b25295..3d87757cc829 100644 --- a/toolkit/content/aboutSupport.js +++ b/toolkit/content/aboutSupport.js @@ -449,7 +449,6 @@ var snapshotFormatters = { addRowFromKey("features", "webgl2DriverExtensions"); addRowFromKey("features", "webgl2Extensions"); addRowFromKey("features", "supportsHardwareH264", "hardwareH264"); - addRowFromKey("features", "currentAudioBackend", "audioBackend"); addRowFromKey("features", "direct2DEnabled", "#Direct2D"); if ("directWriteEnabled" in data) { @@ -598,6 +597,111 @@ var snapshotFormatters = { } }, + media: function media(data) { + let strings = stringBundle(); + + function insertBasicInfo(key, value) { + function createRow(key, value) { + let th = $.new("th", strings.GetStringFromName(key), "column"); + let td = $.new("td", value); + td.style["white-space"] = "pre-wrap"; + return $.new("tr", [th, td]); + } + $.append($("media-info-tbody"), [createRow(key, value)]); + } + + function createDeviceInfoRow(device) { + let deviceInfo = Ci.nsIAudioDeviceInfo; + + let states = {}; + states[deviceInfo.STATE_DISABLED] = "Disabled"; + states[deviceInfo.STATE_UNPLUGGED] = "Unplugged"; + states[deviceInfo.STATE_ENABLED] = "Enabled"; + + let preferreds = {}; + preferreds[deviceInfo.PREF_NONE] = "None"; + preferreds[deviceInfo.PREF_MULTIMEDIA] = "Multimedia"; + preferreds[deviceInfo.PREF_VOICE] = "Voice"; + preferreds[deviceInfo.PREF_NOTIFICATION] = "Notification"; + preferreds[deviceInfo.PREF_ALL] = "All"; + + let formats = {}; + formats[deviceInfo.FMT_S16LE] = "S16LE"; + formats[deviceInfo.FMT_S16BE] = "S16BE"; + formats[deviceInfo.FMT_F32LE] = "F32LE"; + formats[deviceInfo.FMT_F32BE] = "F32BE"; + + function toPreferredString(preferred) { + if (preferred == deviceInfo.PREF_NONE) { + return preferreds[deviceInfo.PREF_NONE]; + } else if (preferred & deviceInfo.PREF_ALL) { + return preferreds[deviceInfo.PREF_ALL]; + } + let str = ""; + for (let pref of [deviceInfo.PREF_MULTIMEDIA, + deviceInfo.PREF_VOICE, + deviceInfo.PREF_NOTIFICATION]) { + if (preferred & pref) { + str += " " + preferreds[pref]; + } + } + return str; + } + + function toFromatString(dev) { + let str = "default: " + formats[dev.defaultFormat] + ", support:"; + for (let fmt of [deviceInfo.FMT_S16LE, + deviceInfo.FMT_S16BE, + deviceInfo.FMT_F32LE, + deviceInfo.FMT_F32BE]) { + if (dev.supportedFormat & fmt) { + str += " " + formats[fmt]; + } + } + return str; + } + + function toRateString(dev) { + return "default: " + dev.defaultRate + + ", support: " + dev.minRate + " - " + dev.maxRate; + } + + function toLatencyString(dev) { + return dev.minLatency + " - " + dev.maxLatency; + } + + return $.new("tr", [$.new("td", device.name), + $.new("td", device.groupId), + $.new("td", device.vendor), + $.new("td", states[device.state]), + $.new("td", toPreferredString(device.preferred)), + $.new("td", toFromatString(device)), + $.new("td", device.maxChannels), + $.new("td", toRateString(device)), + $.new("td", toLatencyString(device))]); + } + + function insertDeviceInfo(side, devices) { + let rows = []; + for (let dev of devices) { + rows.push(createDeviceInfoRow(dev)); + } + $.append($("media-" + side + "-devices-tbody"), rows); + } + + // Basic information + insertBasicInfo("audioBackend", data.currentAudioBackend); + insertBasicInfo("maxAudioChannels", data.currentMaxAudioChannels); + insertBasicInfo("channelLayout", data.currentPreferredChannelLayout); + insertBasicInfo("sampleRate", data.currentPreferredSampleRate); + + // Output devices information + insertDeviceInfo("output", data.audioOutputDevices); + + // Input devices information + insertDeviceInfo("input", data.audioInputDevices); + }, + javaScript: function javaScript(data) { $("javascript-incremental-gc").textContent = data.incrementalGCEnabled; }, diff --git a/toolkit/content/aboutSupport.xhtml b/toolkit/content/aboutSupport.xhtml index ded2edfaaae3..4081306d5463 100644 --- a/toolkit/content/aboutSupport.xhtml +++ b/toolkit/content/aboutSupport.xhtml @@ -443,6 +443,91 @@ +

+ &aboutSupport.mediaTitle; +

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ &aboutSupport.mediaOutputDevicesTitle; +
+ &aboutSupport.mediaDeviceName; + + &aboutSupport.mediaDeviceGroup; + + &aboutSupport.mediaDeviceVendor; + + &aboutSupport.mediaDeviceState; + + &aboutSupport.mediaDevicePreferred; + + &aboutSupport.mediaDeviceFormat; + + &aboutSupport.mediaDeviceChannels; + + &aboutSupport.mediaDeviceRate; + + &aboutSupport.mediaDeviceLatency; +
+ &aboutSupport.mediaInputDevicesTitle; +
+ &aboutSupport.mediaDeviceName; + + &aboutSupport.mediaDeviceGroup; + + &aboutSupport.mediaDeviceVendor; + + &aboutSupport.mediaDeviceState; + + &aboutSupport.mediaDevicePreferred; + + &aboutSupport.mediaDeviceFormat; + + &aboutSupport.mediaDeviceChannels; + + &aboutSupport.mediaDeviceRate; + + &aboutSupport.mediaDeviceLatency; +
+ + +

&aboutSupport.modifiedKeyPrefsTitle;

diff --git a/toolkit/locales/en-US/chrome/global/aboutSupport.dtd b/toolkit/locales/en-US/chrome/global/aboutSupport.dtd index 34b7b0f53ad8..606032c6e4ff 100644 --- a/toolkit/locales/en-US/chrome/global/aboutSupport.dtd +++ b/toolkit/locales/en-US/chrome/global/aboutSupport.dtd @@ -141,3 +141,16 @@ variant of aboutSupport.showDir.label. --> + + + + + + + + + + + + + diff --git a/toolkit/locales/en-US/chrome/global/aboutSupport.properties b/toolkit/locales/en-US/chrome/global/aboutSupport.properties index 01a6b7b72b4c..35e315359217 100644 --- a/toolkit/locales/en-US/chrome/global/aboutSupport.properties +++ b/toolkit/locales/en-US/chrome/global/aboutSupport.properties @@ -57,7 +57,6 @@ clearTypeParameters = ClearType Parameters compositing = Compositing hardwareH264 = Hardware H264 Decoding -audioBackend = Audio Backend mainThreadNoOMTC = main thread, no OMTC yes = Yes no = No @@ -102,6 +101,11 @@ resetOnNextRestart = Reset on Next Restart gpuProcessKillButton = Terminate GPU Process gpuDeviceResetButton = Trigger Device Reset +audioBackend = Audio Backend +maxAudioChannels = Max Channels +channelLayout = Preferred Channel Layout +sampleRate = Preferred Sample Rate + minLibVersions = Expected minimum version loadedLibVersions = Version in use @@ -149,4 +153,4 @@ disabledByBuild = disabled by build enabledByDefault = enabled by default disabledByDefault = disabled by default enabledByUser = enabled by user -disabledByUser = disabled by user \ No newline at end of file +disabledByUser = disabled by user diff --git a/toolkit/modules/Troubleshoot.jsm b/toolkit/modules/Troubleshoot.jsm index 67c379cecd5c..2d18a601743d 100644 --- a/toolkit/modules/Troubleshoot.jsm +++ b/toolkit/modules/Troubleshoot.jsm @@ -402,8 +402,6 @@ var dataProviders = { QueryInterface(Ci.nsIInterfaceRequestor). getInterface(Ci.nsIDOMWindowUtils) - data.currentAudioBackend = winUtils.currentAudioBackend; - if (!data.numAcceleratedWindows && gfxInfo) { let win = AppConstants.platform == "win"; let feature = win ? gfxInfo.FEATURE_DIRECT3D_9_LAYERS : @@ -548,6 +546,49 @@ var dataProviders = { completed(); }, + media: function media(done) { + function convertDevices(devices) { + if (!devices) { + return undefined; + } + let infos = []; + for (let i = 0; i < devices.length; ++i) { + let device = devices.queryElementAt(i, Ci.nsIAudioDeviceInfo); + infos.push({ + name: device.name, + groupId: device.groupId, + vendor: device.vendor, + type: device.type, + state: device.state, + preferred: device.preferred, + supportedFormat: device.supportedFormat, + defaultFormat: device.defaultFormat, + maxChannels: device.maxChannels, + defaultRate: device.defaultRate, + maxRate: device.maxRate, + minRate: device.minRate, + maxLatency: device.maxLatency, + minLatency: device.minLatency + }); + } + return infos; + } + + let data = {}; + let winUtils = Services.wm.getMostRecentWindow(""). + QueryInterface(Ci.nsIInterfaceRequestor). + getInterface(Ci.nsIDOMWindowUtils); + data.currentAudioBackend = winUtils.currentAudioBackend; + data.currentMaxAudioChannels = winUtils.currentMaxAudioChannels; + data.currentPreferredChannelLayout = winUtils.currentPreferredChannelLayout; + data.currentPreferredSampleRate = winUtils.currentPreferredSampleRate; + data.audioOutputDevices = convertDevices(winUtils.audioDevices(Ci.nsIDOMWindowUtils.AUDIO_OUTPUT). + QueryInterface(Ci.nsIArray)); + data.audioInputDevices = convertDevices(winUtils.audioDevices(Ci.nsIDOMWindowUtils.AUDIO_INPUT). + QueryInterface(Ci.nsIArray)); + done(data); + }, + javaScript: function javaScript(done) { let data = {}; let winEnumer = Services.ww.getWindowEnumerator();