mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 23:31:56 +00:00
Bug 1432779 - P4. Remove the concept of preferred layout. r=padenot,r=kamidphish
Channel layout is derived by the content being played. The concept of preferred layout is meaningless. Either we have a layout defined, or we don't. There's no in-between. So we remove it. MozReview-Commit-ID: CSCAInNmzMS
This commit is contained in:
parent
5a631a5822
commit
87fa7068d5
@ -2328,13 +2328,6 @@ nsDOMWindowUtils::GetCurrentMaxAudioChannels(uint32_t* aChannels)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMWindowUtils::GetCurrentPreferredChannelLayout(nsAString& aLayout)
|
||||
{
|
||||
CubebUtils::GetPreferredChannelLayout(aLayout);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMWindowUtils::GetCurrentPreferredSampleRate(uint32_t* aRate)
|
||||
{
|
||||
|
@ -1293,11 +1293,6 @@ interface nsIDOMWindowUtils : nsISupports {
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
|
@ -348,7 +348,7 @@ AudioStream::Init(uint32_t aNumChannels, uint32_t aChannelMap, uint32_t aRate)
|
||||
cubeb_stream_params params;
|
||||
params.rate = aRate;
|
||||
params.channels = mOutChannels;
|
||||
params.layout = CubebUtils::ConvertChannelMapToCubebLayout(aChannelMap);
|
||||
params.layout = CUBEB_LAYOUT_UNDEFINED;
|
||||
params.format = ToCubebFormat<AUDIO_OUTPUT_FORMAT>::value;
|
||||
params.prefs = CUBEB_STREAM_PREF_NONE;
|
||||
|
||||
|
@ -235,11 +235,6 @@ public:
|
||||
return CubebUtils::PreferredSampleRate();
|
||||
}
|
||||
|
||||
static uint32_t GetPreferredChannelMap(uint32_t aChannels)
|
||||
{
|
||||
return CubebUtils::PreferredChannelMap(aChannels);
|
||||
}
|
||||
|
||||
uint32_t GetOutChannels() { return mOutChannels; }
|
||||
|
||||
// Set playback rate as a multiple of the intrinsic playback rate. This is to
|
||||
|
@ -204,11 +204,6 @@ const layoutInfo kLayoutInfos[CUBEB_LAYOUT_MAX] = {
|
||||
// visible on the querying thread/CPU.
|
||||
uint32_t sPreferredSampleRate;
|
||||
|
||||
// We only support SMPTE layout in cubeb for now. If the value is
|
||||
// CUBEB_LAYOUT_UNDEFINED, then it implies that the preferred layout is
|
||||
// non-SMPTE format.
|
||||
cubeb_channel_layout sPreferredChannelLayout;
|
||||
|
||||
} // namespace
|
||||
|
||||
static const uint32_t CUBEB_NORMAL_LATENCY_MS = 100;
|
||||
@ -345,59 +340,6 @@ uint32_t PreferredSampleRate()
|
||||
return sPreferredSampleRate;
|
||||
}
|
||||
|
||||
bool InitPreferredChannelLayout()
|
||||
{
|
||||
{
|
||||
StaticMutexAutoLock lock(sMutex);
|
||||
if (sPreferredChannelLayout != 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
cubeb* context = GetCubebContext();
|
||||
if (!context) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Favor calling cubeb api with the mutex unlock, potential deadlock.
|
||||
cubeb_channel_layout layout;
|
||||
if (cubeb_get_preferred_channel_layout(context, &layout) != CUBEB_OK) {
|
||||
return false;
|
||||
}
|
||||
|
||||
StaticMutexAutoLock lock(sMutex);
|
||||
sPreferredChannelLayout = layout;
|
||||
return true;
|
||||
}
|
||||
|
||||
uint32_t PreferredChannelMap(uint32_t aChannels)
|
||||
{
|
||||
// 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
|
||||
if (!InitPreferredChannelLayout() ||
|
||||
kLayoutInfos[sPreferredChannelLayout].channels != aChannels) {
|
||||
AudioConfig::ChannelLayout smpteLayout(aChannels);
|
||||
return smpteLayout.Map();
|
||||
}
|
||||
|
||||
return kLayoutInfos[sPreferredChannelLayout].mask;
|
||||
}
|
||||
|
||||
cubeb_channel_layout GetPreferredChannelLayoutOrSMPTE(cubeb* context, uint32_t aChannels)
|
||||
{
|
||||
cubeb_channel_layout layout = CUBEB_LAYOUT_UNDEFINED;
|
||||
if (cubeb_get_preferred_channel_layout(context, &layout) != CUBEB_OK) {
|
||||
return layout; //undefined
|
||||
}
|
||||
|
||||
if (kLayoutInfos[layout].channels != aChannels) {
|
||||
AudioConfig::ChannelLayout smpteLayout(aChannels);
|
||||
return ConvertChannelMapToCubebLayout(smpteLayout.Map());
|
||||
}
|
||||
|
||||
return layout;
|
||||
}
|
||||
|
||||
void InitBrandName()
|
||||
{
|
||||
if (sBrandName) {
|
||||
@ -641,33 +583,6 @@ uint32_t MaxNumberOfChannels()
|
||||
return 0;
|
||||
}
|
||||
|
||||
cubeb_channel_layout ConvertChannelMapToCubebLayout(uint32_t aChannelMap)
|
||||
{
|
||||
switch(aChannelMap) {
|
||||
case MASK_MONO: return CUBEB_LAYOUT_MONO;
|
||||
case MASK_MONO_LFE: return CUBEB_LAYOUT_MONO_LFE;
|
||||
case MASK_STEREO: return CUBEB_LAYOUT_STEREO;
|
||||
case MASK_STEREO_LFE: return CUBEB_LAYOUT_STEREO_LFE;
|
||||
case MASK_3F: return CUBEB_LAYOUT_3F;
|
||||
case MASK_3F_LFE: return CUBEB_LAYOUT_3F_LFE;
|
||||
case MASK_2F1: return CUBEB_LAYOUT_2F1;
|
||||
case MASK_2F1_LFE: return CUBEB_LAYOUT_2F1_LFE;
|
||||
case MASK_3F1: return CUBEB_LAYOUT_3F1;
|
||||
case MASK_3F1_LFE: return CUBEB_LAYOUT_3F1_LFE;
|
||||
case MASK_2F2: return CUBEB_LAYOUT_2F2;
|
||||
case MASK_2F2_LFE: return CUBEB_LAYOUT_2F2_LFE;
|
||||
case MASK_QUAD: return CUBEB_LAYOUT_QUAD;
|
||||
case MASK_QUAD_LFE: return CUBEB_LAYOUT_QUAD_LFE;
|
||||
case MASK_3F2: return CUBEB_LAYOUT_3F2;
|
||||
case MASK_3F2_LFE: return CUBEB_LAYOUT_3F2_LFE;
|
||||
case MASK_3F3R_LFE: return CUBEB_LAYOUT_3F3R_LFE;
|
||||
case MASK_3F4_LFE: return CUBEB_LAYOUT_3F4_LFE;
|
||||
default:
|
||||
NS_ERROR("The channel map is unsupported");
|
||||
return CUBEB_LAYOUT_UNDEFINED;
|
||||
}
|
||||
}
|
||||
|
||||
void GetCurrentBackend(nsAString& aBackend)
|
||||
{
|
||||
cubeb* cubebContext = GetCubebContext();
|
||||
@ -681,13 +596,6 @@ void GetCurrentBackend(nsAString& aBackend)
|
||||
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[] = {
|
||||
|
@ -30,9 +30,6 @@ uint32_t MaxNumberOfChannels();
|
||||
// Get the sample rate the hardware/mixer runs at. Thread safe.
|
||||
uint32_t PreferredSampleRate();
|
||||
|
||||
// Get the bit mask of the connected audio device's preferred layout.
|
||||
uint32_t PreferredChannelMap(uint32_t aChannels);
|
||||
|
||||
enum Side {
|
||||
Input,
|
||||
Output
|
||||
@ -46,12 +43,9 @@ void ReportCubebBackendUsed();
|
||||
uint32_t GetCubebPlaybackLatencyInMilliseconds();
|
||||
uint32_t GetCubebMSGLatencyInFrames(cubeb_stream_params * params);
|
||||
bool CubebLatencyPrefSet();
|
||||
cubeb_channel_layout ConvertChannelMapToCubebLayout(uint32_t aChannelMap);
|
||||
void GetCurrentBackend(nsAString& aBackend);
|
||||
void GetPreferredChannelLayout(nsAString& aLayout);
|
||||
void GetDeviceCollection(nsTArray<RefPtr<AudioDeviceInfo>>& aDeviceInfos,
|
||||
Side aSide);
|
||||
cubeb_channel_layout GetPreferredChannelLayoutOrSMPTE(cubeb* context, uint32_t aChannels);
|
||||
|
||||
#ifdef MOZ_WIDGET_ANDROID
|
||||
uint32_t AndroidGetAudioOutputSampleRate();
|
||||
|
@ -630,7 +630,7 @@ AudioCallbackDriver::Init()
|
||||
mScratchBuffer = SpillBuffer<AudioDataValue, WEBAUDIO_BLOCK_SIZE * 2>(mOutputChannels);
|
||||
|
||||
output.channels = mOutputChannels;
|
||||
output.layout = CubebUtils::GetPreferredChannelLayoutOrSMPTE(cubebContext, mOutputChannels);
|
||||
output.layout = CUBEB_LAYOUT_UNDEFINED;
|
||||
output.prefs = CUBEB_STREAM_PREF_NONE;
|
||||
|
||||
uint32_t latency_frames = CubebUtils::GetCubebMSGLatencyInFrames(&output);
|
||||
|
@ -102,7 +102,6 @@ private:
|
||||
DECL_MEDIA_PREF("accessibility.monoaudio.enable", MonoAudio, bool, false);
|
||||
DECL_MEDIA_PREF("media.resampling.enabled", AudioSinkResampling, bool, false);
|
||||
#if defined(XP_WIN) || defined(XP_DARWIN) || defined(MOZ_PULSEAUDIO)
|
||||
// libcubeb backend implement .get_preferred_channel_layout
|
||||
DECL_MEDIA_PREF("media.forcestereo.enabled", AudioSinkForceStereo, bool, false);
|
||||
#else
|
||||
DECL_MEDIA_PREF("media.forcestereo.enabled", AudioSinkForceStereo, bool, true);
|
||||
|
@ -197,7 +197,7 @@ AudioSink::InitializeAudioStream(const PlaybackParams& aParams)
|
||||
// the coming audio data, so we use the predefined channel map instead.
|
||||
uint32_t channelMap = mConverter
|
||||
? mConverter->OutputConfig().Layout().Map()
|
||||
: AudioStream::GetPreferredChannelMap(mOutputChannels);
|
||||
: AudioConfig::ChannelLayout(mOutputChannels).Map();
|
||||
// The layout map used here is already processed by mConverter with
|
||||
// mOutputChannels into SMPTE format, so there is no need to worry if
|
||||
// MediaPrefs::MonoAudio() or MediaPrefs::AudioSinkForceStereo() is applied.
|
||||
|
@ -711,7 +711,6 @@ var snapshotFormatters = {
|
||||
// Basic information
|
||||
insertBasicInfo("audioBackend", data.currentAudioBackend);
|
||||
insertBasicInfo("maxAudioChannels", data.currentMaxAudioChannels);
|
||||
insertBasicInfo("channelLayout", data.currentPreferredChannelLayout);
|
||||
insertBasicInfo("sampleRate", data.currentPreferredSampleRate);
|
||||
|
||||
// Output devices information
|
||||
|
@ -586,7 +586,6 @@ var dataProviders = {
|
||||
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));
|
||||
|
@ -425,10 +425,6 @@ const SNAPSHOT_SCHEMA = {
|
||||
required: true,
|
||||
type: "number",
|
||||
},
|
||||
currentPreferredChannelLayout: {
|
||||
required: true,
|
||||
type: "string",
|
||||
},
|
||||
currentPreferredSampleRate: {
|
||||
required: true,
|
||||
type: "number",
|
||||
|
Loading…
Reference in New Issue
Block a user