Merge "AudioFlinger: Split off audio processing library"
diff --git a/media/liboboe/include/oboe/OboeAudio.h b/media/liboboe/include/oboe/OboeAudio.h
index 788cf5f..2181b8c 100644
--- a/media/liboboe/include/oboe/OboeAudio.h
+++ b/media/liboboe/include/oboe/OboeAudio.h
@@ -372,7 +372,7 @@
*
* @param stream A stream created using OboeStreamBuilder_openStream().
* @param periodNanoseconds the estimated period at which the audio thread will need to wake up
- * @param start_routine your thread entry point
+ * @param startRoutine your thread entry point
* @param arg an argument that will be passed to your thread entry point
* @return OBOE_OK or a negative error.
*/
@@ -408,7 +408,7 @@
*
* @param stream handle provided by OboeStreamBuilder_openStream()
* @param requestedFrames requested number of frames that can be filled without blocking
- * @return actualFrames receives final number of frames
+ * @param actualFrames receives final number of frames
* @return OBOE_OK or a negative error
*/
OBOE_API oboe_result_t OboeStream_setBufferSize(OboeStream stream,
diff --git a/media/liboboe/src/utility/HandleTracker.h b/media/liboboe/src/utility/HandleTracker.h
index da5b654..37dbac8 100644
--- a/media/liboboe/src/utility/HandleTracker.h
+++ b/media/liboboe/src/utility/HandleTracker.h
@@ -53,7 +53,7 @@
/**
* Store a pointer and return a handle that can be used to retrieve the pointer.
*
- * @param type the type of the object to be tracked
+ * @param expectedType the type of the object to be tracked
* @param address pointer to be converted to a handle
* @return a valid handle or a negative error
*/
diff --git a/media/mtp/MtpFfsHandle.cpp b/media/mtp/MtpFfsHandle.cpp
index 10314e9..d11a10d 100644
--- a/media/mtp/MtpFfsHandle.cpp
+++ b/media/mtp/MtpFfsHandle.cpp
@@ -38,6 +38,8 @@
#define cpu_to_le16(x) htole16(x)
#define cpu_to_le32(x) htole32(x)
+#define FUNCTIONFS_ENDPOINT_ALLOC _IOR('g', 131, __u32)
+
namespace {
constexpr char FFS_MTP_EP_IN[] = "/dev/usb-ffs/mtp/ep1";
@@ -467,6 +469,24 @@
mLock.unlock();
}
+class ScopedEndpointBufferAlloc {
+private:
+ const int mFd;
+ const unsigned int mAllocSize;
+public:
+ ScopedEndpointBufferAlloc(int fd, unsigned alloc_size) :
+ mFd(fd),
+ mAllocSize(alloc_size) {
+ if (ioctl(mFd, FUNCTIONFS_ENDPOINT_ALLOC, static_cast<__u32>(mAllocSize)))
+ PLOG(DEBUG) << "FFS endpoint alloc failed!";
+ }
+
+ ~ScopedEndpointBufferAlloc() {
+ if (ioctl(mFd, FUNCTIONFS_ENDPOINT_ALLOC, static_cast<__u32>(0)))
+ PLOG(DEBUG) << "FFS endpoint alloc reset failed!";
+ }
+};
+
/* Read from USB and write to a local file. */
int MtpFfsHandle::receiveFile(mtp_file_range mfr) {
// When receiving files, the incoming length is given in 32 bits.
@@ -494,6 +514,7 @@
bool write = false;
posix_fadvise(mfr.fd, 0, 0, POSIX_FADV_SEQUENTIAL | POSIX_FADV_NOREUSE);
+ ScopedEndpointBufferAlloc(mBulkOut, mMaxRead);
// Break down the file into pieces that fit in buffers
while (file_length > 0 || write) {
@@ -609,6 +630,8 @@
if (writeHandle(mBulkIn, data, packet_size) == -1) return -1;
if (file_length == 0) return 0;
+ ScopedEndpointBufferAlloc(mBulkIn, mMaxWrite);
+
// Break down the file into pieces that fit in buffers
while(file_length > 0) {
if (read) {