libeplayer3: further malloc-memcpy-write -> writev replacements; not fully regression tested

This commit is contained in:
martii
2013-06-08 11:15:09 +02:00
parent 8d8aa01f98
commit a09c2518bc
12 changed files with 134 additions and 172 deletions

View File

@@ -37,9 +37,7 @@
#include <asm/types.h>
#include <pthread.h>
#include <errno.h>
#ifdef MARTII
#include <sys/uio.h>
#endif
#include "common.h"
#include "output.h"
@@ -96,9 +94,6 @@ static int writeData(void* _call)
WriterAVCallData_t* call = (WriterAVCallData_t*) _call;
unsigned char PesHeader[PES_MAX_HEADER_SIZE];
#ifndef MARTII
unsigned char DataCopy[PES_MAX_HEADER_SIZE];
#endif
int len = 0;
h263_printf(10, "\n");
@@ -136,30 +131,12 @@ static int writeData(void* _call)
HeaderLength += PrivateHeaderLength;
#ifdef MARTII
struct iovec iov[2];
iov[0].iov_base = PesHeader;
iov[0].iov_len = HeaderLength;
iov[1].iov_base = call->data;
iov[1].iov_len = call->len;
len = writev(call->fd, iov, 2);
#else
unsigned char *PacketData = malloc(HeaderLength + call->len);
if(PacketData != NULL)
{
memcpy(PacketData, PesHeader, HeaderLength);
memcpy(PacketData + HeaderLength, call->data, call->len);
len = write(call->fd, PacketData, call->len + HeaderLength);
free(PacketData);
}
else
{
h263_err("no mem\n");
}
#endif
h263_printf(10, "< len %d\n", len);
return len;