avutil & avdevice: remove av_bprint_fd_contents()

MSVC does not allow passing file pointers between libs
This API can thus not work with MSVC and as it was very recently added
and its it was in no release its removial should not cause any problems

A better API will be implemented, but its not finished yet, this revert is
to avoid potentially blocking the release

Found-by: Hendrik Leppkes <h.leppkes@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Michael Niedermayer 2014-07-13 15:56:06 +02:00
parent 7a15c22c5f
commit 9514472904
3 changed files with 16 additions and 54 deletions

View File

@ -26,7 +26,6 @@
/* #define DEBUG */
#include <float.h> /* DBL_MIN, DBL_MAX */
#include <fcntl.h> /* O_RDONLY */
#include "libavutil/bprint.h"
#include "libavutil/channel_layout.h"
@ -42,13 +41,6 @@
#include "libavformat/internal.h"
#include "avdevice.h"
#if HAVE_UNISTD_H
#include <unistd.h> /* close() */
#endif
#if HAVE_IO_H
#include <io.h>
#endif
typedef struct {
AVClass *class; ///< class for private options
char *graph_str;
@ -123,22 +115,23 @@ av_cold static int lavfi_read_header(AVFormatContext *avctx)
}
if (lavfi->graph_filename) {
AVBPrint graph_file_pb;
int fd = avpriv_open(lavfi->graph_filename, O_RDONLY);
if (fd == -1)
FAIL(AVERROR(EINVAL));
av_bprint_init(&graph_file_pb, 0, AV_BPRINT_SIZE_UNLIMITED);
ret = av_bprint_fd_contents(&graph_file_pb, fd);
av_bprint_chars(&graph_file_pb, '\0', 1);
close(fd);
if (!ret && !av_bprint_is_complete(&graph_file_pb))
ret = AVERROR(ENOMEM);
if (ret) {
av_bprint_finalize(&graph_file_pb, NULL);
FAIL(ret);
uint8_t *file_buf, *graph_buf;
size_t file_bufsize;
ret = av_file_map(lavfi->graph_filename,
&file_buf, &file_bufsize, 0, avctx);
if (ret < 0)
goto end;
/* create a 0-terminated string based on the read file */
graph_buf = av_malloc(file_bufsize + 1);
if (!graph_buf) {
av_file_unmap(file_buf, file_bufsize);
FAIL(AVERROR(ENOMEM));
}
if ((ret = av_bprint_finalize(&graph_file_pb, &lavfi->graph_str)))
FAIL(ret);
memcpy(graph_buf, file_buf, file_bufsize);
graph_buf[file_bufsize] = 0;
av_file_unmap(file_buf, file_bufsize);
lavfi->graph_str = graph_buf;
}
if (!lavfi->graph_str)

View File

@ -30,14 +30,6 @@
#include "error.h"
#include "mem.h"
#if HAVE_IO_H
#include <io.h>
#endif
#if HAVE_UNISTD_H
#include <unistd.h>
#endif
#define av_bprint_room(buf) ((buf)->size - FFMIN((buf)->len, (buf)->size))
#define av_bprint_is_allocated(buf) ((buf)->str != (buf)->reserved_internal_buffer)
@ -312,22 +304,6 @@ void av_bprint_escape(AVBPrint *dstbuf, const char *src, const char *special_cha
}
}
int av_bprint_fd_contents(AVBPrint *pb, int fd)
{
int ret;
char buf[1024];
while (1) {
ret = read(fd, buf, sizeof(buf));
if (!ret)
return 0;
else if (ret < 0)
return AVERROR(errno);
av_bprint_append_data(pb, buf, ret);
if (!av_bprint_is_complete(pb))
return AVERROR(ENOMEM);
}
}
#ifdef TEST
#undef printf

View File

@ -213,11 +213,4 @@ int av_bprint_finalize(AVBPrint *buf, char **ret_str);
void av_bprint_escape(AVBPrint *dstbuf, const char *src, const char *special_chars,
enum AVEscapeMode mode, int flags);
/**
* Read contents of fd into print buffer up to EOF.
*
* @return 0 for success, error code otherwise
*/
int av_bprint_fd_contents(AVBPrint *pb, int fd);
#endif /* AVUTIL_BPRINT_H */