summaryrefslogtreecommitdiffstats
path: root/libs
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2009-03-02 22:54:33 -0800
committerThe Android Open Source Project <initial-contribution@android.com>2009-03-02 22:54:33 -0800
commit3dec7d563a2f3e1eb967ce2054a00b6620e3558c (patch)
treeaa3b0365c47cb3c1607c0dc76c8d32b4046fc287 /libs
parent15ab3eae2ec3d73b3e8aa60b33ae41445bf83f4b (diff)
downloadframeworks_base-3dec7d563a2f3e1eb967ce2054a00b6620e3558c.zip
frameworks_base-3dec7d563a2f3e1eb967ce2054a00b6620e3558c.tar.gz
frameworks_base-3dec7d563a2f3e1eb967ce2054a00b6620e3558c.tar.bz2
auto import from //depot/cupcake/@137055
Diffstat (limited to 'libs')
-rw-r--r--libs/audioflinger/A2dpAudioInterface.cpp15
-rw-r--r--libs/audioflinger/A2dpAudioInterface.h1
-rw-r--r--libs/audioflinger/AudioFlinger.cpp17
-rw-r--r--libs/audioflinger/AudioFlinger.h5
-rw-r--r--libs/audioflinger/AudioHardwareGeneric.h2
-rw-r--r--libs/ui/Camera.cpp2
-rw-r--r--libs/utils/Threads.cpp4
7 files changed, 24 insertions, 22 deletions
diff --git a/libs/audioflinger/A2dpAudioInterface.cpp b/libs/audioflinger/A2dpAudioInterface.cpp
index d1b7af3..eb00f8c 100644
--- a/libs/audioflinger/A2dpAudioInterface.cpp
+++ b/libs/audioflinger/A2dpAudioInterface.cpp
@@ -131,8 +131,7 @@ status_t A2dpAudioInterface::dump(int fd, const Vector<String16>& args)
// ----------------------------------------------------------------------------
A2dpAudioInterface::A2dpAudioStreamOut::A2dpAudioStreamOut() :
- mFd(-1), mStandby(true), mStartCount(0), mRetryCount(0), mData(NULL),
- mInitialized(false)
+ mFd(-1), mStandby(true), mStartCount(0), mRetryCount(0), mData(NULL)
{
// use any address by default
strncpy(mA2dpAddress, "00:00:00:00:00:00", sizeof(mA2dpAddress));
@@ -167,13 +166,14 @@ ssize_t A2dpAudioInterface::A2dpAudioStreamOut::write(const void* buffer, size_t
status_t status = NO_INIT;
size_t remaining = bytes;
- if (!mInitialized) {
- status = a2dp_init(mA2dpAddress, 44100, 2, &mData);
+ if (!mData) {
+ status = a2dp_init(44100, 2, &mData);
if (status < 0) {
LOGE("a2dp_init failed err: %d\n", status);
+ mData = NULL;
goto Error;
}
- mInitialized = true;
+ a2dp_set_sink(mData, mA2dpAddress);
}
while (remaining > 0) {
@@ -191,7 +191,6 @@ ssize_t A2dpAudioInterface::A2dpAudioStreamOut::write(const void* buffer, size_t
return bytes;
Error:
- close();
// Simulate audio output timing in case of error
usleep(bytes * 1000000 / frameSize() / sampleRate());
@@ -218,7 +217,8 @@ status_t A2dpAudioInterface::A2dpAudioStreamOut::setAddress(const char* address)
if (strcmp(address, mA2dpAddress)) {
strcpy(mA2dpAddress, address);
- close();
+ if (mData)
+ a2dp_set_sink(mData, mA2dpAddress);
}
return NO_ERROR;
@@ -229,7 +229,6 @@ status_t A2dpAudioInterface::A2dpAudioStreamOut::close()
if (mData) {
a2dp_cleanup(mData);
mData = NULL;
- mInitialized = false;
}
return NO_ERROR;
}
diff --git a/libs/audioflinger/A2dpAudioInterface.h b/libs/audioflinger/A2dpAudioInterface.h
index 5bef5da..a56e8a0 100644
--- a/libs/audioflinger/A2dpAudioInterface.h
+++ b/libs/audioflinger/A2dpAudioInterface.h
@@ -96,7 +96,6 @@ private:
int mRetryCount;
char mA2dpAddress[20];
void* mData;
- bool mInitialized;
};
Mutex mLock;
diff --git a/libs/audioflinger/AudioFlinger.cpp b/libs/audioflinger/AudioFlinger.cpp
index 557d93b..92c40e9 100644
--- a/libs/audioflinger/AudioFlinger.cpp
+++ b/libs/audioflinger/AudioFlinger.cpp
@@ -171,13 +171,6 @@ AudioFlinger::AudioFlinger()
} else {
LOGE("Couldn't even initialize the stubbed audio hardware!");
}
-
- char value[PROPERTY_VALUE_MAX];
- property_get("ro.audio.silent", value, "0");
- if (atoi(value)) {
- LOGD("Silence is golden");
- setMasterMute(true);
- }
}
AudioFlinger::~AudioFlinger()
@@ -995,6 +988,16 @@ bool AudioFlinger::MixerThread::threadLoop()
IPCThreadState::self()->flushCommands();
mWaitWorkCV.wait(mLock);
LOGV("Audio hardware exiting standby, output %d\n", mOutputType);
+
+ if (mMasterMute == false) {
+ char value[PROPERTY_VALUE_MAX];
+ property_get("ro.audio.silent", value, "0");
+ if (atoi(value)) {
+ LOGD("Silence is golden");
+ setMasterMute(true);
+ }
+ }
+
standbyTime = systemTime() + kStandbyTimeInNsecs;
continue;
}
diff --git a/libs/audioflinger/AudioFlinger.h b/libs/audioflinger/AudioFlinger.h
index dfbb1e9..77f064b 100644
--- a/libs/audioflinger/AudioFlinger.h
+++ b/libs/audioflinger/AudioFlinger.h
@@ -223,10 +223,7 @@ private:
enum track_flags {
STEPSERVER_FAILED = 0x01, // StepServer could not acquire cblk->lock mutex
SYSTEM_FLAGS_MASK = 0x0000ffffUL,
-
- AUDIO_IN_AGC_ENABLE = AudioSystem::AGC_ENABLE << 16,
- AUDIO_IN_NS_ENABLE = AudioSystem::NS_ENABLE << 16,
- AUDIO_IN_IIR_ENABLE = AudioSystem::TX_IIR_ENABLE << 16
+ // The upper 16 bits are used for track-specific flags.
};
TrackBase(const sp<MixerThread>& mixerThread,
diff --git a/libs/audioflinger/AudioHardwareGeneric.h b/libs/audioflinger/AudioHardwareGeneric.h
index 1d58389..c949aa1 100644
--- a/libs/audioflinger/AudioHardwareGeneric.h
+++ b/libs/audioflinger/AudioHardwareGeneric.h
@@ -47,7 +47,7 @@ public:
virtual size_t bufferSize() const { return 4096; }
virtual int channelCount() const { return 2; }
virtual int format() const { return AudioSystem::PCM_16_BIT; }
- virtual uint32_t latency() const { return 0; }
+ virtual uint32_t latency() const { return 20; }
virtual status_t setVolume(float volume) { return INVALID_OPERATION; }
virtual ssize_t write(const void* buffer, size_t bytes);
virtual status_t standby();
diff --git a/libs/ui/Camera.cpp b/libs/ui/Camera.cpp
index 6c60b85..b3cbda1 100644
--- a/libs/ui/Camera.cpp
+++ b/libs/ui/Camera.cpp
@@ -110,6 +110,8 @@ sp<Camera> Camera::connect()
if (c->mCamera != 0) {
c->mCamera->asBinder()->linkToDeath(c);
c->mStatus = NO_ERROR;
+ } else {
+ c.clear();
}
return c;
}
diff --git a/libs/utils/Threads.cpp b/libs/utils/Threads.cpp
index 74271ba..5f407a9 100644
--- a/libs/utils/Threads.cpp
+++ b/libs/utils/Threads.cpp
@@ -896,6 +896,7 @@ void ReadWriteLock::unlockForRead()
{
mLock.lock();
if (mNumReaders == 0) {
+ mLock.unlock();
LOG(LOG_WARN, "thread",
"WARNING: unlockForRead requested, but not locked\n");
return;
@@ -961,6 +962,7 @@ void ReadWriteLock::unlockForWrite()
{
mLock.lock();
if (mNumWriters == 0) {
+ mLock.unlock();
LOG(LOG_WARN, "thread",
"WARNING: unlockForWrite requested, but not locked\n");
return;
@@ -972,7 +974,7 @@ void ReadWriteLock::unlockForWrite()
//printf(" wrlk held %.3f msec\n",
// (double) mDebugTimer.durationUsecs() / 1000.0);
#endif
- // mWriteWaiter.signal(); // should other writers get first dibs?
+ mWriteWaiter.signal(); // should other writers get first dibs?
//printf("+++ signaling readers (if any)\n");
mReadWaiter.broadcast(); // wake all readers (if any)
mLock.unlock();