sjanc commented on code in PR #3233:
URL: https://github.com/apache/mynewt-core/pull/3233#discussion_r1632892442


##########
hw/drivers/i2s/src/i2s_stream.c:
##########
@@ -0,0 +1,95 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+#include <assert.h>
+
+#include <os/util.h>
+#include <stream/stream.h>
+#include <i2s/i2s.h>
+#include <i2s/i2s_stream.h>
+
+OSTREAM_DEF(i2s_out_stream);
+
+static int
+i2s_out_stream_pump_from(struct out_stream *ostream, struct in_stream 
*istream, uint32_t count)
+{
+    struct i2s_out_stream *i2s_str = CONTAINER_OF(ostream, struct 
i2s_out_stream, ostream);
+    struct i2s_sample_buffer *buffer = i2s_str->buffer;
+    struct i2s *i2s = i2s_str->i2s;
+    int written = 0;
+    uint32_t available = istream_available(istream);
+    uint32_t sample_count;
+
+    if (available < count) {
+        count = available;
+    }
+    sample_count = count / i2s->sample_size_in_bytes;
+
+    while (count) {

Review Comment:
   this looks bit odd since count is never modified inside loop



##########
util/stream/src/stream.c:
##########
@@ -107,3 +108,30 @@ istream_read(struct in_stream *istream, uint8_t *buf, 
uint32_t count)
     return istream->vft->read(istream, buf, count);
 }
 
+int
+stream_pump(struct in_stream *istream, struct out_stream *ostream, uint32_t 
count)
+{
+    int pumped;
+
+    /* If output stream has pump_from function used it */
+    if (ostream->vft->pump_from) {
+        pumped = ostream->vft->pump_from(ostream, istream, count);
+    } else if (istream->vft->pump_to) {
+        /* When input stream has pump_to used it */
+        pumped = istream->vft->pump_to(istream, ostream, count);
+    } else {
+        /* Both stream don't provide pump functions, use local buffer for 
pumping data */
+        uint8_t buf[16];
+        pumped = 0;
+        while (count) {

Review Comment:
   same here



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@mynewt.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to