summaryrefslogtreecommitdiffstats
path: root/libaudio/AudioHardwareALSA.h
diff options
context:
space:
mode:
authorAnton Rogozin <ant.rogozin@samsung.com>2010-10-07 11:39:37 +0900
committerEric Laurent <elaurent@google.com>2010-10-07 11:41:47 -0700
commitc438633685a7cede23633823086c9a29be40cc54 (patch)
tree312a7a288d923f826d6312efd096802a089ff27a /libaudio/AudioHardwareALSA.h
parent3680ff0b8a3a25d05055079b4f4b033810bc9c1b (diff)
downloaddevice_samsung_crespo-c438633685a7cede23633823086c9a29be40cc54.zip
device_samsung_crespo-c438633685a7cede23633823086c9a29be40cc54.tar.gz
device_samsung_crespo-c438633685a7cede23633823086c9a29be40cc54.tar.bz2
libaudio: code cleanup & RIL interface update
Anton Rogozin <ant.rogozin@samsung.com>: Unused code removed, dynamic loading of RIL lib, alsa lib resampler turning on UK KIM <w0806.kim@samsung.com>: 1. deleted unneeded standby_l() and set_wakelock func() in each stream class. 2. use StreamOPS:close() to close stream. 3. reference new libaudio. Eric Laurent <elaurent@google.com>: Some more cleanup Fixed clicks when playing call ended tone Change-Id: Ieea1319262576b2f6680c675957643eacbab9c11
Diffstat (limited to 'libaudio/AudioHardwareALSA.h')
-rwxr-xr-xlibaudio/AudioHardwareALSA.h224
1 files changed, 68 insertions, 156 deletions
diff --git a/libaudio/AudioHardwareALSA.h b/libaudio/AudioHardwareALSA.h
index 0390beb..f65aa68 100755
--- a/libaudio/AudioHardwareALSA.h
+++ b/libaudio/AudioHardwareALSA.h
@@ -24,73 +24,9 @@
#include <hardware_legacy/AudioHardwareBase.h>
-#if defined SEC_IPC
-#include <hardware/hardware.h>
-
// sangsu fix : headers for IPC
#include "secril-client.h"
-// sangsu fix : defines for IPC
-#define OEM_FUNCTION_ID_SOUND 0x08 // sound Main Cmd
-
-//sangsu fix : sound sub command for IPC
-#define OEM_SOUND_SET_VOLUME_CTRL 0x03
-#define OEM_SOUND_GET_VOLUME_CTRL 0x04
-#define OEM_SOUND_SET_AUDIO_PATH_CTRL 0x05
-#define OEM_SOUND_GET_AUDIO_PATH_CTRL 0x06
-
-//sangsu fix : audio path for IPC
-#define OEM_SOUND_AUDIO_PATH_HANDSET 0x01
-#define OEM_SOUND_AUDIO_PATH_HEADSET 0x02
-#define OEM_SOUND_AUDIO_PATH_HANDFREE 0x03
-#define OEM_SOUND_AUDIO_PATH_BLUETOOTH 0x04
-#define OEM_SOUND_AUDIO_PATH_STREOBT 0x05
-#define OEM_SOUND_AUDIO_PATH_SPEAKER 0x06
-#define OEM_SOUND_AUDIO_PATH_HEADSET35 0x07
-#define OEM_SOUND_AUDIO_PATH_BT_NSEC_OFF 0x08
-
-// sangsu fix : volume level for IPC
-#define OEM_SOUND_VOLUME_LEVEL_MUTE 0x00
-#define OEM_SOUND_VOLUME_LEVEL1 0x01
-#define OEM_SOUND_VOLUME_LEVEL2 0x02
-#define OEM_SOUND_VOLUME_LEVEL3 0x03
-#define OEM_SOUND_VOLUME_LEVEL4 0x04
-#define OEM_SOUND_VOLUME_LEVEL5 0x05
-#define OEM_SOUND_VOLUME_LEVEL6 0x06
-#define OEM_SOUND_VOLUME_LEVEL7 0x07
-#define OEM_SOUND_VOLUME_LEVEL8 0x08
-
-// For synchronizing I2S clocking
-#if defined SYNCHRONIZE_CP
-#define OEM_SOUND_SET_CLOCK_CTRL 0x0A
-#define OEM_SOUND_CLOCK_START 0x01
-#define OEM_SOUND_CLOCK_STOP 0x00
-#endif
-
-// For VT
-#if defined VIDEO_TELEPHONY
-#define OEM_SOUND_VIDEO_CALL_STOP 0x00
-#define OEM_SOUND_VIDEO_CALL_START 0x01
-#define OEM_SOUND_SET_VIDEO_CALL_CTRL 0x07
-#endif
-
-// sangsu fix : volume type for IPC
-#define OEM_SOUND_TYPE_VOICE 0x01 // Receiver(0x00) + Voice(0x01)
-#define OEM_SOUND_TYPE_KEYTONE 0x02 // Receiver(0x00) + Key tone (0x02)
-#define OEM_SOUND_TYPE_BELL 0x03 // Receiver(0x00) + Bell (0x03)
-#define OEM_SOUND_TYPE_MESSAGE 0x04 // Receiver(0x00) + Message(0x04)
-#define OEM_SOUND_TYPE_ALARM 0x05 // Receiver(0x00) + Alarm (0x05)
-#define OEM_SOUND_TYPE_SPEAKER 0x11 // SpeakerPhone (0x10) + Voice(0x01)
-#define OEM_SOUND_TYPE_HFKVOICE 0x21 // HFK (0x20) + Voice(0x01)
-#define OEM_SOUND_TYPE_HFKKEY 0x22 // HFK (0x20) + Key tone (0x02)
-#define OEM_SOUND_TYPE_HFKBELL 0x23 // HFK (0x20) + Bell (0x03)
-#define OEM_SOUND_TYPE_HFKMSG 0x24 // HFK (0x20) + Message(0x04)
-#define OEM_SOUND_TYPE_HFKALARM 0x25 // HFK (0x20) + Alarm (0x05)
-#define OEM_SOUND_TYPE_HFKPDA 0x26 // HFK (0x20) + PDA miscellaneous sound (0x06)
-#define OEM_SOUND_TYPE_HEADSET 0x31 // Headset (0x30) + Voice(0x01)
-#define OEM_SOUND_TYPE_BTVOICE 0x41 // BT(0x40) + Voice(0x01)
-#endif
-
#ifndef ALSA_DEFAULT_SAMPLE_RATE
#define ALSA_DEFAULT_SAMPLE_RATE 44100 // in Hz
#endif
@@ -112,7 +48,6 @@
namespace android
{
-
class AudioHardwareALSA;
// ----------------------------------------------------------------------------
@@ -181,13 +116,13 @@ namespace android
status_t sampleRate(uint32_t rate);
virtual size_t bufferSize() const;
virtual int format() const;
- int getAndroidFormat(snd_pcm_format_t format);
+ int getAndroidFormat(snd_pcm_format_t format);
virtual uint32_t channels() const;
int channelCount() const;
status_t channelCount(int channelCount);
uint32_t getAndroidChannels(int channelCount) const;
-
+
status_t open(int mode, uint32_t device);
void close();
status_t setSoftwareParams();
@@ -209,7 +144,6 @@ namespace android
snd_pcm_t *mHandle;
snd_pcm_hw_params_t *mHardwareParams;
snd_pcm_sw_params_t *mSoftwareParams;
- int mMode;
uint32_t mDevice;
StreamDefaults *mDefaults;
@@ -224,9 +158,9 @@ namespace android
virtual ~AudioStreamOutALSA();
- status_t set(int *format,
- uint32_t *channelCount,
- uint32_t *sampleRate){
+ status_t set(int *format,
+ uint32_t *channelCount,
+ uint32_t *sampleRate){
return ALSAStreamOps::set(format, channelCount, sampleRate);
}
@@ -239,7 +173,7 @@ namespace android
return ALSAStreamOps::bufferSize();
}
- virtual uint32_t channels() const
+ virtual uint32_t channels() const
{
return ALSAStreamOps::channels();
}
@@ -254,18 +188,16 @@ namespace android
virtual ssize_t write(const void *buffer, size_t bytes);
virtual status_t dump(int fd, const Vector<String16>& args);
virtual status_t setDevice(int mode, uint32_t newDevice, uint32_t audio_mode);
- virtual status_t setVolume(float left, float right); //Tushar: New arch
+ virtual status_t setVolume(float left, float right); //Tushar: New arch
status_t setVolume(float volume);
status_t standby();
- bool isStandby();
- void setWakeLock();
- virtual status_t setParameters(const String8& keyValuePairs);
- virtual String8 getParameters(const String8& keys);
-
- virtual status_t getRenderPosition(uint32_t *dspFrames);
+ virtual status_t setParameters(const String8& keyValuePairs);
+ virtual String8 getParameters(const String8& keys);
+
+ virtual status_t getRenderPosition(uint32_t *dspFrames);
private:
@@ -279,9 +211,9 @@ namespace android
AudioStreamInALSA(AudioHardwareALSA *parent);
virtual ~AudioStreamInALSA();
- status_t set(int *format,
- uint32_t *channelCount,
- uint32_t *sampleRate){
+ status_t set(int *format,
+ uint32_t *channelCount,
+ uint32_t *sampleRate) {
return ALSAStreamOps::set(format, channelCount, sampleRate);
}
@@ -294,7 +226,7 @@ namespace android
return ALSAStreamOps::bufferSize();
}
- virtual uint32_t channels() const
+ virtual uint32_t channels() const
{
return ALSAStreamOps::channels();
}
@@ -311,37 +243,18 @@ namespace android
virtual status_t setGain(float gain);
virtual status_t standby();
- status_t standby_l();
- void setWakeLock();
- virtual status_t setParameters(const String8& keyValuePairs);
- virtual String8 getParameters(const String8& keys);
+ virtual status_t setParameters(const String8& keyValuePairs);
+ virtual String8 getParameters(const String8& keys);
- virtual unsigned int getInputFramesLost() const { return 0; }
+ virtual unsigned int getInputFramesLost() const { return 0; }
private:
- AudioHardwareALSA *mParent;
- bool mPowerLock;
- int16_t mBuffer[2 * PERIOD_SZ_CAPTURE];
+ AudioHardwareALSA *mParent;
+ bool mPowerLock;
+ int16_t mBuffer[2 * PERIOD_SZ_CAPTURE];
};
-#if defined SEC_IPC
- //TODO..implementation has to be done
- class AudioHardwareIPC
- {
- public:
- AudioHardwareIPC();
- virtual ~AudioHardwareIPC();
- status_t transmitVolumeIPC(uint32_t type, float volume);
- status_t transmitAudioPathIPC(uint32_t path);
-#if defined SYNCHRONIZE_CP
- status_t transmitClock_IPC(uint32_t condition);
-#endif
- private:
- HRilClient mClient;
- char data[100];
- };
-#endif
class AudioHardwareALSA : public AudioHardwareBase
{
public:
@@ -373,34 +286,32 @@ namespace android
// mic mute
virtual status_t setMicMute(bool state);
virtual status_t getMicMute(bool* state);
- virtual size_t getInputBufferSize(
- uint32_t sampleRate,
- int format,
- int channelCount);
-#if defined TURN_ON_DEVICE_ONLY_USE
- virtual int setMicStatus(int on); // To deliver status of input stream(activated or not). If it's activated, doesn't turn off codec.
-#endif
- /** This method creates and opens the audio hardware output stream */
- virtual AudioStreamOut* openOutputStream(
- uint32_t devices,
- int *format=0,
- uint32_t *channels=0,
- uint32_t *sampleRate=0,
- status_t *status=0);
- virtual void closeOutputStream(AudioStreamOut* out);
-
- /** This method creates and opens the audio hardware input stream */
- virtual AudioStreamIn* openInputStream(
- uint32_t devices,
- int *format,
- uint32_t *channels,
- uint32_t *sampleRate,
- status_t *status,
- AudioSystem::audio_in_acoustics acoustics);
- virtual void closeInputStream(AudioStreamIn* in);
-
- static uint32_t checkInputSampleRate(uint32_t sampleRate);
- static const uint32_t inputSamplingRates[];
+ virtual size_t getInputBufferSize(uint32_t sampleRate,
+ int format,
+ int channelCount);
+ virtual int setMicStatus(int on); // To deliver status of input stream(activated or not). If it's activated, doesn't turn off codec.
+
+ /** This method creates and opens the audio hardware output stream */
+ virtual AudioStreamOut* openOutputStream(uint32_t devices,
+ int *format = 0,
+ uint32_t *channels = 0,
+ uint32_t *sampleRate = 0,
+ status_t *status = 0);
+ virtual void closeOutputStream(AudioStreamOut* out);
+
+ /** This method creates and opens the audio hardware input stream */
+ virtual AudioStreamIn* openInputStream(uint32_t devices,
+ int *format,
+ uint32_t *channels,
+ uint32_t *sampleRate,
+ status_t *status,
+ AudioSystem::audio_in_acoustics acoustics);
+ virtual void closeInputStream(AudioStreamIn* in);
+
+ static uint32_t checkInputSampleRate(uint32_t sampleRate);
+ static const uint32_t inputSamplingRates[];
+
+ int mode() { return mMode; }
protected:
/**
@@ -409,34 +320,35 @@ namespace android
* doRouting when required. If the device has any special requirements these
* methods can be overriden.
*/
- virtual status_t doRouting(uint32_t device);
+ virtual status_t doRouting(uint32_t device);
- virtual status_t dump(int fd, const Vector<String16>& args);
+ virtual status_t dump(int fd, const Vector<String16>& args);
friend class AudioStreamOutALSA;
friend class AudioStreamInALSA;
- ALSAMixer *mMixer;
- AudioStreamOutALSA *mOutput;
- AudioStreamInALSA *mInput;
-#if defined SEC_IPC
- AudioHardwareIPC *mIPC; //for IPC
- uint32_t mRoutes[AudioSystem::NUM_MODES];
-#endif
+ ALSAMixer *mMixer;
+ AudioStreamOutALSA *mOutput;
+ AudioStreamInALSA *mInput;
+ uint32_t mRoutes[AudioSystem::NUM_MODES];
private:
- Mutex mLock;
-#if defined TURN_ON_DEVICE_ONLY_USE
- bool mActivatedInputDevice;
-#endif
+ Mutex mLock;
+ bool mActivatedInputDevice;
+
+ void *mSecRilLibHandle;
+ HRilClient mRilClient;
+ HRilClient (*openClientRILD) (void);
+ int (*disconnectRILD) (HRilClient);
+ int (*closeClientRILD) (HRilClient);
+ int (*isConnectedRILD) (HRilClient);
+ int (*connectRILD) (HRilClient);
+ int (*setCallVolume) (HRilClient, SoundType, int);
+ int (*setCallAudioPath)(HRilClient, AudioPath);
+
+ void loadRILD(void);
+ status_t connectRILDIfRequired(void);
};
- // ----------------------------------------------------------------------------
-
-#if defined SEC_IPC
-// sangsu fix : global functions for IPC
-static int onRawReqComplete(HRilClient client, const void *data, size_t datalen);
-static int onUnsol(HRilClient client, const void *data, size_t datalen);
-#endif
}; // namespace android
#endif // ANDROID_AUDIO_HARDWARE_ALSA_H