mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-11 20:35:50 +00:00
Backed out changeset cf756c62b0a6 (bug 1197045)
This commit is contained in:
parent
2856cb892f
commit
0a44c0dc0a
@ -75,7 +75,6 @@
|
|||||||
#include "Layers.h"
|
#include "Layers.h"
|
||||||
#include "gfxPrefs.h"
|
#include "gfxPrefs.h"
|
||||||
|
|
||||||
#include "mozilla/dom/AudioDeviceInfo.h"
|
|
||||||
#include "mozilla/dom/Element.h"
|
#include "mozilla/dom/Element.h"
|
||||||
#include "mozilla/dom/TabChild.h"
|
#include "mozilla/dom/TabChild.h"
|
||||||
#include "mozilla/dom/IDBFactoryBinding.h"
|
#include "mozilla/dom/IDBFactoryBinding.h"
|
||||||
@ -2477,53 +2476,6 @@ nsDOMWindowUtils::GetCurrentAudioBackend(nsAString& aBackend)
|
|||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP
|
|
||||||
nsDOMWindowUtils::GetCurrentMaxAudioChannels(uint32_t* aChannels)
|
|
||||||
{
|
|
||||||
*aChannels = CubebUtils::MaxNumberOfChannels();
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
|
||||||
nsDOMWindowUtils::GetCurrentPreferredChannelLayout(nsAString& aLayout)
|
|
||||||
{
|
|
||||||
CubebUtils::GetPreferredChannelLayout(aLayout);
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
|
||||||
nsDOMWindowUtils::GetCurrentPreferredSampleRate(uint32_t* aRate)
|
|
||||||
{
|
|
||||||
*aRate = CubebUtils::PreferredSampleRate();
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
|
||||||
nsDOMWindowUtils::AudioDevices(uint16_t aSide, nsIArray** aDevices)
|
|
||||||
{
|
|
||||||
NS_ENSURE_ARG_POINTER(aDevices);
|
|
||||||
NS_ENSURE_ARG((aSide == AUDIO_INPUT) || (aSide == AUDIO_OUTPUT));
|
|
||||||
*aDevices = nullptr;
|
|
||||||
|
|
||||||
nsresult rv = NS_OK;
|
|
||||||
nsCOMPtr<nsIMutableArray> devices =
|
|
||||||
do_CreateInstance(NS_ARRAY_CONTRACTID, &rv);
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
|
|
||||||
nsTArray<RefPtr<AudioDeviceInfo>> collection;
|
|
||||||
CubebUtils::GetDeviceCollection(collection,
|
|
||||||
aSide == AUDIO_INPUT
|
|
||||||
? CubebUtils::Side::Input
|
|
||||||
: CubebUtils::Side::Output);
|
|
||||||
for (auto device: collection) {
|
|
||||||
devices->AppendElement(device, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
devices.forget(aDevices);
|
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
nsDOMWindowUtils::StartFrameTimeRecording(uint32_t *startIndex)
|
nsDOMWindowUtils::StartFrameTimeRecording(uint32_t *startIndex)
|
||||||
{
|
{
|
||||||
|
@ -29,7 +29,6 @@ native nscolor(nscolor);
|
|||||||
[ptr] native gfxContext(gfxContext);
|
[ptr] native gfxContext(gfxContext);
|
||||||
typedef unsigned long long nsViewID;
|
typedef unsigned long long nsViewID;
|
||||||
|
|
||||||
interface nsIArray;
|
|
||||||
interface nsICycleCollectorListener;
|
interface nsICycleCollectorListener;
|
||||||
interface nsIDOMNode;
|
interface nsIDOMNode;
|
||||||
interface nsIDOMNodeList;
|
interface nsIDOMNodeList;
|
||||||
@ -1427,28 +1426,6 @@ interface nsIDOMWindowUtils : nsISupports {
|
|||||||
*/
|
*/
|
||||||
readonly attribute AString currentAudioBackend;
|
readonly attribute AString currentAudioBackend;
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the max channel counts of the current audio device.
|
|
||||||
*/
|
|
||||||
readonly attribute unsigned long currentMaxAudioChannels;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the preferred channel layout of the current audio device.
|
|
||||||
*/
|
|
||||||
readonly attribute AString currentPreferredChannelLayout;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the preferred sample rate of the current audio device.
|
|
||||||
*/
|
|
||||||
readonly attribute unsigned long currentPreferredSampleRate;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns all the audio input/output devices.
|
|
||||||
*/
|
|
||||||
const unsigned short AUDIO_INPUT = 0;
|
|
||||||
const unsigned short AUDIO_OUTPUT = 1;
|
|
||||||
nsIArray audioDevices(in unsigned short aSide);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Record (and return) frame-intervals for frames which were presented
|
* Record (and return) frame-intervals for frames which were presented
|
||||||
* between calling StartFrameTimeRecording and StopFrameTimeRecording.
|
* between calling StartFrameTimeRecording and StopFrameTimeRecording.
|
||||||
|
@ -104,33 +104,6 @@ const int CUBEB_BACKEND_INIT_FAILURE_OTHER = CUBEB_BACKEND_INIT_FAILURE_FIRST +
|
|||||||
/* Index for an unknown backend. */
|
/* Index for an unknown backend. */
|
||||||
const int CUBEB_BACKEND_UNKNOWN = CUBEB_BACKEND_INIT_FAILURE_FIRST + 2;
|
const int CUBEB_BACKEND_UNKNOWN = CUBEB_BACKEND_INIT_FAILURE_FIRST + 2;
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
const char* name;
|
|
||||||
const unsigned int channels;
|
|
||||||
const uint32_t mask;
|
|
||||||
} layoutInfo;
|
|
||||||
|
|
||||||
const layoutInfo kLayoutInfos[CUBEB_LAYOUT_MAX] = {
|
|
||||||
{ "undefined", 0, 0 }, // CUBEB_LAYOUT_UNDEFINED
|
|
||||||
{ "dual mono", 2, MASK_STEREO }, // CUBEB_LAYOUT_DUAL_MONO
|
|
||||||
{ "dual mono lfe", 3, MASK_STEREO_LFE }, // CUBEB_LAYOUT_DUAL_MONO_LFE
|
|
||||||
{ "mono", 1, MASK_MONO }, // CUBEB_LAYOUT_MONO
|
|
||||||
{ "mono lfe", 2, MASK_MONO_LFE }, // CUBEB_LAYOUT_MONO_LFE
|
|
||||||
{ "stereo", 2, MASK_STEREO }, // CUBEB_LAYOUT_STEREO
|
|
||||||
{ "stereo lfe", 3, MASK_STEREO_LFE }, // CUBEB_LAYOUT_STEREO_LFE
|
|
||||||
{ "3f", 3, MASK_3F }, // CUBEB_LAYOUT_3F
|
|
||||||
{ "3f lfe", 4, MASK_3F_LFE }, // CUBEB_LAYOUT_3F_LFE
|
|
||||||
{ "2f1", 3, MASK_2F1 }, // CUBEB_LAYOUT_2F1
|
|
||||||
{ "2f1 lfe", 4, MASK_2F1_LFE }, // CUBEB_LAYOUT_2F1_LFE
|
|
||||||
{ "3f1", 4, MASK_3F1 }, // CUBEB_LAYOUT_3F1
|
|
||||||
{ "3f1 lfe", 5, MASK_3F1_LFE }, // CUBEB_LAYOUT_3F1_LFE
|
|
||||||
{ "2f2", 4, MASK_2F2_LFE }, // CUBEB_LAYOUT_2F2
|
|
||||||
{ "2f2 lfe", 5, MASK_2F2_LFE }, // CUBEB_LAYOUT_2F2_LFE
|
|
||||||
{ "3f2", 5, MASK_3F2 }, // CUBEB_LAYOUT_3F2
|
|
||||||
{ "3f2 lfe", 6, MASK_3F2_LFE }, // CUBEB_LAYOUT_3F2_LFE
|
|
||||||
{ "3f3r lfe", 7, MASK_3F3R_LFE }, // CUBEB_LAYOUT_3F3R_LFE
|
|
||||||
{ "3f4 lfe", 8, MASK_3F4_LFE } // CUBEB_LAYOUT_3F4_LFE
|
|
||||||
};
|
|
||||||
|
|
||||||
// Prefered samplerate, in Hz (characteristic of the hardware, mixer, platform,
|
// Prefered samplerate, in Hz (characteristic of the hardware, mixer, platform,
|
||||||
// and API used).
|
// and API used).
|
||||||
@ -291,15 +264,42 @@ bool InitPreferredChannelLayout()
|
|||||||
|
|
||||||
uint32_t PreferredChannelMap(uint32_t aChannels)
|
uint32_t PreferredChannelMap(uint32_t aChannels)
|
||||||
{
|
{
|
||||||
|
// The first element of the following mapping table is channel counts,
|
||||||
|
// and the second one is its bit mask. It will be used in many times,
|
||||||
|
// so we shoule avoid to allocate it in stack, or it will be created
|
||||||
|
// and removed repeatedly. Use static to allocate this local variable
|
||||||
|
// in data space instead of stack.
|
||||||
|
static uint32_t layoutInfo[CUBEB_LAYOUT_MAX][2] = {
|
||||||
|
{ 0, 0 }, // CUBEB_LAYOUT_UNDEFINED
|
||||||
|
{ 2, MASK_STEREO }, // CUBEB_LAYOUT_DUAL_MONO
|
||||||
|
{ 3, MASK_STEREO_LFE }, // CUBEB_LAYOUT_DUAL_MONO_LFE
|
||||||
|
{ 1, MASK_MONO }, // CUBEB_LAYOUT_MONO
|
||||||
|
{ 2, MASK_MONO_LFE }, // CUBEB_LAYOUT_MONO_LFE
|
||||||
|
{ 2, MASK_STEREO }, // CUBEB_LAYOUT_STEREO
|
||||||
|
{ 3, MASK_STEREO_LFE }, // CUBEB_LAYOUT_STEREO_LFE
|
||||||
|
{ 3, MASK_3F }, // CUBEB_LAYOUT_3F
|
||||||
|
{ 4, MASK_3F_LFE }, // CUBEB_LAYOUT_3F_LFE
|
||||||
|
{ 3, MASK_2F1 }, // CUBEB_LAYOUT_2F1
|
||||||
|
{ 4, MASK_2F1_LFE }, // CUBEB_LAYOUT_2F1_LFE
|
||||||
|
{ 4, MASK_3F1 }, // CUBEB_LAYOUT_3F1
|
||||||
|
{ 5, MASK_3F1_LFE }, // CUBEB_LAYOUT_3F1_LFE
|
||||||
|
{ 4, MASK_2F2 }, // CUBEB_LAYOUT_2F2
|
||||||
|
{ 5, MASK_2F2_LFE }, // CUBEB_LAYOUT_2F2_LFE
|
||||||
|
{ 5, MASK_3F2 }, // CUBEB_LAYOUT_3F2
|
||||||
|
{ 6, MASK_3F2_LFE }, // CUBEB_LAYOUT_3F2_LFE
|
||||||
|
{ 7, MASK_3F3R_LFE }, // CUBEB_LAYOUT_3F3R_LFE
|
||||||
|
{ 8, MASK_3F4_LFE }, // CUBEB_LAYOUT_3F4_LFE
|
||||||
|
};
|
||||||
|
|
||||||
// Use SMPTE default channel map if we can't get preferred layout
|
// Use SMPTE default channel map if we can't get preferred layout
|
||||||
// or the channel counts of preferred layout is different from input's one
|
// or the channel counts of preferred layout is different from input's one
|
||||||
if (!InitPreferredChannelLayout()
|
if (!InitPreferredChannelLayout()
|
||||||
|| kLayoutInfos[sPreferredChannelLayout].channels != aChannels) {
|
|| layoutInfo[sPreferredChannelLayout][0] != aChannels) {
|
||||||
AudioConfig::ChannelLayout smpteLayout(aChannels);
|
AudioConfig::ChannelLayout smpteLayout(aChannels);
|
||||||
return smpteLayout.Map();
|
return smpteLayout.Map();
|
||||||
}
|
}
|
||||||
|
|
||||||
return kLayoutInfos[sPreferredChannelLayout].mask;
|
return layoutInfo[sPreferredChannelLayout][1];
|
||||||
}
|
}
|
||||||
|
|
||||||
void InitBrandName()
|
void InitBrandName()
|
||||||
@ -531,105 +531,5 @@ void GetCurrentBackend(nsAString& aBackend)
|
|||||||
aBackend.AssignLiteral("unknown");
|
aBackend.AssignLiteral("unknown");
|
||||||
}
|
}
|
||||||
|
|
||||||
void GetPreferredChannelLayout(nsAString& aLayout)
|
|
||||||
{
|
|
||||||
const char* layout = InitPreferredChannelLayout() ?
|
|
||||||
kLayoutInfos[sPreferredChannelLayout].name : "unknown";
|
|
||||||
aLayout.AssignASCII(layout);
|
|
||||||
}
|
|
||||||
|
|
||||||
uint16_t ConvertCubebType(cubeb_device_type aType)
|
|
||||||
{
|
|
||||||
uint16_t map[] = {
|
|
||||||
nsIAudioDeviceInfo::TYPE_UNKNOWN, // CUBEB_DEVICE_TYPE_UNKNOWN
|
|
||||||
nsIAudioDeviceInfo::TYPE_INPUT, // CUBEB_DEVICE_TYPE_INPUT,
|
|
||||||
nsIAudioDeviceInfo::TYPE_OUTPUT // CUBEB_DEVICE_TYPE_OUTPUT
|
|
||||||
};
|
|
||||||
return map[aType];
|
|
||||||
}
|
|
||||||
|
|
||||||
uint16_t ConvertCubebState(cubeb_device_state aState)
|
|
||||||
{
|
|
||||||
uint16_t map[] = {
|
|
||||||
nsIAudioDeviceInfo::STATE_DISABLED, // CUBEB_DEVICE_STATE_DISABLED
|
|
||||||
nsIAudioDeviceInfo::STATE_UNPLUGGED, // CUBEB_DEVICE_STATE_UNPLUGGED
|
|
||||||
nsIAudioDeviceInfo::STATE_ENABLED // CUBEB_DEVICE_STATE_ENABLED
|
|
||||||
};
|
|
||||||
return map[aState];
|
|
||||||
}
|
|
||||||
|
|
||||||
uint16_t ConvertCubebPreferred(cubeb_device_pref aPreferred)
|
|
||||||
{
|
|
||||||
if (aPreferred == CUBEB_DEVICE_PREF_NONE) {
|
|
||||||
return nsIAudioDeviceInfo::PREF_NONE;
|
|
||||||
} else if (aPreferred == CUBEB_DEVICE_PREF_ALL) {
|
|
||||||
return nsIAudioDeviceInfo::PREF_ALL;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint16_t preferred = 0;
|
|
||||||
if (aPreferred & CUBEB_DEVICE_PREF_MULTIMEDIA) {
|
|
||||||
preferred |= nsIAudioDeviceInfo::PREF_MULTIMEDIA;
|
|
||||||
}
|
|
||||||
if (aPreferred & CUBEB_DEVICE_PREF_VOICE) {
|
|
||||||
preferred |= nsIAudioDeviceInfo::PREF_VOICE;
|
|
||||||
}
|
|
||||||
if (aPreferred & CUBEB_DEVICE_PREF_NOTIFICATION) {
|
|
||||||
preferred |= nsIAudioDeviceInfo::PREF_NOTIFICATION;
|
|
||||||
}
|
|
||||||
return preferred;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint16_t ConvertCubebFormat(cubeb_device_fmt aFormat)
|
|
||||||
{
|
|
||||||
uint16_t format = 0;
|
|
||||||
if (aFormat & CUBEB_DEVICE_FMT_S16LE) {
|
|
||||||
format |= nsIAudioDeviceInfo::FMT_S16LE;
|
|
||||||
}
|
|
||||||
if (aFormat & CUBEB_DEVICE_FMT_S16BE) {
|
|
||||||
format |= nsIAudioDeviceInfo::FMT_S16BE;
|
|
||||||
}
|
|
||||||
if (aFormat & CUBEB_DEVICE_FMT_F32LE) {
|
|
||||||
format |= nsIAudioDeviceInfo::FMT_F32LE;
|
|
||||||
}
|
|
||||||
if (aFormat & CUBEB_DEVICE_FMT_F32BE) {
|
|
||||||
format |= nsIAudioDeviceInfo::FMT_F32BE;
|
|
||||||
}
|
|
||||||
return format;
|
|
||||||
}
|
|
||||||
|
|
||||||
void GetDeviceCollection(nsTArray<RefPtr<AudioDeviceInfo>>& aDeviceInfos,
|
|
||||||
Side aSide)
|
|
||||||
{
|
|
||||||
cubeb* context = GetCubebContext();
|
|
||||||
if (context) {
|
|
||||||
cubeb_device_collection collection = { nullptr, 0 };
|
|
||||||
if (cubeb_enumerate_devices(context,
|
|
||||||
aSide == Input ? CUBEB_DEVICE_TYPE_INPUT :
|
|
||||||
CUBEB_DEVICE_TYPE_OUTPUT,
|
|
||||||
&collection) == CUBEB_OK) {
|
|
||||||
for (unsigned int i = 0; i < collection.count; ++i) {
|
|
||||||
auto device = collection.device[i];
|
|
||||||
RefPtr<AudioDeviceInfo> info =
|
|
||||||
new AudioDeviceInfo(NS_ConvertASCIItoUTF16(device.friendly_name),
|
|
||||||
NS_ConvertASCIItoUTF16(device.group_id),
|
|
||||||
NS_ConvertASCIItoUTF16(device.vendor_name),
|
|
||||||
ConvertCubebType(device.type),
|
|
||||||
ConvertCubebState(device.state),
|
|
||||||
ConvertCubebPreferred(device.preferred),
|
|
||||||
ConvertCubebFormat(device.format),
|
|
||||||
ConvertCubebFormat(device.default_format),
|
|
||||||
device.max_channels,
|
|
||||||
device.default_rate,
|
|
||||||
device.max_rate,
|
|
||||||
device.min_rate,
|
|
||||||
device.latency_hi,
|
|
||||||
device.latency_lo);
|
|
||||||
aDeviceInfos.AppendElement(info);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
cubeb_device_collection_destroy(context, &collection);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace CubebUtils
|
} // namespace CubebUtils
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
@ -8,7 +8,6 @@
|
|||||||
#define CubebUtils_h_
|
#define CubebUtils_h_
|
||||||
|
|
||||||
#include "cubeb/cubeb.h"
|
#include "cubeb/cubeb.h"
|
||||||
#include "mozilla/dom/AudioDeviceInfo.h"
|
|
||||||
#include "mozilla/dom/AudioChannelBinding.h"
|
#include "mozilla/dom/AudioChannelBinding.h"
|
||||||
#include "mozilla/Maybe.h"
|
#include "mozilla/Maybe.h"
|
||||||
|
|
||||||
@ -34,11 +33,6 @@ uint32_t PreferredSampleRate();
|
|||||||
// Get the bit mask of the connected audio device's preferred layout.
|
// Get the bit mask of the connected audio device's preferred layout.
|
||||||
uint32_t PreferredChannelMap(uint32_t aChannels);
|
uint32_t PreferredChannelMap(uint32_t aChannels);
|
||||||
|
|
||||||
enum Side {
|
|
||||||
Input,
|
|
||||||
Output
|
|
||||||
};
|
|
||||||
|
|
||||||
void PrefChanged(const char* aPref, void* aClosure);
|
void PrefChanged(const char* aPref, void* aClosure);
|
||||||
double GetVolumeScale();
|
double GetVolumeScale();
|
||||||
bool GetFirstStream();
|
bool GetFirstStream();
|
||||||
@ -54,9 +48,7 @@ cubeb_channel_layout ConvertChannelMapToCubebLayout(uint32_t aChannelMap);
|
|||||||
cubeb_stream_type ConvertChannelToCubebType(dom::AudioChannel aChannel);
|
cubeb_stream_type ConvertChannelToCubebType(dom::AudioChannel aChannel);
|
||||||
#endif
|
#endif
|
||||||
void GetCurrentBackend(nsAString& aBackend);
|
void GetCurrentBackend(nsAString& aBackend);
|
||||||
void GetPreferredChannelLayout(nsAString& aLayout);
|
|
||||||
void GetDeviceCollection(nsTArray<RefPtr<AudioDeviceInfo>>& aDeviceInfos,
|
|
||||||
Side aSide);
|
|
||||||
} // namespace CubebUtils
|
} // namespace CubebUtils
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user