Skip to content

Commit b7feb1c

Browse files
author
Eino-Ville Talvala
committed
Switch camera sounds to always use the system enforced audio stream.
Instead of picking between the music stream and the enforced audio stream, change the camera service to always play sounds through enforced system stream. Also update the currently-hidden CameraSound API to match. Bug: 5778365 Change-Id: I3cc64b1d1ff567dbac8020a665d5b19846197ff3
1 parent dacbf67 commit b7feb1c

File tree

3 files changed

+2
-19
lines changed

3 files changed

+2
-19
lines changed

core/java/android/hardware/CameraSound.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@ public void release() {
110110

111111
private static class CameraSoundPlayer implements Runnable {
112112
private int mSoundId;
113-
private int mAudioStreamType;
114113
private MediaPlayer mPlayer;
115114
private Thread mThread;
116115
private boolean mExit;
@@ -147,7 +146,7 @@ public void run() {
147146
}
148147
mPlayer = new MediaPlayer();
149148
try {
150-
mPlayer.setAudioStreamType(mAudioStreamType);
149+
mPlayer.setAudioStreamType(AudioManager.STREAM_SYSTEM_ENFORCED);
151150
mPlayer.setDataSource(soundFilePath);
152151
mPlayer.setLooping(false);
153152
mPlayer.prepare();
@@ -179,11 +178,6 @@ public void run() {
179178

180179
public CameraSoundPlayer(int soundId) {
181180
mSoundId = soundId;
182-
if (SystemProperties.get("ro.camera.sound.forced", "0").equals("0")) {
183-
mAudioStreamType = AudioManager.STREAM_MUSIC;
184-
} else {
185-
mAudioStreamType = AudioManager.STREAM_SYSTEM_ENFORCED;
186-
}
187181
}
188182

189183
public void play() {

services/camera/libcameraservice/CameraService.cpp

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -97,16 +97,6 @@ void CameraService::onFirstRef()
9797
setCameraFree(i);
9898
}
9999
}
100-
101-
// Read the system property to determine if we have to use the
102-
// AUDIO_STREAM_ENFORCED_AUDIBLE type.
103-
char value[PROPERTY_VALUE_MAX];
104-
property_get("ro.camera.sound.forced", value, "0");
105-
if (strcmp(value, "0") != 0) {
106-
mAudioStreamType = AUDIO_STREAM_ENFORCED_AUDIBLE;
107-
} else {
108-
mAudioStreamType = AUDIO_STREAM_MUSIC;
109-
}
110100
}
111101

112102
CameraService::~CameraService() {
@@ -295,7 +285,7 @@ void CameraService::setCameraFree(int cameraId) {
295285
MediaPlayer* CameraService::newMediaPlayer(const char *file) {
296286
MediaPlayer* mp = new MediaPlayer();
297287
if (mp->setDataSource(file, NULL) == NO_ERROR) {
298-
mp->setAudioStreamType(mAudioStreamType);
288+
mp->setAudioStreamType(AUDIO_STREAM_ENFORCED_AUDIBLE);
299289
mp->prepare();
300290
} else {
301291
LOGE("Failed to load CameraService sounds: %s", file);

services/camera/libcameraservice/CameraService.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ class CameraService :
7676
void setCameraFree(int cameraId);
7777

7878
// sounds
79-
audio_stream_type_t mAudioStreamType;
8079
MediaPlayer* newMediaPlayer(const char *file);
8180

8281
Mutex mSoundLock;

0 commit comments

Comments
 (0)