Hi,
I have fixed the alsa compilation problem on Eclair, I have to test because I
just create some stub fuction
and I must read the source code of other device for understandig the new
interface. So it is just to have
somenthing to start and compile.
Michael
--
unsubscribe: android-porting+unsubscr...@googlegroups.com
website: http://groups.google.com/group/android-porting
Not yes tested but fix the compilation issue
Signed-off-by: Michael Trimarchi <mich...@panicking.kicks-ass.org>
---
diff --git a/AudioHardwareALSA.cpp b/AudioHardwareALSA.cpp
index 684ee63..40eda60 100644
--- a/AudioHardwareALSA.cpp
+++ b/AudioHardwareALSA.cpp
@@ -232,9 +232,9 @@ status_t AudioHardwareALSA::setMasterVolume(float volume)
}
AudioStreamOut *
-AudioHardwareALSA::openOutputStream(int format,
- int channelCount,
- uint32_t sampleRate,
+AudioHardwareALSA::openOutputStream(uint32_t devices, int *format,
+ uint32_t *channelCount,
+ uint32_t *sampleRate,
status_t *status)
{
AutoMutex lock(mLock);
@@ -247,7 +247,7 @@ AudioHardwareALSA::openOutputStream(int format,
AudioStreamOutALSA *out = new AudioStreamOutALSA(this);
- *status = out->set(format, channelCount, sampleRate);
+ *status = out->set(*format, *channelCount, *sampleRate);
if (*status == NO_ERROR) {
mOutput = out;
@@ -262,17 +262,27 @@ AudioHardwareALSA::openOutputStream(int format,
return mOutput;
}
+void AudioHardwareALSA::closeOutputStream(AudioStreamOut* out) {
+ Mutex::Autolock lock(mLock);
+ if (mOutput == 0 || mOutput != out) {
+ LOGW("Attempt to close invalid output stream");
+ }
+ else {
+ delete mOutput;
+ mOutput = 0;
+ }
+}
+
AudioStreamIn *
-AudioHardwareALSA::openInputStream(int inputSource,
- int format,
- int channelCount,
- uint32_t sampleRate,
+AudioHardwareALSA::openInputStream(uint32_t inputSource,
+ int *format,
+ uint32_t *channelCount,
+ uint32_t *sampleRate,
status_t *status,
AudioSystem::audio_in_acoustics acoustics)
{
// check for valid input source
- if ((inputSource < AudioRecord::DEFAULT_INPUT) ||
- (inputSource >= AudioRecord::NUM_INPUT_SOURCES)) {
+ if (!AudioSystem::isInputDevice((AudioSystem::audio_devices)inputSource)) {
return 0;
}
@@ -286,7 +296,7 @@ AudioHardwareALSA::openInputStream(int inputSource,
AudioStreamInALSA *in = new AudioStreamInALSA(this, acoustics);
- *status = in->set(format, channelCount, sampleRate);
+ *status = in->set(*format, *channelCount, *sampleRate);
if (*status == NO_ERROR) {
mInput = in;
// Some information is expected to be available immediately after
@@ -300,6 +310,17 @@ AudioHardwareALSA::openInputStream(int inputSource,
return mInput;
}
+void AudioHardwareALSA::closeInputStream(AudioStreamIn* in) {
+ Mutex::Autolock lock(mLock);
+ if (mInput == 0 || mInput != in) {
+ LOGW("Attempt to close invalid input stream");
+ }
+ else {
+ delete mInput;
+ mInput = 0;
+ }
+}
+
status_t AudioHardwareALSA::doRouting()
{
AutoMutex lock(mLock);
@@ -929,8 +950,9 @@ int AudioStreamOutALSA::channelCount() const
return c;
}
-status_t AudioStreamOutALSA::setVolume(float volume)
+status_t AudioStreamOutALSA::setVolume(float left, float right)
{
+ float volume = (left > right) ? left : right;
if (!mParent->mMixer || !mDevice)
return NO_INIT;
@@ -1016,6 +1038,39 @@ uint32_t AudioStreamOutALSA::latency() const
return USEC_TO_MSEC (mDefaults->latency);
}
+status_t AudioStreamOutALSA::setParameters(const String8& keyValuePairs)
+{
+ AudioParameter param = AudioParameter(keyValuePairs);
+ String8 key = String8(AudioParameter::keyRouting);
+ status_t status = NO_ERROR;
+ int device;
+ LOGV("setParameters() %s", keyValuePairs.string());
+
+ if (param.getInt(key, device) == NO_ERROR) {
+ mDevice = device;
+ param.remove(key);
+ }
+
+ if (param.size()) {
+ status = BAD_VALUE;
+ }
+ return status;
+}
+
+String8 AudioStreamOutALSA::getParameters(const String8& keys)
+{
+ AudioParameter param = AudioParameter(keys);
+ String8 value;
+ String8 key = String8(AudioParameter::keyRouting);
+
+ if (param.get(key, value) == NO_ERROR) {
+ param.addInt(key, (int)mDevice);
+ }
+
+ LOGV("getParameters() %s", param.toString().string());
+ return param.toString();
+}
+
// ----------------------------------------------------------------------------
AudioStreamInALSA::AudioStreamInALSA(AudioHardwareALSA *parent,
@@ -1117,6 +1172,39 @@ status_t AudioStreamInALSA::standby()
return NO_ERROR;
}
+status_t AudioStreamInALSA::setParameters(const String8& keyValuePairs)
+{
+ AudioParameter param = AudioParameter(keyValuePairs);
+ String8 key = String8(AudioParameter::keyRouting);
+ status_t status = NO_ERROR;
+ int device;
+ LOGV("setParameters() %s", keyValuePairs.string());
+
+ if (param.getInt(key, device) == NO_ERROR) {
+ mDevice = device;
+ param.remove(key);
+ }
+
+ if (param.size()) {
+ status = BAD_VALUE;
+ }
+ return status;
+}
+
+String8 AudioStreamInALSA::getParameters(const String8& keys)
+{
+ AudioParameter param = AudioParameter(keys);
+ String8 value;
+ String8 key = String8(AudioParameter::keyRouting);
+
+ if (param.get(key, value) == NO_ERROR) {
+ param.addInt(key, (int)mDevice);
+ }
+
+ LOGV("getParameters() %s", param.toString().string());
+ return param.toString();
+}
+
// ----------------------------------------------------------------------------
struct mixer_info_t
diff --git a/AudioHardwareALSA.h b/AudioHardwareALSA.h
index bae5bc7..4b1b958 100644
--- a/AudioHardwareALSA.h
+++ b/AudioHardwareALSA.h
@@ -112,6 +112,7 @@ namespace android
status_t set(int format,
int channels,
uint32_t rate);
+
virtual uint32_t sampleRate() const;
status_t sampleRate(uint32_t rate);
virtual size_t bufferSize() const;
@@ -184,10 +185,17 @@ namespace android
virtual ssize_t write(const void *buffer, size_t bytes);
virtual status_t dump(int fd, const Vector<String16>& args);
- status_t setVolume(float volume);
+ status_t setVolume(float left, float right);
virtual status_t standby();
+ virtual uint32_t channels() const {
+ return AudioSystem::CHANNEL_OUT_STEREO;
+ }
+
+ virtual status_t setParameters(const String8& keyValuePairs);
+ virtual String8 getParameters(const String8& keys);
+
protected:
friend class AudioHardwareALSA;
@@ -207,7 +215,7 @@ namespace android
return ALSAStreamOps::set(format, channelCount, sampleRate);
}
- virtual uint32_t sampleRate() {
+ virtual uint32_t sampleRate() const {
return ALSAStreamOps::sampleRate();
}
@@ -216,11 +224,6 @@ namespace android
return ALSAStreamOps::bufferSize();
}
- virtual int channelCount() const
- {
- return ALSAStreamOps::channelCount();
- }
-
virtual int format() const
{
return ALSAStreamOps::format();
@@ -233,6 +236,13 @@ namespace android
virtual status_t standby();
+ virtual uint32_t channels() const {
+ return ALSAStreamOps::channelCount();
+ }
+
+ virtual status_t setParameters(const String8& keyValuePairs);
+ virtual String8 getParameters(const String8& keys);
+
protected:
friend class AudioHardwareALSA;
@@ -270,20 +280,28 @@ namespace android
/** This method creates and opens the audio hardware output stream */
virtual AudioStreamOut* openOutputStream(
- int format=0,
- int channelCount=0,
- uint32_t sampleRate=0,
+ uint32_t devices,
+ int *format=0,
+ uint32_t *channelCount=0,
+ uint32_t *sampleRate=0,
status_t *status=0);
/** This method creates and opens the audio hardware input stream */
virtual AudioStreamIn* openInputStream(
- int inputSource,
- int format,
- int channelCount,
- uint32_t sampleRate,
+ uint32_t inputSource,
+ int *format,
+ uint32_t *channelCount,
+ uint32_t *sampleRate,
status_t *status,
AudioSystem::audio_in_acoustics acoustics);
+ virtual void closeOutputStream(AudioStreamOut* out);
+ virtual void closeInputStream(AudioStreamIn* in);
+
+ virtual status_t setParameters(const String8& keyValuePairs);
+ virtual String8 getParameters(const String8& keys);
+
+
protected:
/**
* doRouting actually initiates the routing. A call to setRouting
Not yet tested
Signed-off-by: Michael Trimarchi <mich...@panicking.kicks-ass.org>
---
diff --git a/include/media/AudioSystem.h b/include/media/AudioSystem.h
index e066177..03cd023 100644
--- a/include/media/AudioSystem.h
+++ b/include/media/AudioSystem.h
@@ -168,6 +168,15 @@ public:
TX_DISABLE = 0
};
+ enum audio_routes {
+ ROUTE_EARPIECE = (1 << 0),
+ ROUTE_SPEAKER = (1 << 1),
+ ROUTE_BLUETOOTH_SCO = (1 << 2),
+ ROUTE_HEADSET = (1 << 3),
+ ROUTE_BLUETOOTH_A2DP = (1 << 4),
+ ROUTE_ALL = -1UL,
+ };
+
/* These are static methods to control the system-wide AudioFlinger
* only privileged processes can have access to them
*/