OSDN Git Service

oss,sndio: simplify by using FFMIN.
authorReimar Döffinger <Reimar.Doeffinger@gmx.de>
Tue, 29 Mar 2011 18:18:45 +0000 (20:18 +0200)
committerAnton Khirnov <anton@khirnov.net>
Thu, 9 Jun 2011 20:53:17 +0000 (22:53 +0200)
Signed-off-by: Anton Khirnov <anton@khirnov.net>
libavdevice/oss_audio.c
libavdevice/sndio_enc.c

index af46ea8..fcbe26b 100644 (file)
@@ -181,9 +181,7 @@ static int audio_write_packet(AVFormatContext *s1, AVPacket *pkt)
     uint8_t *buf= pkt->data;
 
     while (size > 0) {
-        len = AUDIO_BLOCK_SIZE - s->buffer_ptr;
-        if (len > size)
-            len = size;
+        len = FFMIN(AUDIO_BLOCK_SIZE - s->buffer_ptr, size);
         memcpy(s->buffer + s->buffer_ptr, buf, len);
         s->buffer_ptr += len;
         if (s->buffer_ptr >= AUDIO_BLOCK_SIZE) {
index 6745ba4..49a52b3 100644 (file)
@@ -49,9 +49,7 @@ static int audio_write_packet(AVFormatContext *s1, AVPacket *pkt)
     int len, ret;
 
     while (size > 0) {
-        len = s->buffer_size - s->buffer_offset;
-        if (len > size)
-            len = size;
+        len = FFMIN(s->buffer_size - s->buffer_offset, size);
         memcpy(s->buffer + s->buffer_offset, buf, len);
         buf  += len;
         size -= len;