summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve Kondik <shade@chemlab.org>2010-11-07 14:06:03 -0500
committerSteve Kondik <shade@chemlab.org>2010-11-07 15:28:59 -0500
commitb4869cfc4d52dd6d0e0659e988a9c11bddb69797 (patch)
tree7fdd589b27dd3dc70a938be401e3c1dab2047163
parentd5b54a8188278e14cd251dfcb34fafda8ae2c785 (diff)
downloadframeworks_base-b4869cfc4d52dd6d0e0659e988a9c11bddb69797.zip
frameworks_base-b4869cfc4d52dd6d0e0659e988a9c11bddb69797.tar.gz
frameworks_base-b4869cfc4d52dd6d0e0659e988a9c11bddb69797.tar.bz2
Revert "Revert "audio: Omit FM code when HAVE_FM_RADIO is not set""
Cleaned it up, and fixed a misplaced ifdef that broke the whole damn thing. This reverts commit 568f674b8ef1a83b7ba948b0e53e0dd86207d115. Change-Id: I99fde73b2cf283dde7e9bcb1e73cf86e553324d3
-rw-r--r--include/media/AudioSystem.h21
-rw-r--r--include/media/IAudioFlinger.h3
-rw-r--r--include/media/mediarecorder.h5
-rw-r--r--libs/audioflinger/A2dpAudioInterface.cpp2
-rw-r--r--libs/audioflinger/A2dpAudioInterface.h4
-rw-r--r--libs/audioflinger/Android.mk12
-rw-r--r--libs/audioflinger/AudioDumpInterface.h7
-rw-r--r--libs/audioflinger/AudioFlinger.cpp13
-rw-r--r--libs/audioflinger/AudioFlinger.h11
-rw-r--r--libs/audioflinger/AudioHardwareGeneric.cpp2
-rw-r--r--libs/audioflinger/AudioHardwareGeneric.h2
-rw-r--r--libs/audioflinger/AudioHardwareStub.cpp2
-rw-r--r--libs/audioflinger/AudioHardwareStub.h2
-rw-r--r--libs/audioflinger/AudioPolicyManagerBase.cpp20
-rw-r--r--libs/audioflinger/AudioPolicyService.cpp9
-rw-r--r--libs/audioflinger/AudioPolicyService.h10
-rw-r--r--media/libmedia/Android.mk4
-rw-r--r--media/libmedia/AudioSystem.cpp6
-rw-r--r--media/libmedia/IAudioFlinger.cpp4
19 files changed, 124 insertions, 15 deletions
diff --git a/include/media/AudioSystem.h b/include/media/AudioSystem.h
index 6816ed5..9249d24 100644
--- a/include/media/AudioSystem.h
+++ b/include/media/AudioSystem.h
@@ -45,7 +45,9 @@ public:
ENFORCED_AUDIBLE = 7, // Sounds that cannot be muted by user and must be routed to speaker
DTMF = 8,
TTS = 9,
+#ifdef HAVE_FM_RADIO
FM = 10,
+#endif
NUM_STREAM_TYPES
};
@@ -222,7 +224,9 @@ public:
size_t* buffSize);
static status_t setVoiceVolume(float volume);
+#ifdef HAVE_FM_RADIO
static status_t setFmVolume(float volume);
+#endif
// return the number of audio frames written by AudioFlinger to audio HAL and
// audio dsp to DAC since the output on which the specificed stream is playing
@@ -253,10 +257,16 @@ public:
DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES = 0x100,
DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER = 0x200,
DEVICE_OUT_AUX_DIGITAL = 0x400,
+#ifdef HAVE_FM_RADIO
DEVICE_OUT_FM = 0x800,
+#endif
DEVICE_OUT_DEFAULT = 0x8000,
DEVICE_OUT_ALL = (DEVICE_OUT_EARPIECE | DEVICE_OUT_SPEAKER | DEVICE_OUT_WIRED_HEADSET |
+#ifdef HAV_FM_RADIO
DEVICE_OUT_WIRED_HEADPHONE | DEVICE_OUT_FM | DEVICE_OUT_BLUETOOTH_SCO | DEVICE_OUT_BLUETOOTH_SCO_HEADSET |
+#else
+ DEVICE_OUT_WIRED_HEADPHONE | DEVICE_OUT_BLUETOOTH_SCO | DEVICE_OUT_BLUETOOTH_SCO_HEADSET |
+#endif
DEVICE_OUT_BLUETOOTH_SCO_CARKIT | DEVICE_OUT_BLUETOOTH_A2DP | DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES |
DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER | DEVICE_OUT_AUX_DIGITAL | DEVICE_OUT_DEFAULT),
DEVICE_OUT_ALL_A2DP = (DEVICE_OUT_BLUETOOTH_A2DP | DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES |
@@ -271,13 +281,20 @@ public:
DEVICE_IN_AUX_DIGITAL = 0x200000,
DEVICE_IN_VOICE_CALL = 0x400000,
DEVICE_IN_BACK_MIC = 0x800000,
+#ifdef HAVE_FM_RADIO
DEVICE_IN_FM_RX = 0x1000000,
DEVICE_IN_FM_RX_A2DP = 0x2000000,
+#endif
DEVICE_IN_DEFAULT = 0x80000000,
DEVICE_IN_ALL = (DEVICE_IN_COMMUNICATION | DEVICE_IN_AMBIENT | DEVICE_IN_BUILTIN_MIC |
DEVICE_IN_BLUETOOTH_SCO_HEADSET | DEVICE_IN_WIRED_HEADSET | DEVICE_IN_AUX_DIGITAL |
+#ifdef HAVE_FM_RADIO
DEVICE_IN_VOICE_CALL | DEVICE_IN_BACK_MIC | DEVICE_IN_FM_RX | DEVICE_IN_FM_RX_A2DP | DEVICE_IN_DEFAULT)
+#else
+ DEVICE_IN_VOICE_CALL | DEVICE_IN_BACK_MIC | DEVICE_IN_DEFAULT)
+#endif
+
};
// device connection states used for setDeviceConnectionState()
@@ -381,7 +398,9 @@ public:
static bool isOutputDevice(audio_devices device);
static bool isInputDevice(audio_devices device);
static bool isA2dpDevice(audio_devices device);
+#ifdef HAVE_FM_RADIO
static bool isFmDevice(audio_devices device);
+#endif
static bool isBluetoothScoDevice(audio_devices device);
static bool isLowVisibility(stream_type stream);
static bool isOutputChannel(uint32_t channel);
@@ -460,8 +479,10 @@ public:
static const char *keyFormat;
static const char *keyChannels;
static const char *keyFrameCount;
+#ifdef HAVE_FM_RADIO
static const char *keyFmOn;
static const char *keyFmOff;
+#endif
String8 toString();
diff --git a/include/media/IAudioFlinger.h b/include/media/IAudioFlinger.h
index 78d9a19..5ce3dcf 100644
--- a/include/media/IAudioFlinger.h
+++ b/include/media/IAudioFlinger.h
@@ -134,8 +134,9 @@ public:
virtual status_t getRenderPosition(uint32_t *halFrames, uint32_t *dspFrames, int output) = 0;
virtual unsigned int getInputFramesLost(int ioHandle) = 0;
-
+#ifdef HAVE_FM_RADIO
virtual status_t setFmVolume(float volume) = 0;
+#endif
};
diff --git a/include/media/mediarecorder.h b/include/media/mediarecorder.h
index 38502e1..176b934 100644
--- a/include/media/mediarecorder.h
+++ b/include/media/mediarecorder.h
@@ -44,10 +44,13 @@ enum audio_source {
AUDIO_SOURCE_VOICE_CALL = 4,
AUDIO_SOURCE_CAMCORDER = 5,
AUDIO_SOURCE_VOICE_RECOGNITION = 6,
+#ifdef HAVE_FM_RADIO
AUDIO_SOURCE_FM_RX = 7,
AUDIO_SOURCE_FM_RX_A2DP = 8,
AUDIO_SOURCE_MAX = AUDIO_SOURCE_FM_RX_A2DP,
-
+#else
+ AUDIO_SOURCE_MAX = AUDIO_SOURCE_VOICE_RECOGNITION,
+#endif
AUDIO_SOURCE_LIST_END // must be last - used to validate audio source type
};
diff --git a/libs/audioflinger/A2dpAudioInterface.cpp b/libs/audioflinger/A2dpAudioInterface.cpp
index e87927f..e55a94c 100644
--- a/libs/audioflinger/A2dpAudioInterface.cpp
+++ b/libs/audioflinger/A2dpAudioInterface.cpp
@@ -205,10 +205,12 @@ status_t A2dpAudioInterface::setVoiceVolume(float v)
return mHardwareInterface->setVoiceVolume(v);
}
+#ifdef HAVE_FM_RADIO
status_t A2dpAudioInterface::setFmVolume(float v)
{
return mHardwareInterface->setFmVolume(v);
}
+#endif
status_t A2dpAudioInterface::setMasterVolume(float v)
{
diff --git a/libs/audioflinger/A2dpAudioInterface.h b/libs/audioflinger/A2dpAudioInterface.h
index 7084ac9..65f4875 100644
--- a/libs/audioflinger/A2dpAudioInterface.h
+++ b/libs/audioflinger/A2dpAudioInterface.h
@@ -37,7 +37,6 @@ public:
virtual status_t initCheck();
virtual status_t setVoiceVolume(float volume);
- virtual status_t setFmVolume(float volume);
virtual status_t setMasterVolume(float volume);
virtual status_t setMode(int mode);
@@ -68,6 +67,9 @@ public:
status_t *status,
AudioSystem::audio_in_acoustics acoustics);
virtual void closeInputStream(AudioStreamIn* in);
+#ifdef HAVE_FM_RADIO
+ virtual status_t setFmVolume(float volume);
+#endif
// static AudioHardwareInterface* createA2dpInterface();
protected:
diff --git a/libs/audioflinger/Android.mk b/libs/audioflinger/Android.mk
index 653e3df..33384b7 100644
--- a/libs/audioflinger/Android.mk
+++ b/libs/audioflinger/Android.mk
@@ -32,6 +32,10 @@ ifeq ($(strip $(BOARD_USES_GENERIC_AUDIO)),true)
LOCAL_CFLAGS += -DGENERIC_AUDIO
endif
+ifeq ($(BOARD_HAVE_FM_RADIO),true)
+ LOCAL_CFLAGS += -DHAVE_FM_RADIO
+endif
+
LOCAL_MODULE:= libaudiointerface
ifeq ($(BOARD_HAVE_BLUETOOTH),true)
@@ -66,6 +70,10 @@ ifeq ($(BOARD_HAVE_BLUETOOTH),true)
LOCAL_CFLAGS += -DWITH_A2DP
endif
+ifeq ($(BOARD_HAVE_FM_RADIO),true)
+ LOCAL_CFLAGS += -DHAVE_FM_RADIO
+endif
+
ifeq ($(AUDIO_POLICY_TEST),true)
LOCAL_CFLAGS += -DAUDIO_POLICY_TEST
endif
@@ -118,6 +126,10 @@ ifeq ($(AUDIO_POLICY_TEST),true)
LOCAL_CFLAGS += -DAUDIO_POLICY_TEST
endif
+ifeq ($(BOARD_HAVE_FM_RADIO),true)
+ LOCAL_CFLAGS += -DHAVE_FM_RADIO
+endif
+
ifeq ($(TARGET_SIMULATOR),true)
ifeq ($(HOST_OS),linux)
LOCAL_LDLIBS += -lrt -lpthread
diff --git a/libs/audioflinger/AudioDumpInterface.h b/libs/audioflinger/AudioDumpInterface.h
index 3ed1503..8059177 100644
--- a/libs/audioflinger/AudioDumpInterface.h
+++ b/libs/audioflinger/AudioDumpInterface.h
@@ -131,8 +131,6 @@ public:
{return mFinalInterface->initCheck();}
virtual status_t setVoiceVolume(float volume)
{return mFinalInterface->setVoiceVolume(volume);}
- virtual status_t setFmVolume(float volume)
- {return mFinalInterface->setFmVolume(volume);}
virtual status_t setMasterVolume(float volume)
{return mFinalInterface->setMasterVolume(volume);}
@@ -150,7 +148,10 @@ public:
virtual void closeInputStream(AudioStreamIn* in);
virtual status_t dump(int fd, const Vector<String16>& args) { return mFinalInterface->dumpState(fd, args); }
-
+#ifdef HAVE_FM_RADIO
+ virtual status_t setFmVolume(float volume)
+ {return mFinalInterface->setFmVolume(volume);}
+#endif
String8 fileName() const { return mFileName; }
protected:
diff --git a/libs/audioflinger/AudioFlinger.cpp b/libs/audioflinger/AudioFlinger.cpp
index 04197c1..9aebfe4 100644
--- a/libs/audioflinger/AudioFlinger.cpp
+++ b/libs/audioflinger/AudioFlinger.cpp
@@ -120,10 +120,13 @@ static bool settingsAllowed() {
}
// ----------------------------------------------------------------------------
-
AudioFlinger::AudioFlinger()
: BnAudioFlinger(),
+#ifdef HAVE_FM_RADIO
mAudioHardware(0), mMasterVolume(1.0f), mMasterMute(false), mNextThreadId(0), mFmOn(false)
+#else
+ mAudioHardware(0), mMasterVolume(1.0f), mMasterMute(false), mNextThreadId(0)
+#endif
{
mHardwareStatus = AUDIO_HW_IDLE;
@@ -568,9 +571,11 @@ bool AudioFlinger::isStreamActive(int stream) const
return true;
}
}
+#ifdef HAVE_FM_RADIO
if (mFmOn && stream == AudioSystem::MUSIC) {
return true;
}
+#endif
return false;
}
@@ -605,7 +610,7 @@ status_t AudioFlinger::setParameters(int ioHandle, const String8& keyValuePairs)
}
}
#endif
-
+#ifdef HAVE_FM_RADIO
AudioParameter param = AudioParameter(keyValuePairs);
String8 key = String8(AudioParameter::keyRouting);
int device;
@@ -628,7 +633,7 @@ status_t AudioFlinger::setParameters(int ioHandle, const String8& keyValuePairs)
// Call hardware to switch FM on/off
mAudioHardware->setParameters(keyValuePairs);
}
-
+#endif
// ioHandle == 0 means the parameters are global to the audio hardware interface
if (ioHandle == 0) {
/* Set global DSP parameters, if any. */
@@ -738,6 +743,7 @@ status_t AudioFlinger::getRenderPosition(uint32_t *halFrames, uint32_t *dspFrame
return BAD_VALUE;
}
+#ifdef HAVE_FM_RADIO
status_t AudioFlinger::setFmVolume(float value)
{
// check calling permissions
@@ -752,6 +758,7 @@ status_t AudioFlinger::setFmVolume(float value)
return ret;
}
+#endif
void AudioFlinger::registerClient(const sp<IAudioFlingerClient>& client)
{
diff --git a/libs/audioflinger/AudioFlinger.h b/libs/audioflinger/AudioFlinger.h
index 6fc465b..cbbcc61 100644
--- a/libs/audioflinger/AudioFlinger.h
+++ b/libs/audioflinger/AudioFlinger.h
@@ -144,8 +144,10 @@ public:
virtual status_t setVoiceVolume(float volume);
virtual status_t getRenderPosition(uint32_t *halFrames, uint32_t *dspFrames, int output);
-
+
+#ifdef HAVE_FM_RADIO
virtual status_t setFmVolume(float volume);
+#endif
// IBinder::DeathRecipient
virtual void binderDied(const wp<IBinder>& who);
@@ -167,7 +169,9 @@ public:
AUDIO_HW_SET_MIC_MUTE,
AUDIO_SET_VOICE_VOLUME,
AUDIO_SET_PARAMETER,
+#ifdef HAVE_FM_RADIO
AUDIO_SET_FM_VOLUME
+#endif
};
// record interface
@@ -803,13 +807,14 @@ private:
PlaybackThread::stream_type_t mStreamTypes[AudioSystem::NUM_STREAM_TYPES];
float mMasterVolume;
bool mMasterMute;
- bool mFmOn;
DefaultKeyedVector< int, sp<RecordThread> > mRecordThreads;
SortedVector< sp<IBinder> > mNotificationClients;
int mNextThreadId;
-
+#ifdef HAVE_FM_RADIO
+ bool mFmOn;
+#endif
AudioDSP mDsp;
};
diff --git a/libs/audioflinger/AudioHardwareGeneric.cpp b/libs/audioflinger/AudioHardwareGeneric.cpp
index 446994d..64d2bc5 100644
--- a/libs/audioflinger/AudioHardwareGeneric.cpp
+++ b/libs/audioflinger/AudioHardwareGeneric.cpp
@@ -142,11 +142,13 @@ status_t AudioHardwareGeneric::setVoiceVolume(float v)
return NO_ERROR;
}
+#ifdef HAVE_FM_RADIO
status_t AudioHardwareGeneric::setFmVolume(float v)
{
// Implement: set fm volume
return NO_ERROR;
}
+#endif
status_t AudioHardwareGeneric::setMasterVolume(float v)
{
diff --git a/libs/audioflinger/AudioHardwareGeneric.h b/libs/audioflinger/AudioHardwareGeneric.h
index ef288b0..8b3e123 100644
--- a/libs/audioflinger/AudioHardwareGeneric.h
+++ b/libs/audioflinger/AudioHardwareGeneric.h
@@ -105,7 +105,9 @@ public:
virtual ~AudioHardwareGeneric();
virtual status_t initCheck();
virtual status_t setVoiceVolume(float volume);
+#ifdef HAVE_FM_RADIO
virtual status_t setFmVolume(float volume);
+#endif
virtual status_t setMasterVolume(float volume);
// mic mute
diff --git a/libs/audioflinger/AudioHardwareStub.cpp b/libs/audioflinger/AudioHardwareStub.cpp
index 0bcef00..9460259 100644
--- a/libs/audioflinger/AudioHardwareStub.cpp
+++ b/libs/audioflinger/AudioHardwareStub.cpp
@@ -91,10 +91,12 @@ status_t AudioHardwareStub::setVoiceVolume(float volume)
return NO_ERROR;
}
+#ifdef HAVE_FM_RADIO
status_t AudioHardwareStub::setFmVolume(float volume)
{
return NO_ERROR;
}
+#endif
status_t AudioHardwareStub::setMasterVolume(float volume)
{
diff --git a/libs/audioflinger/AudioHardwareStub.h b/libs/audioflinger/AudioHardwareStub.h
index 6b947d5..8b2503c 100644
--- a/libs/audioflinger/AudioHardwareStub.h
+++ b/libs/audioflinger/AudioHardwareStub.h
@@ -67,7 +67,9 @@ public:
virtual ~AudioHardwareStub();
virtual status_t initCheck();
virtual status_t setVoiceVolume(float volume);
+#ifdef HAVE_FM_RADIO
virtual status_t setFmVolume(float volume);
+#endif
virtual status_t setMasterVolume(float volume);
// mic mute
diff --git a/libs/audioflinger/AudioPolicyManagerBase.cpp b/libs/audioflinger/AudioPolicyManagerBase.cpp
index b943546..cf9ccf6 100644
--- a/libs/audioflinger/AudioPolicyManagerBase.cpp
+++ b/libs/audioflinger/AudioPolicyManagerBase.cpp
@@ -91,6 +91,7 @@ status_t AudioPolicyManagerBase::setDeviceConnectionState(AudioSystem::audio_dev
#endif
}
}
+#ifdef HAVE_FM_RADIO
if (AudioSystem::isFmDevice(device)) {
AudioOutputDescriptor *hwOutputDesc = mOutputs.valueFor(mHardwareOutput);
hwOutputDesc->mRefCount[AudioSystem::FM] = 1;
@@ -98,6 +99,7 @@ status_t AudioPolicyManagerBase::setDeviceConnectionState(AudioSystem::audio_dev
param.addInt(String8(AudioParameter::keyFmOn), mAvailableOutputDevices);
mpClientInterface->setParameters(mHardwareOutput, param.toString());
}
+#endif
break;
// handle output device disconnection
case AudioSystem::DEVICE_STATE_UNAVAILABLE: {
@@ -131,6 +133,7 @@ status_t AudioPolicyManagerBase::setDeviceConnectionState(AudioSystem::audio_dev
#endif
}
}
+#ifdef HAVE_FM_RADIO
if (AudioSystem::isFmDevice(device)) {
AudioOutputDescriptor *hwOutputDesc = mOutputs.valueFor(mHardwareOutput);
hwOutputDesc->mRefCount[AudioSystem::FM] = 0;
@@ -138,6 +141,7 @@ status_t AudioPolicyManagerBase::setDeviceConnectionState(AudioSystem::audio_dev
param.addInt(String8(AudioParameter::keyFmOff), mAvailableOutputDevices);
mpClientInterface->setParameters(mHardwareOutput, param.toString());
}
+#endif
} break;
default:
@@ -371,8 +375,12 @@ void AudioPolicyManagerBase::setForceUse(AudioSystem::force_use usage, AudioSyst
break;
case AudioSystem::FOR_MEDIA:
if (config != AudioSystem::FORCE_HEADPHONES && config != AudioSystem::FORCE_BT_A2DP &&
+#ifdef HAVE_FM_RADIO
config != AudioSystem::FORCE_WIRED_ACCESSORY && config != AudioSystem::FORCE_SPEAKER &&
config != AudioSystem::FORCE_NONE) {
+#else
+ config != AudioSystem::FORCE_WIRED_ACCESSORY && config != AudioSystem::FORCE_NONE) {
+#endif
LOGW("setForceUse() invalid config %d for FOR_MEDIA", config);
return;
}
@@ -1434,7 +1442,9 @@ AudioPolicyManagerBase::routing_strategy AudioPolicyManagerBase::getStrategy(Aud
// while key clicks are played produces a poor result
case AudioSystem::TTS:
case AudioSystem::MUSIC:
+#ifdef HAVE_FM_RADIO
case AudioSystem::FM:
+#endif
return STRATEGY_MEDIA;
}
}
@@ -1534,6 +1544,7 @@ uint32_t AudioPolicyManagerBase::getDeviceForStrategy(routing_strategy strategy,
// FALL THROUGH
case STRATEGY_MEDIA: {
+#ifdef HAVE_FM_RADIO
uint32_t device2 = 0;
if (mForceUse[AudioSystem::FOR_MEDIA] == AudioSystem::FORCE_SPEAKER) {
device2 = mAvailableOutputDevices & AudioSystem::DEVICE_OUT_SPEAKER;
@@ -1541,6 +1552,9 @@ uint32_t AudioPolicyManagerBase::getDeviceForStrategy(routing_strategy strategy,
if (device2 == 0) {
device2 = mAvailableOutputDevices & AudioSystem::DEVICE_OUT_AUX_DIGITAL;
}
+#else
+ uint32_t device2 = mAvailableOutputDevices & AudioSystem::DEVICE_OUT_AUX_DIGITAL;
+#endif
if (device2 == 0) {
device2 = mAvailableOutputDevices & AudioSystem::DEVICE_OUT_WIRED_HEADPHONE;
}
@@ -1813,7 +1827,11 @@ status_t AudioPolicyManagerBase::checkAndSetVolume(int stream, int index, audio_
float volume = computeVolume(stream, index, output, device);
// do not set volume if the float value did not change
+#ifdef HAVE_FM_RADIO
if (volume != mOutputs.valueFor(output)->mCurVolume[stream] || (stream == AudioSystem::FM) || force) {
+#else
+ if (volume != mOutputs.valueFor(output)->mCurVolume[stream] || force) {
+#endif
mOutputs.valueFor(output)->mCurVolume[stream] = volume;
LOGV("setStreamVolume() for output %d stream %d, volume %f, delay %d", output, stream, volume, delayMs);
if (stream == AudioSystem::VOICE_CALL ||
@@ -1831,6 +1849,7 @@ status_t AudioPolicyManagerBase::checkAndSetVolume(int stream, int index, audio_
if (voiceVolume >= 0 && output == mHardwareOutput) {
mpClientInterface->setVoiceVolume(voiceVolume, delayMs);
}
+#ifdef HAVE_FM_RADIO
} else if (stream == AudioSystem::FM) {
float fmVolume = -1.0;
fmVolume = computeVolume(stream, index, output, device);
@@ -1838,6 +1857,7 @@ status_t AudioPolicyManagerBase::checkAndSetVolume(int stream, int index, audio_
mpClientInterface->setFmVolume(fmVolume, delayMs);
}
return NO_ERROR;
+#endif
}
mpClientInterface->setStreamVolume((AudioSystem::stream_type)stream, volume, output, delayMs);
diff --git a/libs/audioflinger/AudioPolicyService.cpp b/libs/audioflinger/AudioPolicyService.cpp
index ad50a6c..aa2aecf 100644
--- a/libs/audioflinger/AudioPolicyService.cpp
+++ b/libs/audioflinger/AudioPolicyService.cpp
@@ -556,10 +556,12 @@ status_t AudioPolicyService::setVoiceVolume(float volume, int delayMs)
return mAudioCommandThread->voiceVolumeCommand(volume, delayMs);
}
+#ifdef HAVE_FM_RADIO
status_t AudioPolicyService::setFmVolume(float volume, int delayMs)
{
return mAudioCommandThread->fmVolumeCommand(volume, delayMs);
}
+#endif
// ----------- AudioPolicyService::AudioCommandThread implementation ----------
@@ -656,6 +658,7 @@ bool AudioPolicyService::AudioCommandThread::threadLoop()
}
delete data;
}break;
+#ifdef HAVE_FM_RADIO
case SET_FM_VOLUME: {
FmVolumeData *data = (FmVolumeData *)command->mParam;
LOGV("AudioCommandThread() processing set fm volume volume %f", data->mVolume);
@@ -666,6 +669,7 @@ bool AudioPolicyService::AudioCommandThread::threadLoop()
}
delete data;
}break;
+#endif
default:
LOGW("AudioCommandThread() unknown command %d", command->mCommand);
}
@@ -830,6 +834,7 @@ status_t AudioPolicyService::AudioCommandThread::voiceVolumeCommand(float volume
return status;
}
+#ifdef HAVE_FM_RADIO
status_t AudioPolicyService::AudioCommandThread::fmVolumeCommand(float volume, int delayMs)
{
status_t status = NO_ERROR;
@@ -855,7 +860,7 @@ status_t AudioPolicyService::AudioCommandThread::fmVolumeCommand(float volume, i
}
return status;
}
-
+#endif
// insertCommand_l() must be called with mLock held
void AudioPolicyService::AudioCommandThread::insertCommand_l(AudioCommand *command, int delayMs)
@@ -917,9 +922,11 @@ void AudioPolicyService::AudioCommandThread::insertCommand_l(AudioCommand *comma
LOGV("Filtering out volume command on output %d for stream %d", data->mIO, data->mStream);
removedCommands.add(command2);
} break;
+#ifdef HAVE_FM_RADIO
case SET_FM_VOLUME: {
removedCommands.add(command2);
} break;
+#endif
case START_TONE:
case STOP_TONE:
default:
diff --git a/libs/audioflinger/AudioPolicyService.h b/libs/audioflinger/AudioPolicyService.h
index 26454be..508fcb2 100644
--- a/libs/audioflinger/AudioPolicyService.h
+++ b/libs/audioflinger/AudioPolicyService.h
@@ -106,7 +106,9 @@ public:
virtual status_t startTone(ToneGenerator::tone_type tone, AudioSystem::stream_type stream);
virtual status_t stopTone();
virtual status_t setVoiceVolume(float volume, int delayMs = 0);
+#ifdef HAVE_FM_RADIO
virtual status_t setFmVolume(float volume, int delayMs = 0);
+#endif
private:
AudioPolicyService();
@@ -131,7 +133,9 @@ private:
SET_VOLUME,
SET_PARAMETERS,
SET_VOICE_VOLUME,
+#ifdef HAVE_FM_RADIO
SET_FM_VOLUME
+#endif
};
AudioCommandThread (String8 name);
@@ -149,7 +153,9 @@ private:
status_t volumeCommand(int stream, float volume, int output, int delayMs = 0);
status_t parametersCommand(int ioHandle, const String8& keyValuePairs, int delayMs = 0);
status_t voiceVolumeCommand(float volume, int delayMs = 0);
+#ifdef HAVE_FM_RADIO
status_t fmVolumeCommand(float volume, int delayMs = 0);
+#endif
void insertCommand_l(AudioCommand *command, int delayMs = 0);
private:
@@ -193,12 +199,12 @@ private:
public:
float mVolume;
};
-
+#ifdef HAVE_FM_RADIO
class FmVolumeData {
public:
float mVolume;
};
-
+#endif
Mutex mLock;
Condition mWaitWorkCV;
Vector <AudioCommand *> mAudioCommands; // list of pending commands
diff --git a/media/libmedia/Android.mk b/media/libmedia/Android.mk
index 02b8324..9d8fbb8 100644
--- a/media/libmedia/Android.mk
+++ b/media/libmedia/Android.mk
@@ -37,6 +37,10 @@ ifneq ($(BOARD_USES_ECLAIR_LIBCAMERA),true)
libcamera_client
endif
+ifeq ($(BOARD_HAVE_FM_RADIO),true)
+ LOCAL_CFLAGS += -DHAVE_FM_RADIO
+endif
+
LOCAL_MODULE:= libmedia
ifeq ($(TARGET_OS)-$(TARGET_SIMULATOR),linux-true)
diff --git a/media/libmedia/AudioSystem.cpp b/media/libmedia/AudioSystem.cpp
index 1e53408..dfeb727 100644
--- a/media/libmedia/AudioSystem.cpp
+++ b/media/libmedia/AudioSystem.cpp
@@ -364,12 +364,14 @@ unsigned int AudioSystem::getInputFramesLost(audio_io_handle_t ioHandle) {
return result;
}
+#ifdef HAVE_FM_RADIO
status_t AudioSystem::setFmVolume(float value)
{
const sp<IAudioFlinger>& af = AudioSystem::get_audio_flinger();
if (af == 0) return PERMISSION_DENIED;
return af->setFmVolume(value);
}
+#endif
// ---------------------------------------------------------------------------
@@ -711,6 +713,7 @@ bool AudioSystem::isInputDevice(audio_devices device)
}
}
+#ifdef HAVE_FM_RADIO
bool AudioSystem::isFmDevice(audio_devices device)
{
if ((popCount(device) == 1 ) &&
@@ -720,6 +723,7 @@ bool AudioSystem::isFmDevice(audio_devices device)
return false;
}
}
+#endif
bool AudioSystem::isA2dpDevice(audio_devices device)
{
@@ -809,8 +813,10 @@ const char *AudioParameter::keySamplingRate = "sampling_rate";
const char *AudioParameter::keyFormat = "format";
const char *AudioParameter::keyChannels = "channels";
const char *AudioParameter::keyFrameCount = "frame_count";
+#ifdef HAVE_FM_RADIO
const char *AudioParameter::keyFmOn = "fm_on";
const char *AudioParameter::keyFmOff = "fm_off";
+#endif
AudioParameter::AudioParameter(const String8& keyValuePairs)
{
diff --git a/media/libmedia/IAudioFlinger.cpp b/media/libmedia/IAudioFlinger.cpp
index 731159a..124d64e 100644
--- a/media/libmedia/IAudioFlinger.cpp
+++ b/media/libmedia/IAudioFlinger.cpp
@@ -499,6 +499,7 @@ public:
return reply.readInt32();
}
+#ifdef HAVE_FM_RADIO
virtual status_t setFmVolume(float volume)
{
Parcel data, reply;
@@ -507,6 +508,7 @@ public:
remote()->transact(SET_FM_VOLUME, data, &reply);
return reply.readInt32();
}
+#endif
};
IMPLEMENT_META_INTERFACE(AudioFlinger, "android.media.IAudioFlinger");
@@ -779,12 +781,14 @@ status_t BnAudioFlinger::onTransact(
return NO_ERROR;
} break;
+#ifdef HAVE_FM_RADIO
case SET_FM_VOLUME: {
CHECK_INTERFACE(IAudioFlinger, data, reply);
float volume = data.readFloat();
reply->writeInt32( setFmVolume(volume) );
return NO_ERROR;
} break;
+#endif
default:
return BBinder::onTransact(code, data, reply, flags);
}