summaryrefslogtreecommitdiff
path: root/libavdevice/lavfi.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2014-07-13 15:56:06 +0200
committerMichael Niedermayer <michaelni@gmx.at>2014-07-15 21:49:56 +0200
commit95144729045fe00130f6b3547c04d40d1b48b157 (patch)
tree55d4259547dde6f7116bde0fef3530fb209895dc /libavdevice/lavfi.c
parent7a15c22c5f76c1e5261b9ac023f95f418f8459d8 (diff)
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>
Diffstat (limited to 'libavdevice/lavfi.c')
-rw-r--r--libavdevice/lavfi.c39
1 files changed, 16 insertions, 23 deletions
diff --git a/libavdevice/lavfi.c b/libavdevice/lavfi.c
index 4fc09d86c8..d1904dd70b 100644
--- a/libavdevice/lavfi.c
+++ b/libavdevice/lavfi.c
@@ -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)