Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 90f4bc2a authored by Chih-Chung Chang's avatar Chih-Chung Chang
Browse files

Allow shutter/recording sound to be adjusted unless it's forced.

Change-Id: I7080d5f50a87f92c8e9395d4cf8f927a6760fa70
parent 1b8ba61c
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -278,9 +278,20 @@ void CameraService::setCameraFree(int cameraId) {
// media players.

static MediaPlayer* newMediaPlayer(const char *file) {
    // Read the system property to determine if we have need to use the
    // AUDIO_STREAM_ENFORCED_AUDIBLE type.
    char value[PROPERTY_VALUE_MAX];
    property_get("ro.camera.sound.forced", value, "0");
    int audioStreamType;
    if (strcmp(value, "0") != 0) {
        audioStreamType = AUDIO_STREAM_ENFORCED_AUDIBLE;
    } else {
        audioStreamType = AUDIO_STREAM_MUSIC;
    }

    MediaPlayer* mp = new MediaPlayer();
    if (mp->setDataSource(file, NULL) == NO_ERROR) {
        mp->setAudioStreamType(AUDIO_STREAM_ENFORCED_AUDIBLE);
        mp->setAudioStreamType(audioStreamType);
        mp->prepare();
    } else {
        LOGE("Failed to load CameraService sounds: %s", file);