Android-x86
Fork
Faire un don

  • R/O
  • HTTP
  • SSH
  • HTTPS

hardware-interfaces: Commit

hardware/interfaces


Commit MetaInfo

Révision0f65d6e38ab531af1a090d01fc7c4c04a46484bc (tree)
l'heure2017-10-11 08:43:35
AuteurTreeHugger Robot <treehugger-gerrit@goog...>
CommiterAndroid (Google) Code Review

Message de Log

Merge "Legacy wrapper: Use arbitrary limit on buffer size" into oc-mr1-dev

Change Summary

Modification

--- a/audio/2.0/default/Stream.h
+++ b/audio/2.0/default/Stream.h
@@ -49,6 +49,13 @@ using ::android::sp;
4949 struct Stream : public IStream, public ParametersUtil {
5050 explicit Stream(audio_stream_t* stream);
5151
52+ /** 1GiB is the maximum buffer size the HAL client is allowed to request.
53+ * This value has been chosen to be under SIZE_MAX and still big enough
54+ * for all audio use case.
55+ * Keep private for 2.0, put in .hal in 2.1
56+ */
57+ static constexpr uint32_t MAX_BUFFER_SIZE = 2 << 30 /* == 1GiB */;
58+
5259 // Methods from ::android::hardware::audio::V2_0::IStream follow.
5360 Return<uint64_t> getFrameSize() override;
5461 Return<uint64_t> getFrameCount() override;
--- a/audio/2.0/default/StreamIn.cpp
+++ b/audio/2.0/default/StreamIn.cpp
@@ -347,14 +347,10 @@ Return<void> StreamIn::prepareForReading(uint32_t frameSize,
347347 sendError(Result::INVALID_ARGUMENTS);
348348 return Void();
349349 }
350- // A message queue asserts if it can not handle the requested buffer,
351- // thus the client has to guess the maximum size it can handle
352- // Choose an arbitrary margin for the overhead of a message queue
353- size_t metadataOverhead = 100000;
354- if (frameSize >
355- (std::numeric_limits<size_t>::max() - metadataOverhead) / framesCount) {
356- ALOGE("Buffer too big: %u*%u bytes can not fit in a message queue",
357- frameSize, framesCount);
350+
351+ if (frameSize > Stream::MAX_BUFFER_SIZE / framesCount) {
352+ ALOGE("Buffer too big: %u*%u bytes > MAX_BUFFER_SIZE (%u)", frameSize, framesCount,
353+ Stream::MAX_BUFFER_SIZE);
358354 sendError(Result::INVALID_ARGUMENTS);
359355 return Void();
360356 }
--- a/audio/2.0/default/StreamOut.cpp
+++ b/audio/2.0/default/StreamOut.cpp
@@ -323,14 +323,9 @@ Return<void> StreamOut::prepareForWriting(uint32_t frameSize,
323323 sendError(Result::INVALID_ARGUMENTS);
324324 return Void();
325325 }
326- // A message queue asserts if it can not handle the requested buffer,
327- // thus the client has to guess the maximum size it can handle
328- size_t metadataOverhead =
329- 100000; // Arbitrary margin for the overhead of a message queue
330- if (frameSize >
331- (std::numeric_limits<size_t>::max() - metadataOverhead) / framesCount) {
332- ALOGE("Buffer too big: %u*%u bytes can not fit in a message queue",
333- frameSize, framesCount);
326+ if (frameSize > Stream::MAX_BUFFER_SIZE / framesCount) {
327+ ALOGE("Buffer too big: %u*%u bytes > MAX_BUFFER_SIZE (%u)", frameSize, framesCount,
328+ Stream::MAX_BUFFER_SIZE);
334329 sendError(Result::INVALID_ARGUMENTS);
335330 return Void();
336331 }
Afficher sur ancien navigateur de dépôt.