OSDN Git Service

Fix A2DP compilation, remove FM routing, use snd_pcm_hw_params_set_buffer_size_near
authorSean McNeil <sean.mcneil@windriver.com>
Wed, 23 Jun 2010 07:22:01 +0000 (14:22 +0700)
committerSean McNeil <sean.mcneil@windriver.com>
Wed, 23 Jun 2010 07:22:01 +0000 (14:22 +0700)
ALSAMixer.cpp
Android.mk
AudioPolicyManagerALSA.cpp
alsa_default.cpp

index 883edf1..8bae00a 100644 (file)
@@ -74,7 +74,6 @@ mixerProp[][SND_PCM_STREAM_LAST+1] = {
     ALSA_PROP(AudioSystem::DEVICE_OUT_WIRED_HEADSET, "headset", "Headphone", "Capture"),
     ALSA_PROP(AudioSystem::DEVICE_OUT_BLUETOOTH_SCO, "bluetooth.sco", "Bluetooth", "Bluetooth Capture"),
     ALSA_PROP(AudioSystem::DEVICE_OUT_BLUETOOTH_A2DP, "bluetooth.a2dp", "Bluetooth A2DP", "Bluetooth A2DP Capture"),
-    ALSA_PROP(AudioSystem::DEVICE_OUT_FM_HEADPHONE, "fm", "FM", ""),
     ALSA_PROP(static_cast<AudioSystem::audio_devices>(0), "", NULL, NULL)
 };
 
index f9b1781..099cdda 100644 (file)
@@ -46,6 +46,7 @@ endif
   include $(CLEAR_VARS)
 
   LOCAL_CFLAGS := -D_POSIX_SOURCE
+
 ifeq ($(BOARD_HAVE_BLUETOOTH),true)
   LOCAL_CFLAGS += -DWITH_A2DP
 endif
index b7808c9..8f93503 100644 (file)
@@ -214,6 +214,7 @@ status_t AudioPolicyManagerALSA::setDeviceConnectionState(AudioSystem::audio_dev
                             mOutputs.valueFor(mHardwareOutput)->isUsedByStrategy(STRATEGY_DTMF)) {
                          newDevice = device;
                     }
+#ifdef SUPPORT_DEVICE_OUT_TTY
                 } else if (device == AudioSystem::DEVICE_OUT_TTY) {
                     LOGV("setDeviceConnectionState() tty device");
                     // if connecting a wired headset, we check the following by order of priority
@@ -225,22 +226,7 @@ status_t AudioPolicyManagerALSA::setDeviceConnectionState(AudioSystem::audio_dev
                         mOutputs.valueFor(mHardwareOutput)->isUsedByStrategy(STRATEGY_PHONE))) {
                         newDevice = device;
                     }
-                } else if (device == AudioSystem::DEVICE_OUT_FM_SPEAKER ||
-                           device == AudioSystem::DEVICE_OUT_FM_HEADPHONE) {
-                    LOGV("setDeviceConnectionState() no mic headphone device");
-                    // if connecting a wired headset, we check the following by order of priority
-                    // to request a routing change if necessary:
-                    // 1: the strategy sonification is active on the hardware output:
-                    //      use device for strategy sonification
-                    // 2: the strategy media is active on the hardware output:
-                    //      use device for strategy media
-                    if ((getDeviceForStrategy(STRATEGY_SONIFICATION) & device) &&
-                               mOutputs.valueFor(mHardwareOutput)->isUsedByStrategy(STRATEGY_SONIFICATION)){
-                        newDevice = getDeviceForStrategy(STRATEGY_SONIFICATION);
-                    } else if ((getDeviceForStrategy(STRATEGY_MEDIA) == device) &&
-                               mOutputs.valueFor(mHardwareOutput)->isUsedByStrategy(STRATEGY_MEDIA)){
-                        newDevice = device;
-                    }
+#endif // SUPPORT_DEVICE_OUT_TTY
                 }
 
                 // request routing change if necessary
@@ -390,6 +376,7 @@ status_t AudioPolicyManagerALSA::setDeviceConnectionState(AudioSystem::audio_dev
                                mOutputs.valueFor(mHardwareOutput)->isUsedByStrategy(STRATEGY_DTMF)){
                         newDevice = getDeviceForStrategy(STRATEGY_DTMF);
                     }
+#ifdef SUPPORT_DEVICE_OUT_TTY
                 } else if (device == AudioSystem::DEVICE_OUT_TTY) {
                     LOGV("setDeviceConnectionState() tty device");
                     if (wasUsedforPhone &&
@@ -397,18 +384,10 @@ status_t AudioPolicyManagerALSA::setDeviceConnectionState(AudioSystem::audio_dev
                          mOutputs.valueFor(mHardwareOutput)->isUsedByStrategy(STRATEGY_PHONE))) {
                         newDevice = getDeviceForStrategy(STRATEGY_PHONE);
                     }
-                } else if (device == AudioSystem::DEVICE_OUT_FM_SPEAKER ||
-                           device == AudioSystem::DEVICE_OUT_FM_HEADPHONE) {
-                    LOGV("setDeviceConnectionState() no mic headphone device");
-                    if (wasUsedForSonification &&
-                        mOutputs.valueFor(mHardwareOutput)->isUsedByStrategy(STRATEGY_SONIFICATION)){
-                        newDevice = getDeviceForStrategy(STRATEGY_SONIFICATION);
-                    } else if (wasUsedForMedia &&
-                               mOutputs.valueFor(mHardwareOutput)->isUsedByStrategy(STRATEGY_MEDIA)){
-                        newDevice = getDeviceForStrategy(STRATEGY_MEDIA);
-                    }
+#endif // SUPPORT_DEVICE_OUT_TTY
                 }
             }
