Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(31)

Side by Side Diff: media/base/android/java/src/org/chromium/media/AudioManagerAndroid.java

Issue 14049003: Set default sampling rate to 44100 and query the native output sampling rate. (Closed) Base URL: https://src.chromium.org/svn/trunk/src/
Patch Set: rebase Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.media; 5 package org.chromium.media;
6 6
7 import android.content.BroadcastReceiver; 7 import android.content.BroadcastReceiver;
8 import android.content.Context; 8 import android.content.Context;
9 import android.content.Intent; 9 import android.content.Intent;
10 import android.content.IntentFilter; 10 import android.content.IntentFilter;
11 import android.media.AudioManager; 11 import android.media.AudioManager;
12 import android.os.Build; 12 import android.os.Build;
13 import android.util.Log; 13 import android.util.Log;
14 14
15 import org.chromium.base.CalledByNative; 15 import org.chromium.base.CalledByNative;
16 import org.chromium.base.JNINamespace; 16 import org.chromium.base.JNINamespace;
17 17
18 @JNINamespace("media") 18 @JNINamespace("media")
19 class AudioManagerAndroid { 19 class AudioManagerAndroid {
20 private static final String TAG = AudioManagerAndroid.class.getSimpleName(); 20 private static final String TAG = AudioManagerAndroid.class.getSimpleName();
21 // Most of Google lead devices use 44.1K as the default sampling rate, 44.1K
22 // is also widely used on other android devices.
23 private static final int DEFAULT_SAMPLING_RATE = 44100;
21 24
22 private final AudioManager mAudioManager; 25 private final AudioManager mAudioManager;
23 private final Context mContext; 26 private final Context mContext;
24 27
25 private BroadcastReceiver mReceiver; 28 private BroadcastReceiver mReceiver;
26 private boolean mOriginalSpeakerStatus; 29 private boolean mOriginalSpeakerStatus;
27 30
28 @CalledByNative 31 @CalledByNative
29 public void setMode(int mode) { 32 public void setMode(int mode) {
30 try { 33 try {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 mContext.registerReceiver(mReceiver, filter); 74 mContext.registerReceiver(mReceiver, filter);
72 } 75 }
73 76
74 @CalledByNative 77 @CalledByNative
75 public void unregisterHeadsetReceiver() { 78 public void unregisterHeadsetReceiver() {
76 mContext.unregisterReceiver(mReceiver); 79 mContext.unregisterReceiver(mReceiver);
77 mReceiver = null; 80 mReceiver = null;
78 mAudioManager.setSpeakerphoneOn(mOriginalSpeakerStatus); 81 mAudioManager.setSpeakerphoneOn(mOriginalSpeakerStatus);
79 } 82 }
80 83
84 @CalledByNative
85 public int getNativeOutputSampleRate() {
86 if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.J ELLY_BEAN_MR1) {
87 String sampleRateString = mAudioManager.getProperty(
qinmin 2013/05/16 01:31:23 nit: No need for 2 if statement: String sampleRat
88 AudioManager.PROPERTY_OUTPUT_SAMPLE_RATE);
89 return (sampleRateString == null ?
90 DEFAULT_SAMPLING_RATE : Integer.parseInt(sampleRateString));
91 } else {
92 return DEFAULT_SAMPLING_RATE;
93 }
94 }
95
81 private void logDeviceInfo() { 96 private void logDeviceInfo() {
82 Log.i(TAG, "Manufacturer:" + Build.MANUFACTURER + 97 Log.i(TAG, "Manufacturer:" + Build.MANUFACTURER +
83 " Board: " + Build.BOARD + " Device: " + Build.DEVICE + 98 " Board: " + Build.BOARD + " Device: " + Build.DEVICE +
84 " Model: " + Build.MODEL + " PRODUCT: " + Build.PRODUCT); 99 " Model: " + Build.MODEL + " PRODUCT: " + Build.PRODUCT);
85 } 100 }
86 } 101 }
OLDNEW
« media/audio/android/audio_manager_android.cc ('K') | « media/audio/android/audio_manager_android.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698