diff options
Diffstat (limited to 'libs')
-rw-r--r-- | libs/audioflinger/AudioFlinger.cpp | 7 | ||||
-rw-r--r-- | libs/surfaceflinger/LayerScreenshot.cpp | 110 | ||||
-rw-r--r-- | libs/surfaceflinger/SurfaceFlinger.cpp | 1 | ||||
-rw-r--r-- | libs/utils/Parcel.cpp | 5 | ||||
-rw-r--r-- | libs/utils/ZipFile.cpp | 202 |
5 files changed, 221 insertions, 104 deletions
diff --git a/libs/audioflinger/AudioFlinger.cpp b/libs/audioflinger/AudioFlinger.cpp index b56221f..a4050b3 100644 --- a/libs/audioflinger/AudioFlinger.cpp +++ b/libs/audioflinger/AudioFlinger.cpp @@ -652,6 +652,7 @@ status_t AudioFlinger::setStreamVolume(int stream, float value) } status_t ret = NO_ERROR; + if (stream == AudioSystem::VOICE_CALL || stream == AudioSystem::BLUETOOTH_SCO) { float hwValue; @@ -668,7 +669,13 @@ status_t AudioFlinger::setStreamVolume(int stream, float value) mHardwareStatus = AUDIO_SET_VOICE_VOLUME; ret = mAudioHardware->setVoiceVolume(hwValue); mHardwareStatus = AUDIO_HW_IDLE; + } + + mHardwareMixerThread->setStreamVolume(stream, value); +#ifdef WITH_A2DP + mA2dpMixerThread->setStreamVolume(stream, value); +#endif mHardwareMixerThread->setStreamVolume(stream, value); #ifdef WITH_A2DP diff --git a/libs/surfaceflinger/LayerScreenshot.cpp b/libs/surfaceflinger/LayerScreenshot.cpp new file mode 100644 index 0000000..fb7b585 --- /dev/null +++ b/libs/surfaceflinger/LayerScreenshot.cpp @@ -0,0 +1,110 @@ +/* + * Copyright (C) 2007 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define LOG_TAG "SurfaceFlinger" + +#include <stdlib.h> +#include <stdint.h> +#include <sys/types.h> + +#include <utils/Errors.h> +#include <utils/Log.h> + +#include <core/SkBitmap.h> + +#include <ui/EGLDisplaySurface.h> + +#include "LayerBase.h" +#include "LayerScreenshot.h" +#include "SurfaceFlinger.h" +#include "DisplayHardware/DisplayHardware.h" + +namespace android { +// --------------------------------------------------------------------------- + +const uint32_t LayerScreenshot::typeInfo = LayerBase::typeInfo | 0x20; +const char* const LayerScreenshot::typeID = "LayerScreenshot"; + +// --------------------------------------------------------------------------- + +LayerScreenshot::LayerScreenshot(SurfaceFlinger* flinger, DisplayID display) + : LayerBase(flinger, display), mReply(0) +{ +} + +LayerScreenshot::~LayerScreenshot() +{ +} + +void LayerScreenshot::onDraw(const Region& clip) const +{ + const DisplayHardware& hw(graphicPlane(0).displayHardware()); + copybit_image_t dst; + hw.getDisplaySurface(&dst); + if (dst.base != 0) { + uint8_t const* src = (uint8_t const*)(intptr_t(dst.base) + dst.offset); + const int fbWidth = dst.w; + const int fbHeight = dst.h; + const int fbFormat = dst.format; + + int x = mTransformedBounds.left; + int y = mTransformedBounds.top; + int w = mTransformedBounds.width(); + int h = mTransformedBounds.height(); + Parcel* const reply = mReply; + if (reply) { + const size_t Bpp = bytesPerPixel(fbFormat); + const size_t size = w * h * Bpp; + int32_t cfg = SkBitmap::kNo_Config; + switch (fbFormat) { + case PIXEL_FORMAT_RGBA_4444: cfg = SkBitmap::kARGB_4444_Config; break; + case PIXEL_FORMAT_RGBA_8888: cfg = SkBitmap::kARGB_8888_Config; break; + case PIXEL_FORMAT_RGB_565: cfg = SkBitmap::kRGB_565_Config; break; + case PIXEL_FORMAT_A_8: cfg = SkBitmap::kA8_Config; break; + } + reply->writeInt32(0); + reply->writeInt32(cfg); + reply->writeInt32(w); + reply->writeInt32(h); + reply->writeInt32(w * Bpp); + void* data = reply->writeInplace(size); + if (data) { + uint8_t* d = (uint8_t*)data; + uint8_t const* s = src + (x + y*fbWidth) * Bpp; + if (w == fbWidth) { + memcpy(d, s, w*h*Bpp); + } else { + for (int y=0 ; y<h ; y++) { + memcpy(d, s, w*Bpp); + d += w*Bpp; + s += fbWidth*Bpp; + } + } + } + } + } + mCV.broadcast(); +} + +void LayerScreenshot::takeScreenshot(Mutex& lock, Parcel* reply) +{ + mReply = reply; + mCV.wait(lock); +} + +// --------------------------------------------------------------------------- + +}; // namespace android diff --git a/libs/surfaceflinger/SurfaceFlinger.cpp b/libs/surfaceflinger/SurfaceFlinger.cpp index 167a59b..54b33ce 100644 --- a/libs/surfaceflinger/SurfaceFlinger.cpp +++ b/libs/surfaceflinger/SurfaceFlinger.cpp @@ -23,6 +23,7 @@ #include <fcntl.h> #include <errno.h> #include <math.h> +#include <limits.h> #include <sys/types.h> #include <sys/stat.h> #include <sys/ioctl.h> diff --git a/libs/utils/Parcel.cpp b/libs/utils/Parcel.cpp index 0f4b647..4225e67 100644 --- a/libs/utils/Parcel.cpp +++ b/libs/utils/Parcel.cpp @@ -950,14 +950,13 @@ native_handle* Parcel::readNativeHandle(native_handle* (*alloc)(void*, int, int) return 0; } } - for (int i=0 ; err==NO_ERROR && i<numFds ; i++) { h->data[i] = dup(readFileDescriptor()); if (h->data[i] < 0) err = BAD_VALUE; } - + err = read(h->data + numFds, sizeof(int)*numInts); - + if (err != NO_ERROR) { if (alloc == 0) { free(h); diff --git a/libs/utils/ZipFile.cpp b/libs/utils/ZipFile.cpp index 89aa874..2132d22 100644 --- a/libs/utils/ZipFile.cpp +++ b/libs/utils/ZipFile.cpp @@ -94,10 +94,10 @@ status_t ZipFile::open(const char* zipFileName, int flags) } mZipFp = fopen(zipFileName, openflags); if (mZipFp == NULL) { - int err = errno; - LOGD("fopen failed: %d\n", err); + int err = errno; + LOGD("fopen failed: %d\n", err); return errnoToStatus(err); - } + } status_t result; if (!newArchive) { @@ -221,8 +221,8 @@ status_t ZipFile::readCentralDir(void) buf = new unsigned char[EndOfCentralDir::kMaxEOCDSearch]; if (buf == NULL) { - LOGD("Failure allocating %d bytes for EOCD search", - EndOfCentralDir::kMaxEOCDSearch); + LOGD("Failure allocating %d bytes for EOCD search", + EndOfCentralDir::kMaxEOCDSearch); result = NO_MEMORY; goto bail; } @@ -235,7 +235,7 @@ status_t ZipFile::readCentralDir(void) readAmount = (long) fileLength; } if (fseek(mZipFp, seekStart, SEEK_SET) != 0) { - LOGD("Failure seeking to end of zip at %ld", (long) seekStart); + LOGD("Failure seeking to end of zip at %ld", (long) seekStart); result = UNKNOWN_ERROR; goto bail; } @@ -265,9 +265,9 @@ status_t ZipFile::readCentralDir(void) /* extract eocd values */ result = mEOCD.readBuf(buf + i, readAmount - i); if (result != NO_ERROR) { - LOGD("Failure reading %ld bytes of EOCD values", readAmount - i); + LOGD("Failure reading %ld bytes of EOCD values", readAmount - i); goto bail; - } + } //mEOCD.dump(); if (mEOCD.mDiskNumber != 0 || mEOCD.mDiskWithCentralDir != 0 || @@ -293,8 +293,8 @@ status_t ZipFile::readCentralDir(void) * we're hoping to preserve. */ if (fseek(mZipFp, mEOCD.mCentralDirOffset, SEEK_SET) != 0) { - LOGD("Failure seeking to central dir offset %ld\n", - mEOCD.mCentralDirOffset); + LOGD("Failure seeking to central dir offset %ld\n", + mEOCD.mCentralDirOffset); result = UNKNOWN_ERROR; goto bail; } @@ -743,61 +743,61 @@ status_t ZipFile::compressFpToFp(FILE* dstFp, FILE* srcFp, const void* data, size_t size, unsigned long* pCRC32) { status_t result = NO_ERROR; - const size_t kBufSize = 32768; - unsigned char* inBuf = NULL; - unsigned char* outBuf = NULL; - z_stream zstream; + const size_t kBufSize = 32768; + unsigned char* inBuf = NULL; + unsigned char* outBuf = NULL; + z_stream zstream; bool atEof = false; // no feof() aviailable yet - unsigned long crc; - int zerr; - - /* - * Create an input buffer and an output buffer. - */ - inBuf = new unsigned char[kBufSize]; - outBuf = new unsigned char[kBufSize]; - if (inBuf == NULL || outBuf == NULL) { - result = NO_MEMORY; - goto bail; - } - - /* - * Initialize the zlib stream. - */ - memset(&zstream, 0, sizeof(zstream)); - zstream.zalloc = Z_NULL; - zstream.zfree = Z_NULL; - zstream.opaque = Z_NULL; - zstream.next_in = NULL; - zstream.avail_in = 0; - zstream.next_out = outBuf; - zstream.avail_out = kBufSize; - zstream.data_type = Z_UNKNOWN; - - zerr = deflateInit2(&zstream, Z_BEST_COMPRESSION, - Z_DEFLATED, -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY); - if (zerr != Z_OK) { - result = UNKNOWN_ERROR; - if (zerr == Z_VERSION_ERROR) { - LOGE("Installed zlib is not compatible with linked version (%s)\n", - ZLIB_VERSION); - } else { - LOGD("Call to deflateInit2 failed (zerr=%d)\n", zerr); - } - goto bail; - } - - crc = crc32(0L, Z_NULL, 0); - - /* - * Loop while we have data. - */ - do { - size_t getSize; - int flush; - - /* only read if the input buffer is empty */ - if (zstream.avail_in == 0 && !atEof) { + unsigned long crc; + int zerr; + + /* + * Create an input buffer and an output buffer. + */ + inBuf = new unsigned char[kBufSize]; + outBuf = new unsigned char[kBufSize]; + if (inBuf == NULL || outBuf == NULL) { + result = NO_MEMORY; + goto bail; + } + + /* + * Initialize the zlib stream. + */ + memset(&zstream, 0, sizeof(zstream)); + zstream.zalloc = Z_NULL; + zstream.zfree = Z_NULL; + zstream.opaque = Z_NULL; + zstream.next_in = NULL; + zstream.avail_in = 0; + zstream.next_out = outBuf; + zstream.avail_out = kBufSize; + zstream.data_type = Z_UNKNOWN; + + zerr = deflateInit2(&zstream, Z_BEST_COMPRESSION, + Z_DEFLATED, -MAX_WBITS, DEF_MEM_LEVEL, Z_DEFAULT_STRATEGY); + if (zerr != Z_OK) { + result = UNKNOWN_ERROR; + if (zerr == Z_VERSION_ERROR) { + LOGE("Installed zlib is not compatible with linked version (%s)\n", + ZLIB_VERSION); + } else { + LOGD("Call to deflateInit2 failed (zerr=%d)\n", zerr); + } + goto bail; + } + + crc = crc32(0L, Z_NULL, 0); + + /* + * Loop while we have data. + */ + do { + size_t getSize; + int flush; + + /* only read if the input buffer is empty */ + if (zstream.avail_in == 0 && !atEof) { LOGV("+++ reading %d bytes\n", (int)kBufSize); if (data) { getSize = size > kBufSize ? kBufSize : size; @@ -817,54 +817,54 @@ status_t ZipFile::compressFpToFp(FILE* dstFp, FILE* srcFp, atEof = true; } - crc = crc32(crc, inBuf, getSize); - - zstream.next_in = inBuf; - zstream.avail_in = getSize; - } - - if (atEof) - flush = Z_FINISH; /* tell zlib that we're done */ - else - flush = Z_NO_FLUSH; /* more to come! */ - - zerr = deflate(&zstream, flush); - if (zerr != Z_OK && zerr != Z_STREAM_END) { - LOGD("zlib deflate call failed (zerr=%d)\n", zerr); - result = UNKNOWN_ERROR; - goto z_bail; - } - - /* write when we're full or when we're done */ - if (zstream.avail_out == 0 || - (zerr == Z_STREAM_END && zstream.avail_out != (uInt) kBufSize)) - { - LOGV("+++ writing %d bytes\n", (int) (zstream.next_out - outBuf)); + crc = crc32(crc, inBuf, getSize); + + zstream.next_in = inBuf; + zstream.avail_in = getSize; + } + + if (atEof) + flush = Z_FINISH; /* tell zlib that we're done */ + else + flush = Z_NO_FLUSH; /* more to come! */ + + zerr = deflate(&zstream, flush); + if (zerr != Z_OK && zerr != Z_STREAM_END) { + LOGD("zlib deflate call failed (zerr=%d)\n", zerr); + result = UNKNOWN_ERROR; + goto z_bail; + } + + /* write when we're full or when we're done */ + if (zstream.avail_out == 0 || + (zerr == Z_STREAM_END && zstream.avail_out != (uInt) kBufSize)) + { + LOGV("+++ writing %d bytes\n", (int) (zstream.next_out - outBuf)); if (fwrite(outBuf, 1, zstream.next_out - outBuf, dstFp) != (size_t)(zstream.next_out - outBuf)) { - LOGD("write %d failed in deflate\n", + LOGD("write %d failed in deflate\n", (int) (zstream.next_out - outBuf)); - goto z_bail; - } + goto z_bail; + } - zstream.next_out = outBuf; - zstream.avail_out = kBufSize; - } - } while (zerr == Z_OK); + zstream.next_out = outBuf; + zstream.avail_out = kBufSize; + } + } while (zerr == Z_OK); - assert(zerr == Z_STREAM_END); /* other errors should've been caught */ + assert(zerr == Z_STREAM_END); /* other errors should've been caught */ - *pCRC32 = crc; + *pCRC32 = crc; z_bail: - deflateEnd(&zstream); /* free up any allocated structures */ + deflateEnd(&zstream); /* free up any allocated structures */ bail: - delete[] inBuf; - delete[] outBuf; + delete[] inBuf; + delete[] outBuf; - return result; + return result; } /* @@ -1206,7 +1206,7 @@ bail: /* * =========================================================================== - * ZipFile::EndOfCentralDir + * ZipFile::EndOfCentralDir * =========================================================================== */ |