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

Commit 8eb9881d authored by Android (Google) Code Review's avatar Android (Google) Code Review
Browse files

Merge change 7735

* changes:
  Fix issue 1795088       Improve audio routing code
parents 8dc0c9b4 a553c25b
Loading
Loading
Loading
Loading
+423 −10
Original line number Diff line number Diff line
@@ -73186,7 +73186,7 @@
 value="1"
 static="true"
 final="true"
 deprecated="not deprecated"
 deprecated="deprecated"
 visibility="public"
>
</field>
@@ -73197,7 +73197,7 @@
 value="0"
 static="true"
 final="true"
 deprecated="not deprecated"
 deprecated="deprecated"
 visibility="public"
>
</field>
@@ -73208,7 +73208,7 @@
 value="2"
 static="true"
 final="true"
 deprecated="not deprecated"
 deprecated="deprecated"
 visibility="public"
>
</field>
@@ -73219,6 +73219,358 @@
 value="3"
 static="true"
 final="true"
 deprecated="deprecated"
 visibility="public"
>
</field>
<field name="CHANNEL_INVALID"
 type="int"
 transient="false"
 volatile="false"
 value="-1"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="CHANNEL_IN_BACK"
 type="int"
 transient="false"
 volatile="false"
 value="524288"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="CHANNEL_IN_BACK_PROCESSED"
 type="int"
 transient="false"
 volatile="false"
 value="8388608"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="CHANNEL_IN_DEFAULT"
 type="int"
 transient="false"
 volatile="false"
 value="0"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="CHANNEL_IN_FRONT"
 type="int"
 transient="false"
 volatile="false"
 value="262144"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="CHANNEL_IN_FRONT_PROCESSED"
 type="int"
 transient="false"
 volatile="false"
 value="4194304"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="CHANNEL_IN_LEFT"
 type="int"
 transient="false"
 volatile="false"
 value="65536"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="CHANNEL_IN_LEFT_PROCESSED"
 type="int"
 transient="false"
 volatile="false"
 value="1048576"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="CHANNEL_IN_MONO"
 type="int"
 transient="false"
 volatile="false"
 value="262144"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="CHANNEL_IN_PRESSURE"
 type="int"
 transient="false"
 volatile="false"
 value="16777216"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="CHANNEL_IN_RIGHT"
 type="int"
 transient="false"
 volatile="false"
 value="131072"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="CHANNEL_IN_RIGHT_PROCESSED"
 type="int"
 transient="false"
 volatile="false"
 value="2097152"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="CHANNEL_IN_STEREO"
 type="int"
 transient="false"
 volatile="false"
 value="196608"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="CHANNEL_IN_X_AXIS"
 type="int"
 transient="false"
 volatile="false"
 value="33554432"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="CHANNEL_IN_Y_AXIS"
 type="int"
 transient="false"
 volatile="false"
 value="67108864"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="CHANNEL_IN_Z_AXIS"
 type="int"
 transient="false"
 volatile="false"
 value="134217728"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="CHANNEL_OUT_5POINT1"
 type="int"
 transient="false"
 volatile="false"
 value="63"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="CHANNEL_OUT_7POINT1"
 type="int"
 transient="false"
 volatile="false"
 value="255"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="CHANNEL_OUT_BACK_CENTER"
 type="int"
 transient="false"
 volatile="false"
 value="256"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="CHANNEL_OUT_BACK_LEFT"
 type="int"
 transient="false"
 volatile="false"
 value="16"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="CHANNEL_OUT_BACK_RIGHT"
 type="int"
 transient="false"
 volatile="false"
 value="32"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="CHANNEL_OUT_DEFAULT"
 type="int"
 transient="false"
 volatile="false"
 value="0"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="CHANNEL_OUT_FRONT_CENTER"
 type="int"
 transient="false"
 volatile="false"
 value="4"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="CHANNEL_OUT_FRONT_LEFT"
 type="int"
 transient="false"
 volatile="false"
 value="1"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="CHANNEL_OUT_FRONT_LEFT_OF_CENTER"
 type="int"
 transient="false"
 volatile="false"
 value="64"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="CHANNEL_OUT_FRONT_RIGHT"
 type="int"
 transient="false"
 volatile="false"
 value="2"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="CHANNEL_OUT_FRONT_RIGHT_OF_CENTER"
 type="int"
 transient="false"
 volatile="false"
 value="128"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="CHANNEL_OUT_LOW_FREQUENCY"
 type="int"
 transient="false"
 volatile="false"
 value="8"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="CHANNEL_OUT_MONO"
 type="int"
 transient="false"
 volatile="false"
 value="1"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="CHANNEL_OUT_QUAD"
 type="int"
 transient="false"
 volatile="false"
 value="51"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="CHANNEL_OUT_STEREO"
 type="int"
 transient="false"
 volatile="false"
 value="3"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="CHANNEL_OUT_SURROUND"
 type="int"
 transient="false"
 volatile="false"
 value="263"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
