CCodec: force array mode for linear output buffers

Bug: 112678648
Test: Cast
Change-Id: I325d08d0e04fc135f404d3168e252bfdfd4a3653
(cherry picked from commit 6c9615eee98b2d572d54970a9525580bbc71f206)
diff --git a/media/sfplugin/CCodecBufferChannel.cpp b/media/sfplugin/CCodecBufferChannel.cpp
index cbf89e1..8d82b85 100644
--- a/media/sfplugin/CCodecBufferChannel.cpp
+++ b/media/sfplugin/CCodecBufferChannel.cpp
@@ -2111,7 +2111,12 @@
                     outputGeneration);
         }
 
-        if (oStreamFormat.value == C2FormatAudio) {
+        if (oStreamFormat.value == C2BufferData::LINEAR) {
+            // WORKAROUND: if we're using early CSD workaround we convert to
+            //             array mode, to appease apps assuming the output
+            //             buffers to be of the same size.
+            (*buffers) = (*buffers)->toArrayMode(kMinOutputBufferArraySize);
+
             int32_t channelCount;
             int32_t sampleRate;
             if (outputFormat->findInt32(KEY_CHANNEL_COUNT, &channelCount)
@@ -2125,8 +2130,8 @@
                     padding = 0;
                 }
                 if (delay || padding) {
-                    // We need write access to the buffers..
-                    (*buffers) = (*buffers)->toArrayMode(kMinOutputBufferArraySize);
+                    // We need write access to the buffers, and we're already in
+                    // array mode.
                     (*buffers)->initSkipCutBuffer(delay, padding, sampleRate, channelCount);
                 }
             }
@@ -2194,7 +2199,7 @@
                     ALOGD("[%s] buffer capacity too small for the config (%zu < %zu)",
                             mName, buffer->capacity(), config->size());
                 }
-            } else if (oStreamFormat.value == C2FormatCompressed && i == 0) {
+            } else if (oStreamFormat.value == C2BufferData::LINEAR && i == 0) {
                 // WORKAROUND: Some apps expect CSD available without queueing
                 //             any input. Queue an empty buffer to get the CSD.
                 buffer->setRange(0, 0);