OSDN Git Service

fifo: use const more
authorGlenn Kasten <gkasten@google.com>
Tue, 22 Nov 2016 22:00:53 +0000 (14:00 -0800)
committerGlenn Kasten <gkasten@google.com>
Tue, 22 Nov 2016 22:10:00 +0000 (14:10 -0800)
Test: builds OK
Change-Id: I81c4e656b65e9e50f3affb11aeb3b51b0a36e3f7

audio_utils/fifo.cpp
audio_utils/include/audio_utils/fifo.h

index 9f655fb..8a1ee6a 100644 (file)
@@ -103,7 +103,7 @@ audio_utils_fifo_base::~audio_utils_fifo_base()
 {
 }
 
-uint32_t audio_utils_fifo_base::sum(uint32_t index, uint32_t increment)
+uint32_t audio_utils_fifo_base::sum(uint32_t index, uint32_t increment) const
         __attribute__((no_sanitize("integer")))
 {
     if (mFudgeFactor) {
@@ -121,7 +121,7 @@ uint32_t audio_utils_fifo_base::sum(uint32_t index, uint32_t increment)
     }
 }
 
-int32_t audio_utils_fifo_base::diff(uint32_t rear, uint32_t front, size_t *lost)
+int32_t audio_utils_fifo_base::diff(uint32_t rear, uint32_t front, size_t *lost) const
         __attribute__((no_sanitize("integer")))
 {
     // TODO replace multiple returns by a single return point so this isn't needed
index d2a5663..249c374 100644 (file)
@@ -100,7 +100,7 @@ protected:
      *
      * \return The sum of index plus increment.
      */
-    uint32_t sum(uint32_t index, uint32_t increment);
+    uint32_t sum(uint32_t index, uint32_t increment) const;
 
     /** Return the difference between two indices: rear - front.
      *
@@ -114,7 +114,7 @@ protected:
      * \retval -EOVERFLOW  reader doesn't throttle writer, and frames were lost because reader
      *                     isn't keeping up with writer; see \p lost
      */
-    int32_t diff(uint32_t rear, uint32_t front, size_t *lost = NULL);
+    int32_t diff(uint32_t rear, uint32_t front, size_t *lost = NULL) const;
 
     // These fields are const after initialization
 
@@ -130,17 +130,17 @@ protected:
     const uint32_t mFudgeFactor;
 
     /** Reference to writer's rear index. */
-    audio_utils_fifo_index&     mWriterRear;
+    audio_utils_fifo_index&         mWriterRear;
     /** Indicates how synchronization is done for mWriterRear. */
-    audio_utils_fifo_sync       mWriterRearSync;
+    const audio_utils_fifo_sync     mWriterRearSync;
 
     /**
      * Pointer to the front index of at most one reader that throttles the writer,
      * or NULL for no throttling.
      */
-    audio_utils_fifo_index*     mThrottleFront;
+    audio_utils_fifo_index* const   mThrottleFront;
     /** Indicates how synchronization is done for mThrottleFront. */
-    audio_utils_fifo_sync       mThrottleFrontSync;
+    const audio_utils_fifo_sync     mThrottleFrontSync;
 };
 
 ////////////////////////////////////////////////////////////////////////////////