@@ -73336,6 +73688,19 @@
 visibility="public"
>
</method>
<method name="getParameters"
 return="java.lang.String"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="keys" type="java.lang.String">
</parameter>
</method>
<method name="getRingerMode"
 return="int"
 abstract="false"
@@ -73454,6 +73819,17 @@
 visibility="public"
>
</method>
<method name="isWiredHeadsetOn"
 return="boolean"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
</method>
<method name="loadSoundEffects"
 return="void"
 abstract="false"
@@ -73500,7 +73876,7 @@
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 deprecated="deprecated"
 visibility="public"
>
<parameter name="on" type="boolean">
@@ -73545,6 +73921,19 @@
<parameter name="mode" type="int">
</parameter>
</method>
<method name="setParameters"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="keyValuePairs" type="java.lang.String">
</parameter>
</method>
<method name="setRingerMode"
 return="void"
 abstract="false"
@@ -73650,6 +74039,19 @@
<parameter name="vibrateSetting" type="int">
</parameter>
</method>
<method name="setWiredHeadsetOn"
 return="void"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="deprecated"
 visibility="public"
>
<parameter name="on" type="boolean">
</parameter>
</method>
<method name="shouldVibrate"
 return="boolean"
 abstract="false"
@@ -74022,7 +74424,7 @@
 value="-1"
 static="true"
 final="true"
 deprecated="not deprecated"
 deprecated="deprecated"
 visibility="public"
>
</field>
@@ -74044,7 +74446,7 @@
 value="16"
 static="true"
 final="true"
 deprecated="not deprecated"
 deprecated="deprecated"
 visibility="public"
>
</field>
@@ -74055,7 +74457,7 @@
 value="4"
 static="true"
 final="true"
 deprecated="not deprecated"
 deprecated="deprecated"
 visibility="public"
>
</field>
@@ -74066,7 +74468,7 @@
 value="1"
 static="true"
 final="true"
 deprecated="not deprecated"
 deprecated="deprecated"
 visibility="public"
>
</field>
@@ -74077,7 +74479,7 @@
 value="8"
 static="true"
 final="true"
 deprecated="not deprecated"
 deprecated="deprecated"
 visibility="public"
>
</field>
@@ -74088,7 +74490,7 @@
 value="2"
 static="true"
 final="true"
 deprecated="not deprecated"
 deprecated="deprecated"
 visibility="public"
>
</field>
@@ -74103,6 +74505,17 @@
 visibility="public"
>
</field>
<field name="STREAM_DTMF"
 type="int"
 transient="false"
 volatile="false"
 value="8"
 static="true"
 final="true"
 deprecated="not deprecated"
 visibility="public"
>
</field>
<field name="STREAM_MUSIC"
 type="int"
 transient="false"
+1 −8
Original line number Diff line number Diff line
@@ -33,7 +33,6 @@
#include "CameraService.h"

#include <cutils/atomic.h>
#include <cutils/properties.h>