+
             // request routing change if necessary
             setOutputDevice(mHardwareOutput, newDevice);
 
@@ -1345,8 +1324,10 @@ uint32_t AudioPolicyManagerALSA::getDeviceForStrategy(routing_strategy strategy)
             // FALL THROUGH
 
         default:    // FORCE_NONE
+#ifdef SUPPORT_DEVICE_OUT_TTY
             device = mAvailableOutputDevices & AudioSystem::DEVICE_OUT_TTY;
             if (device) break;
+#endif // SUPPORT_DEVICE_OUT_TTY
             device = mAvailableOutputDevices & AudioSystem::DEVICE_OUT_WIRED_HEADPHONE;
             if (device) break;
             device = mAvailableOutputDevices & AudioSystem::DEVICE_OUT_WIRED_HEADSET;
@@ -1362,7 +1343,7 @@ uint32_t AudioPolicyManagerALSA::getDeviceForStrategy(routing_strategy strategy)
                 device = mAvailableOutputDevices & AudioSystem::DEVICE_OUT_BLUETOOTH_SCO_CARKIT;
                 if (device) break;
             }
-            device = mAvailableOutputDevices & AudioSystem::DEVICE_OUT_FM_SPEAKER;
+            device = mAvailableOutputDevices;
             if (device) break;
             device = mAvailableOutputDevices & AudioSystem::DEVICE_OUT_SPEAKER;
             if (device == 0) {
@@ -1396,22 +1377,16 @@ uint32_t AudioPolicyManagerALSA::getDeviceForStrategy(routing_strategy strategy)
                 if (device2 == 0) {
                     device2 = mAvailableOutputDevices & AudioSystem::DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER;
                     if (device2 == 0) {
-                        device2 = mAvailableOutputDevices & AudioSystem::DEVICE_OUT_FM_HEADPHONE;
-                        if (device2 == 0) {
-                            device2 = mAvailableOutputDevices & AudioSystem::DEVICE_OUT_FM_SPEAKER;
-                            if (device2 == 0) {
-                                device2 = mAvailableOutputDevices & AudioSystem::DEVICE_OUT_WIRED_HEADPHONE;
-                                if (device2 == 0) {
-                                    device2 = mAvailableOutputDevices & AudioSystem::DEVICE_OUT_WIRED_HEADSET;
-                                    if (device2 == 0) {
-                                        device = mAvailableOutputDevices & AudioSystem::DEVICE_OUT_SPEAKER;
-                                        if (device == 0) {
-                                            LOGE("getDeviceForStrategy() speaker device not found");
-                                        }
-                                    }
-                                }
-                            }
-                        }
+                       device2 = mAvailableOutputDevices & AudioSystem::DEVICE_OUT_WIRED_HEADPHONE;
+                       if (device2 == 0) {
+                               device2 = mAvailableOutputDevices & AudioSystem::DEVICE_OUT_WIRED_HEADSET;
+                               if (device2 == 0) {
+                                       device = mAvailableOutputDevices & AudioSystem::DEVICE_OUT_SPEAKER;
+                                       if (device == 0) {
+                                               LOGE("getDeviceForStrategy() speaker device not found");
+                                       }
+                               }
+                       }
                     }
                 }
             }
index 1951498..d437f37 100644 (file)
@@ -138,7 +138,6 @@ static const device_suffix_t deviceSuffix[] = {
         {AudioSystem::DEVICE_OUT_BLUETOOTH_SCO,  "_Bluetooth"},
         {AudioSystem::DEVICE_OUT_WIRED_HEADSET,  "_Headset"},
         {AudioSystem::DEVICE_OUT_BLUETOOTH_A2DP, "_Bluetooth-A2DP"},
-        {AudioSystem::DEVICE_OUT_FM_HEADPHONE,   "_FM"},
 };
 
 static const int deviceSuffixLen = (sizeof(deviceSuffix)
@@ -278,8 +277,9 @@ status_t setHardwareParams(alsa_handle_t *handle)
 #endif
 
     // Make sure we have at least the size we originally wanted
-    err = snd_pcm_hw_params_set_buffer_size(handle->handle, hardwareParams,
-            bufferSize);
+    err = snd_pcm_hw_params_set_buffer_size_near(handle->handle, hardwareParams,
+            &bufferSize);
+
     if (err < 0) {
         LOGE("Unable to set buffer size to %d:  %s",
                 (int)bufferSize, snd_strerror(err));