CameraHardwareStub::CameraHardwareStub()
: mParameters(),
- mPreviewHeap(0),
- mRawHeap(0),
+ mHeap(0),
mFakeCamera(0),
mPreviewFrameSize(0),
mRawPictureCallback(0),
void CameraHardwareStub::initHeapLocked()
{
- // Create raw heap.
- int picture_width, picture_height;
- mParameters.getPictureSize(&picture_width, &picture_height);
- mRawHeap = new MemoryHeapBase(picture_width * 2 * picture_height);
+ int width, height;
+ mParameters.getPreviewSize(&width, &height);
- int preview_width, preview_height;
- mParameters.getPreviewSize(&preview_width, &preview_height);
- LOGD("initHeapLocked: preview size=%dx%d", preview_width, preview_height);
+ LOGD("initHeapLocked: preview size=%dx%d", width, height);
// Note that we enforce yuv422 in setParameters().
- int how_big = preview_width * preview_height * 2;
+ int how_big = width * height * 2;
// If we are being reinitialized to the same size as before, no
// work needs to be done.
// Make a new mmap'ed heap that can be shared across processes.
// use code below to test with pmem
- mPreviewHeap = new MemoryHeapBase(mPreviewFrameSize * kBufferCount);
+ mHeap = new MemoryHeapBase(mPreviewFrameSize * kBufferCount);
// Make an IMemory for each frame so that we can reuse them in callbacks.
for (int i = 0; i < kBufferCount; i++) {
- mBuffers[i] = new MemoryBase(mPreviewHeap, i * mPreviewFrameSize, mPreviewFrameSize);
+ mBuffers[i] = new MemoryBase(mHeap, i * mPreviewFrameSize, mPreviewFrameSize);
}
-
+
// Recreate the fake camera to reflect the current size.
delete mFakeCamera;
- mFakeCamera = new FakeCamera(preview_width, preview_height);
+ mFakeCamera = new FakeCamera(width, height);
}
CameraHardwareStub::~CameraHardwareStub()
sp<IMemoryHeap> CameraHardwareStub::getPreviewHeap() const
{
- return mPreviewHeap;
-}
-
-sp<IMemoryHeap> CameraHardwareStub::getRawHeap() const
-{
- return mRawHeap;
+ return mHeap;
}
// ---------------------------------------------------------------------------
// Find the offset within the heap of the current buffer.
ssize_t offset = mCurrentPreviewFrame * mPreviewFrameSize;
- sp<MemoryHeapBase> heap = mPreviewHeap;
+ sp<MemoryHeapBase> heap = mHeap;
// this assumes the internal state of fake camera doesn't change
// (or is thread safe)
// In the meantime just make another fake camera picture.
int w, h;
mParameters.getPictureSize(&w, &h);
- sp<MemoryBase> mem = new MemoryBase(mRawHeap, 0, w * 2 * h);
+ sp<MemoryHeapBase> heap = new MemoryHeapBase(w * 2 * h);
+ sp<MemoryBase> mem = new MemoryBase(heap, 0, w * 2 * h);
FakeCamera cam(w, h);
- cam.getNextFrameAsYuv422((uint8_t *)mRawHeap->base());
+ cam.getNextFrameAsYuv422((uint8_t *)heap->base());
if (mRawPictureCallback)
mRawPictureCallback(mem, mPictureCallbackCookie);
}
class CameraHardwareStub : public CameraHardwareInterface {
public:
virtual sp<IMemoryHeap> getPreviewHeap() const;
- virtual sp<IMemoryHeap> getRawHeap() const;
virtual status_t startPreview(preview_callback cb, void* user);
virtual void stopPreview();
CameraParameters mParameters;
- sp<MemoryHeapBase> mPreviewHeap;
- sp<MemoryHeapBase> mRawHeap;
+ sp<MemoryHeapBase> mHeap;
sp<MemoryBase> mBuffers[kBufferCount];
FakeCamera *mFakeCamera;
}
CameraService::Client::Client(const sp<CameraService>& cameraService,
- const sp<ICameraClient>& cameraClient, pid_t clientPid)
+ const sp<ICameraClient>& cameraClient, pid_t clientPid)
{
LOGD("Client E constructor");
mCameraService = cameraService;
ret = mHardware->startPreview(NULL, mCameraService.get());
if (ret != NO_ERROR)
LOGE("mHardware->startPreview() failed with status %d\n", ret);
-
+
} else {
ret = mHardware->startPreview(previewCallback,
mCameraService.get());
return INVALID_OPERATION;
}
+ if (mSurface != NULL && !mUseOverlay)
+ mSurface->unregisterBuffers();
- Mutex::Autolock buffer_lock(mBufferLock);
- result = mHardware->takePicture(shutterCallback,
+ return mHardware->takePicture(shutterCallback,
yuvPictureCallback,
jpegPictureCallback,
mCameraService.get());
-
- // It takes quite some time before yuvPicture callback to be called.
- // Register the buffer for raw image here to reduce latency.
- // But yuvPictureCallback is called from libcamera. So do not call into a
- // libcamera function here that gets another lock, which may cause deadlock.
- if (mSurface != 0 && !mUseOverlay) {
- int w, h;
- CameraParameters params(mHardware->getParameters());
- params.getPictureSize(&w, &h);
- mSurface->unregisterBuffers();
- uint32_t transform = 0;
- if (params.getOrientation() == CameraParameters::CAMERA_ORIENTATION_PORTRAIT) {
- LOGV("portrait mode");
- transform = ISurface::BufferHeap::ROT_90;
- }
- ISurface::BufferHeap buffers(w, h, w, h,
- PIXEL_FORMAT_YCbCr_420_SP, transform, 0, mHardware->getRawHeap());
- mSurface->registerBuffers(buffers);
- }
-
- return result;
}
// picture callback - snapshot taken
#endif
// Put the YUV version of the snapshot in the preview display.
- // Use lock to make sure buffer has been registered.
- Mutex::Autolock clientLock(client->mBufferLock);
+ int w, h;
+ CameraParameters params(client->mHardware->getParameters());
+ params.getPictureSize(&w, &h);
+
+// Mutex::Autolock clientLock(client->mLock);
if (client->mSurface != 0 && !client->mUseOverlay) {
+ client->mSurface->unregisterBuffers();
+
+ uint32_t transform = 0;
+ if (params.getOrientation() == CameraParameters::CAMERA_ORIENTATION_PORTRAIT) {
+ LOGV("portrait mode");
+ transform = ISurface::BufferHeap::ROT_90;
+ }
+ ISurface::BufferHeap buffers(w, h, w, h,
+ PIXEL_FORMAT_YCbCr_420_SP, transform, 0, heap);
+
+ client->mSurface->registerBuffers(buffers);
client->mSurface->postBuffer(offset);
}
// for a callback from CameraHardwareInterface. If this
// happens, it will cause a deadlock.
mutable Mutex mSurfaceLock;
- // mBufferLock synchronizes buffer registration between takePicture()
- // and yuvPictureCallback().
- mutable Mutex mBufferLock;
mutable Condition mReady;
sp<CameraService> mCameraService;
sp<ISurface> mSurface;
/** Return the IMemoryHeap for the preview image heap */
virtual sp<IMemoryHeap> getPreviewHeap() const = 0;
- /** Return the IMemoryHeap for the raw image heap */
- virtual sp<IMemoryHeap> getRawHeap() const = 0;
-
/**
* Start preview mode. When a preview image is available
* preview_callback is called with the user parameter. The
return false;
}
- // Return true if 'this' can be considered a match for the parameters in
+ // Return true if 'this' can be considered a match for the parameters in
// 'settings'.
- // Note this is asymetric. A default piece of data will match every request
- // but a request for the default should not match odd specifics
- // (ie, request with no mcc should not match a particular mcc's data)
- // settings is the requested settings
inline bool match(const ResTable_config& settings) const {
if (imsi != 0) {
- if ((settings.mcc != 0 && mcc != 0
- && mcc != settings.mcc) ||
- (settings.mcc == 0 && mcc != 0)) {
+ if (settings.mcc != 0 && mcc != 0
+ && mcc != settings.mcc) {
return false;
}
- if ((settings.mnc != 0 && mnc != 0
- && mnc != settings.mnc) ||
- (settings.mnc == 0 && mnc != 0)) {
+ if (settings.mnc != 0 && mnc != 0
+ && mnc != settings.mnc) {
return false;
}
}
// ----------------------------------------------------------------------------
A2dpAudioInterface::A2dpAudioStreamOut::A2dpAudioStreamOut() :
- mFd(-1), mStandby(true), mStartCount(0), mRetryCount(0), mData(NULL)
+ mFd(-1), mStandby(true), mStartCount(0), mRetryCount(0), mData(NULL),
+ mInitialized(false)
{
// use any address by default
strncpy(mA2dpAddress, "00:00:00:00:00:00", sizeof(mA2dpAddress));
status_t status = NO_INIT;
size_t remaining = bytes;
- if (!mData) {
- status = a2dp_init(44100, 2, &mData);
+ if (!mInitialized) {
+ status = a2dp_init(mA2dpAddress, 44100, 2, &mData);
if (status < 0) {
LOGE("a2dp_init failed err: %d\n", status);
- mData = NULL;
goto Error;
}
- a2dp_set_sink(mData, mA2dpAddress);
+ mInitialized = true;
}
while (remaining > 0) {
return bytes;
Error:
+ close();
// Simulate audio output timing in case of error
usleep(bytes * 1000000 / frameSize() / sampleRate());
if (strcmp(address, mA2dpAddress)) {
strcpy(mA2dpAddress, address);
- if (mData)
- a2dp_set_sink(mData, mA2dpAddress);
+ close();
}
return NO_ERROR;
if (mData) {
a2dp_cleanup(mData);
mData = NULL;
+ mInitialized = false;
}
return NO_ERROR;
}
int mRetryCount;
char mA2dpAddress[20];
void* mData;
+ bool mInitialized;
};
Mutex mLock;
} 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()
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;
}
enum track_flags {
STEPSERVER_FAILED = 0x01, // StepServer could not acquire cblk->lock mutex
SYSTEM_FLAGS_MASK = 0x0000ffffUL,
- // The upper 16 bits are used for track-specific flags.
+
+ 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
};
TrackBase(const sp<MixerThread>& mixerThread,
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 20; }
+ virtual uint32_t latency() const { return 0; }
virtual status_t setVolume(float volume) { return INVALID_OPERATION; }
virtual ssize_t write(const void* buffer, size_t bytes);
virtual status_t standby();
if (c->mCamera != 0) {
c->mCamera->asBinder()->linkToDeath(c);
c->mStatus = NO_ERROR;
- } else {
- c.clear();
}
return c;
}
{
mLock.lock();
if (mNumReaders == 0) {
- mLock.unlock();
LOG(LOG_WARN, "thread",
"WARNING: unlockForRead requested, but not locked\n");
return;
{
mLock.lock();
if (mNumWriters == 0) {
- mLock.unlock();
LOG(LOG_WARN, "thread",
"WARNING: unlockForWrite requested, but not locked\n");
return;
//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();
// ----------------------------------------------------------------------------
-#define VERSION_MAJOR 1
-#define VERSION_MINOR 2
static char const * const gVendorString = "Google Inc.";
static char const * const gVersionString = "1.2 Android Driver";
static char const * const gClientApiString = "OpenGL ES";
}
if (res == EGL_TRUE) {
- if (major != NULL) *major = VERSION_MAJOR;
- if (minor != NULL) *minor = VERSION_MINOR;
+ if (major != NULL) *major = 1;
+ if (minor != NULL) *minor = 2;
}
return res;
}
namespace android {
// ----------------------------------------------------------------------------
-#define VERSION_MAJOR 1
-#define VERSION_MINOR 4
+#define VERSION_MINOR 1
+#define VERSION_MAJOR 4
static char const * const gVendorString = "Android";
static char const * const gVersionString = "1.31 Android META-EGL";
static char const * const gClientApiString = "OpenGL ES";
}
if (res == EGL_TRUE) {
- if (major != NULL) *major = VERSION_MAJOR;
- if (minor != NULL) *minor = VERSION_MINOR;
+ if (major != NULL) *major = 1;
+ if (minor != NULL) *minor = 2;
return EGL_TRUE;
}
return setError(EGL_NOT_INITIALIZED, EGL_FALSE);