namespace android {

@@ -199,13 +198,7 @@ static sp<MediaPlayer> newMediaPlayer(const char *file)
{
    sp<MediaPlayer> mp = new MediaPlayer();
    if (mp->setDataSource(file) == NO_ERROR) {
        char value[PROPERTY_VALUE_MAX];
        property_get("ro.camera.sound.forced", value, "0");
        if (atoi(value)) {
        mp->setAudioStreamType(AudioSystem::ENFORCED_AUDIBLE);
        } else {
            mp->setAudioStreamType(AudioSystem::SYSTEM);            
        }
        mp->prepare();
    } else {
        mp.clear();
+1 −0
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ static struct {
    { AID_MEDIA, "media.audio_flinger" },
    { AID_MEDIA, "media.player" },
    { AID_MEDIA, "media.camera" },
    { AID_MEDIA, "media.audio_policy" },
    { AID_RADIO, "radio.phone" },
    { AID_RADIO, "radio.sms" },
    { AID_RADIO, "radio.phonesubinfo" },
+4 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
#include <SurfaceFlinger.h>
#include <AudioFlinger.h>
#include <CameraService.h>
#include <AudioPolicyService.h>
#include <MediaPlayerService.h>

#include <android_runtime/AndroidRuntime.h>
@@ -80,6 +81,9 @@ extern "C" status_t system_init()

        // Start the camera service
        CameraService::instantiate();

        // Start the audio policy service
        AudioPolicyService::instantiate();
    }

    // And now start the Android runtime.  We have to do this bit
+4 −11
Original line number Diff line number Diff line
@@ -54,7 +54,6 @@ public class BluetoothA2dpService extends IBluetoothA2dp.Stub {
    private static final String BLUETOOTH_ADMIN_PERM = android.Manifest.permission.BLUETOOTH_ADMIN;
    private static final String BLUETOOTH_PERM = android.Manifest.permission.BLUETOOTH;

    private static final String A2DP_SINK_ADDRESS = "a2dp_sink_address";
    private static final String BLUETOOTH_ENABLED = "bluetooth_enabled";

    private static final int MESSAGE_CONNECT_TO = 1;
@@ -238,7 +237,7 @@ public class BluetoothA2dpService extends IBluetoothA2dp.Stub {
                    }
            }
        }
        mAudioManager.setParameter(BLUETOOTH_ENABLED, "true");
        mAudioManager.setParameters(BLUETOOTH_ENABLED+"=true");
    }

    private synchronized void onBluetoothDisable() {
@@ -262,8 +261,8 @@ public class BluetoothA2dpService extends IBluetoothA2dp.Stub {
            }
            mAudioDevices.clear();
        }
        mAudioManager.setBluetoothA2dpOn(false);
        mAudioManager.setParameter(BLUETOOTH_ENABLED, "false");

        mAudioManager.setParameters(BLUETOOTH_ENABLED+"=false");
    }

    public synchronized int connectSink(String address) {
@@ -403,8 +402,7 @@ public class BluetoothA2dpService extends IBluetoothA2dp.Stub {
                   Intent intent = new Intent(AudioManager.ACTION_AUDIO_BECOMING_NOISY);
                   mContext.sendBroadcast(intent);
                }
                if (--mSinkCount == 0)
                    mAudioManager.setBluetoothA2dpOn(false);
                mSinkCount--;
            } else if (state == BluetoothA2dp.STATE_CONNECTED) {
                mSinkCount ++;
            }
@@ -417,11 +415,6 @@ public class BluetoothA2dpService extends IBluetoothA2dp.Stub {
            mContext.sendBroadcast(intent, BLUETOOTH_PERM);

            if (DBG) log("A2DP state : address: " + address + " State:" + prevState + "->" + state);

            if (state == BluetoothA2dp.STATE_CONNECTED) {
                mAudioManager.setParameter(A2DP_SINK_ADDRESS, address);
                mAudioManager.setBluetoothA2dpOn(true);
            }
        }
    }

Loading