summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--camera/libcameraservice/CameraHardwareStub.cpp5
-rw-r--r--camera/libcameraservice/CameraHardwareStub.h1
-rw-r--r--camera/libcameraservice/CameraService.cpp17
-rw-r--r--camera/libcameraservice/CameraService.h3
-rw-r--r--include/ui/Camera.h3
-rw-r--r--include/ui/CameraHardwareInterface.h8
-rw-r--r--include/ui/ICamera.h3
-rw-r--r--libs/audioflinger/AudioFlinger.cpp35
-rw-r--r--libs/audioflinger/AudioFlinger.h2
-rw-r--r--libs/surfaceflinger/Buffer.cpp3
-rw-r--r--libs/surfaceflinger/Layer.cpp3
-rw-r--r--libs/surfaceflinger/LayerBase.cpp6
-rw-r--r--libs/ui/Camera.cpp8
-rw-r--r--libs/ui/ICamera.cpp18
14 files changed, 92 insertions, 23 deletions
diff --git a/camera/libcameraservice/CameraHardwareStub.cpp b/camera/libcameraservice/CameraHardwareStub.cpp
index 24496bb..35f4846 100644
--- a/camera/libcameraservice/CameraHardwareStub.cpp
+++ b/camera/libcameraservice/CameraHardwareStub.cpp
@@ -265,6 +265,11 @@ status_t CameraHardwareStub::autoFocus()
return NO_ERROR;
}
+status_t CameraHardwareStub::cancelAutoFocus()
+{
+ return NO_ERROR;
+}
+
/*static*/ int CameraHardwareStub::beginPictureThread(void *cookie)
{
CameraHardwareStub *c = (CameraHardwareStub *)cookie;
diff --git a/camera/libcameraservice/CameraHardwareStub.h b/camera/libcameraservice/CameraHardwareStub.h
index 000906a..f957fa8 100644
--- a/camera/libcameraservice/CameraHardwareStub.h
+++ b/camera/libcameraservice/CameraHardwareStub.h
@@ -51,6 +51,7 @@ public:
virtual void releaseRecordingFrame(const sp<IMemory>& mem);
virtual status_t autoFocus();
+ virtual status_t cancelAutoFocus();
virtual status_t takePicture();
virtual status_t cancelPicture();
virtual status_t dump(int fd, const Vector<String16>& args) const;
diff --git a/camera/libcameraservice/CameraService.cpp b/camera/libcameraservice/CameraService.cpp
index f425f6b..bab7d08 100644
--- a/camera/libcameraservice/CameraService.cpp
+++ b/camera/libcameraservice/CameraService.cpp
@@ -798,7 +798,6 @@ static void dump_to_file(const char *fname,
}
#endif
-// take a picture - image is returned in callback
status_t CameraService::Client::autoFocus()
{
LOGD("autoFocus (pid %d)", getCallingPid());
@@ -815,6 +814,22 @@ status_t CameraService::Client::autoFocus()
return mHardware->autoFocus();
}
+status_t CameraService::Client::cancelAutoFocus()
+{
+ LOGD("cancelAutoFocus (pid %d)", getCallingPid());
+
+ Mutex::Autolock lock(mLock);
+ status_t result = checkPid();
+ if (result != NO_ERROR) return result;
+
+ if (mHardware == 0) {
+ LOGE("mHardware is NULL, returning.");
+ return INVALID_OPERATION;
+ }
+
+ return mHardware->cancelAutoFocus();
+}
+
// take a picture - image is returned in callback
status_t CameraService::Client::takePicture()
{
diff --git a/camera/libcameraservice/CameraService.h b/camera/libcameraservice/CameraService.h
index f8c7216..0a909cf 100644
--- a/camera/libcameraservice/CameraService.h
+++ b/camera/libcameraservice/CameraService.h
@@ -110,6 +110,9 @@ private:
// auto focus
virtual status_t autoFocus();
+ // cancel auto focus
+ virtual status_t cancelAutoFocus();
+
// take a picture - returns an IMemory (ref-counted mmap)
virtual status_t takePicture();
diff --git a/include/ui/Camera.h b/include/ui/Camera.h
index ae6e255..9ceb8fd 100644
--- a/include/ui/Camera.h
+++ b/include/ui/Camera.h
@@ -143,6 +143,9 @@ public:
// autoFocus - status returned from callback
status_t autoFocus();
+ // cancel auto focus
+ status_t cancelAutoFocus();
+
// take a picture - picture returned from callback
status_t takePicture();
diff --git a/include/ui/CameraHardwareInterface.h b/include/ui/CameraHardwareInterface.h
index 535f70e..5fbb7d8 100644
--- a/include/ui/CameraHardwareInterface.h
+++ b/include/ui/CameraHardwareInterface.h
@@ -161,6 +161,14 @@ public:
virtual status_t autoFocus() = 0;
/**
+ * Cancels auto-focus function. If the auto-focus is still in progress,
+ * this function will cancel it. Whether the auto-focus is in progress
+ * or not, this function will return the focus position to the default.
+ * If the camera does not support auto-focus, this is a no-op.
+ */
+ virtual status_t cancelAutoFocus() = 0;
+
+ /**
* Take a picture.
*/
virtual status_t takePicture() = 0;
diff --git a/include/ui/ICamera.h b/include/ui/ICamera.h
index 1df7914..7595e36 100644
--- a/include/ui/ICamera.h
+++ b/include/ui/ICamera.h
@@ -76,6 +76,9 @@ public:
// auto focus
virtual status_t autoFocus() = 0;
+ // cancel auto focus
+ virtual status_t cancelAutoFocus() = 0;
+
// take a picture
virtual status_t takePicture() = 0;
diff --git a/libs/audioflinger/AudioFlinger.cpp b/libs/audioflinger/AudioFlinger.cpp
index 790a655..4f7500f 100644
--- a/libs/audioflinger/AudioFlinger.cpp
+++ b/libs/audioflinger/AudioFlinger.cpp
@@ -677,8 +677,8 @@ void AudioFlinger::binderDied(const wp<IBinder>& who) {
}
}
-void AudioFlinger::audioConfigChanged(int event, const sp<ThreadBase>& thread, void *param2) {
- Mutex::Autolock _l(mLock);
+// audioConfigChanged_l() must be called with AudioFlinger::mLock held
+void AudioFlinger::audioConfigChanged_l(int event, const sp<ThreadBase>& thread, void *param2) {
int ioHandle = 0;
for (size_t i = 0; i < mPlaybackThreads.size(); i++) {
@@ -700,7 +700,7 @@ void AudioFlinger::audioConfigChanged(int event, const sp<ThreadBase>& thread, v
size_t size = mNotificationClients.size();
for (size_t i = 0; i < size; i++) {
sp<IBinder> binder = mNotificationClients.itemAt(i);
- LOGV("audioConfigChanged() Notifying change to client %p", binder.get());
+ LOGV("audioConfigChanged_l() Notifying change to client %p", binder.get());
sp<IAudioFlingerClient> client = interface_cast<IAudioFlingerClient> (binder);
client->ioConfigChanged(event, ioHandle, param2);
}
@@ -803,8 +803,8 @@ void AudioFlinger::ThreadBase::processConfigEvents()
LOGV("processConfigEvents() remaining events %d", mConfigEvents.size());
ConfigEvent *configEvent = mConfigEvents[0];
mConfigEvents.removeAt(0);
- // release mLock because audioConfigChanged() will call
- // Audioflinger::audioConfigChanged() which locks AudioFlinger mLock thus creating
+ // release mLock because audioConfigChanged() will lock AudioFlinger mLock
+ // before calling Audioflinger::audioConfigChanged_l() thus creating
// potential cross deadlock between AudioFlinger::mLock and mLock
mLock.unlock();
audioConfigChanged(configEvent->mEvent, configEvent->mParam);
@@ -1118,7 +1118,8 @@ void AudioFlinger::PlaybackThread::audioConfigChanged(int event, int param) {
default:
break;
}
- mAudioFlinger->audioConfigChanged(event, this, param2);
+ Mutex::Autolock _l(mAudioFlinger->mLock);
+ mAudioFlinger->audioConfigChanged_l(event, this, param2);
}
void AudioFlinger::PlaybackThread::readOutputParameters()
@@ -1239,7 +1240,7 @@ bool AudioFlinger::MixerThread::threadLoop()
// active tracks were late. Sleep a little bit to give
// them another chance. If we're too late, write 0s to audio
// hardware to avoid underrun.
- if (sleepTime < kMaxBufferRecoveryInUsecs) {
+ if (mBytesWritten == 0 || sleepTime < kMaxBufferRecoveryInUsecs) {
usleep(kBufferRecoveryInUsecs);
} else {
memset (curBuf, 0, mixBufferSize);
@@ -1272,8 +1273,6 @@ bool AudioFlinger::MixerThread::threadLoop()
if (!mStandby) {
mOutput->standby();
}
- sendConfigEvent(AudioSystem::OUTPUT_CLOSED);
- processConfigEvents();
LOGV("MixerThread %p exiting", this);
return false;
@@ -1741,7 +1740,8 @@ bool AudioFlinger::DirectOutputThread::threadLoop()
standbyTime = systemTime() + kStandbyTimeInNsecs;
} else {
sleepTime += kBufferRecoveryInUsecs;
- if (sleepTime < kMaxBufferRecoveryInUsecs) {
+ if (mBytesWritten == 0 || !AudioSystem::isLinearPCM(mFormat) ||
+ sleepTime < kMaxBufferRecoveryInUsecs) {
usleep(kBufferRecoveryInUsecs);
} else {
memset (mMixBuffer, 0, mFrameCount * mFrameSize);
@@ -1771,8 +1771,6 @@ bool AudioFlinger::DirectOutputThread::threadLoop()
if (!mStandby) {
mOutput->standby();
}
- sendConfigEvent(AudioSystem::OUTPUT_CLOSED);
- processConfigEvents();
LOGV("DirectOutputThread %p exiting", this);
return false;
@@ -1964,9 +1962,6 @@ bool AudioFlinger::DuplicatingThread::threadLoop()
}
}
- sendConfigEvent(AudioSystem::OUTPUT_CLOSED);
- processConfigEvents();
-
return false;
}
@@ -3046,9 +3041,6 @@ bool AudioFlinger::RecordThread::threadLoop()
}
mActiveTrack.clear();
- sendConfigEvent(AudioSystem::INPUT_CLOSED);
- processConfigEvents();
-
LOGV("RecordThread %p exiting", this);
return false;
}
@@ -3233,7 +3225,8 @@ void AudioFlinger::RecordThread::audioConfigChanged(int event, int param) {
default:
break;
}
- mAudioFlinger->audioConfigChanged(event, this, param2);
+ Mutex::Autolock _l(mAudioFlinger->mLock);
+ mAudioFlinger->audioConfigChanged_l(event, this, param2);
}
void AudioFlinger::RecordThread::readInputParameters()
@@ -3378,6 +3371,8 @@ status_t AudioFlinger::closeOutput(int output)
}
}
}
+ void *param2 = 0;
+ audioConfigChanged_l(AudioSystem::OUTPUT_CLOSED, thread, param2);
mPlaybackThreads.removeItem(output);
}
thread->exit();
@@ -3497,6 +3492,8 @@ status_t AudioFlinger::closeInput(int input)
}
LOGV("closeInput() %d", input);
+ void *param2 = 0;
+ audioConfigChanged_l(AudioSystem::INPUT_CLOSED, thread, param2);
mRecordThreads.removeItem(input);
}
thread->exit();
diff --git a/libs/audioflinger/AudioFlinger.h b/libs/audioflinger/AudioFlinger.h
index 65c148e..7a6641f 100644
--- a/libs/audioflinger/AudioFlinger.h
+++ b/libs/audioflinger/AudioFlinger.h
@@ -616,7 +616,7 @@ private:
MixerThread *checkMixerThread_l(int output) const;
RecordThread *checkRecordThread_l(int input) const;
float streamVolumeInternal(int stream) const { return mStreamTypes[stream].volume; }
- void audioConfigChanged(int event, const sp<ThreadBase>& thread, void *param2);
+ void audioConfigChanged_l(int event, const sp<ThreadBase>& thread, void *param2);
friend class AudioBuffer;
diff --git a/libs/surfaceflinger/Buffer.cpp b/libs/surfaceflinger/Buffer.cpp
index 4a7c55e..65650aa 100644
--- a/libs/surfaceflinger/Buffer.cpp
+++ b/libs/surfaceflinger/Buffer.cpp
@@ -106,6 +106,9 @@ status_t Buffer::initSize(uint32_t w, uint32_t h, PixelFormat format,
// the requested flags should be honored.
usage = reqUsage | BufferAllocator::USAGE_HW_TEXTURE;
}
+
+ if (format == PIXEL_FORMAT_RGBX_8888)
+ format = PIXEL_FORMAT_RGBA_8888;
err = allocator.alloc(w, h, format, usage, &handle, &stride);
if (err == NO_ERROR) {
diff --git a/libs/surfaceflinger/Layer.cpp b/libs/surfaceflinger/Layer.cpp
index 6275910..1e7f1e6 100644
--- a/libs/surfaceflinger/Layer.cpp
+++ b/libs/surfaceflinger/Layer.cpp
@@ -176,6 +176,9 @@ void Layer::reloadTexture(const Region& dirty)
// this failed, for instance, because we don't support
// NPOT.
// FIXME: do something!
+ LOGD("layer=%p, glEGLImageTargetTexture2DOES(%d) "
+ "failed err=0x%04x",
+ this, mTextures[index].image, error);
mFlags &= ~DisplayHardware::DIRECT_TEXTURE;
} else {
// Everything went okay!
diff --git a/libs/surfaceflinger/LayerBase.cpp b/libs/surfaceflinger/LayerBase.cpp
index 1f22488..e08861d 100644
--- a/libs/surfaceflinger/LayerBase.cpp
+++ b/libs/surfaceflinger/LayerBase.cpp
@@ -590,7 +590,8 @@ regular:
glTexImage2D(GL_TEXTURE_2D, 0,
GL_RGBA, texture_w, texture_h, 0,
GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4, data);
- } else if (t.format == GGL_PIXEL_FORMAT_RGBA_8888) {
+ } else if (t.format == GGL_PIXEL_FORMAT_RGBA_8888 ||
+ t.format == GGL_PIXEL_FORMAT_RGBX_8888) {
glTexImage2D(GL_TEXTURE_2D, 0,
GL_RGBA, texture_w, texture_h, 0,
GL_RGBA, GL_UNSIGNED_BYTE, data);
@@ -620,7 +621,8 @@ regular:
0, bounds.top, t.width, bounds.height(),
GL_RGBA, GL_UNSIGNED_SHORT_4_4_4_4,
t.data + bounds.top*t.stride*2);
- } else if (t.format == GGL_PIXEL_FORMAT_RGBA_8888) {
+ } else if (t.format == GGL_PIXEL_FORMAT_RGBA_8888 ||
+ t.format == GGL_PIXEL_FORMAT_RGBX_8888) {
glTexSubImage2D(GL_TEXTURE_2D, 0,
0, bounds.top, t.width, bounds.height(),
GL_RGBA, GL_UNSIGNED_BYTE,
diff --git a/libs/ui/Camera.cpp b/libs/ui/Camera.cpp
index 12a7725..0c6d340 100644
--- a/libs/ui/Camera.cpp
+++ b/libs/ui/Camera.cpp
@@ -242,6 +242,14 @@ status_t Camera::autoFocus()
return c->autoFocus();
}
+status_t Camera::cancelAutoFocus()
+{
+ LOGV("cancelAutoFocus");
+ sp <ICamera> c = mCamera;
+ if (c == 0) return NO_INIT;
+ return c->cancelAutoFocus();
+}
+
// take a picture
status_t Camera::takePicture()
{
diff --git a/libs/ui/ICamera.cpp b/libs/ui/ICamera.cpp
index 805c2ca..fd7e084 100644
--- a/libs/ui/ICamera.cpp
+++ b/libs/ui/ICamera.cpp
@@ -32,6 +32,7 @@ enum {
START_PREVIEW,
STOP_PREVIEW,
AUTO_FOCUS,
+ CANCEL_AUTO_FOCUS,
TAKE_PICTURE,
SET_PARAMETERS,
GET_PARAMETERS,
@@ -162,6 +163,17 @@ public:
return ret;
}
+ // cancel focus
+ status_t cancelAutoFocus()
+ {
+ LOGV("cancelAutoFocus");
+ Parcel data, reply;
+ data.writeInterfaceToken(ICamera::getInterfaceDescriptor());
+ remote()->transact(CANCEL_AUTO_FOCUS, data, &reply);
+ status_t ret = reply.readInt32();
+ return ret;
+ }
+
// take a picture - returns an IMemory (ref-counted mmap)
status_t takePicture()
{
@@ -294,6 +306,12 @@ status_t BnCamera::onTransact(
reply->writeInt32(autoFocus());
return NO_ERROR;
} break;
+ case CANCEL_AUTO_FOCUS: {
+ LOGV("CANCEL_AUTO_FOCUS");
+ CHECK_INTERFACE(ICamera, data, reply);
+ reply->writeInt32(cancelAutoFocus());
+ return NO_ERROR;
+ } break;
case TAKE_PICTURE: {
LOGV("TAKE_PICTURE");
CHECK_INTERFACE(ICamera, data, reply);