From 7050b00c109e6c404edd50433e4ca7a11a31db78 Mon Sep 17 00:00:00 2001 From: Hiero32 Date: Tue, 20 Dec 2022 03:54:46 +0900 Subject: [PATCH] fdsrc,fdsink: Set binary mode on FD Default mode of STD handles on Windows is text mode, and OS will insert CRLF sequence by default. Co-authored-by: Seungha Yang Part-of: --- subprojects/gstreamer/plugins/elements/gstfdsink.c | 12 ++++++++++++ subprojects/gstreamer/plugins/elements/gstfdsrc.c | 6 ++++++ 2 files changed, 18 insertions(+) diff --git a/subprojects/gstreamer/plugins/elements/gstfdsink.c b/subprojects/gstreamer/plugins/elements/gstfdsink.c index bc6f502..4608598 100644 --- a/subprojects/gstreamer/plugins/elements/gstfdsink.c +++ b/subprojects/gstreamer/plugins/elements/gstfdsink.c @@ -262,8 +262,14 @@ gst_fd_sink_render_list (GstBaseSink * bsink, GstBufferList * buffer_list) for (;;) { guint64 bytes_written = 0; +#ifdef G_OS_WIN32 + int cur_mode = _setmode (sink->fd, O_BINARY); +#endif ret = gst_writev_buffer_list (GST_OBJECT_CAST (sink), sink->fd, sink->fdset, buffer_list, &bytes_written, skip, 0, -1, NULL); +#ifdef G_OS_WIN32 + _setmode (sink->fd, cur_mode); +#endif sink->current_pos += bytes_written; skip += bytes_written; @@ -297,8 +303,14 @@ gst_fd_sink_render (GstBaseSink * bsink, GstBuffer * buffer) for (;;) { guint64 bytes_written = 0; +#ifdef G_OS_WIN32 + int cur_mode = _setmode (sink->fd, O_BINARY); +#endif ret = gst_writev_buffer (GST_OBJECT_CAST (sink), sink->fd, sink->fdset, buffer, &bytes_written, skip, 0, -1, NULL); +#ifdef G_OS_WIN32 + _setmode (sink->fd, cur_mode); +#endif sink->current_pos += bytes_written; skip += bytes_written; diff --git a/subprojects/gstreamer/plugins/elements/gstfdsrc.c b/subprojects/gstreamer/plugins/elements/gstfdsrc.c index bf8c4de..89ccd5a 100644 --- a/subprojects/gstreamer/plugins/elements/gstfdsrc.c +++ b/subprojects/gstreamer/plugins/elements/gstfdsrc.c @@ -450,10 +450,16 @@ gst_fd_src_create (GstPushSrc * psrc, GstBuffer ** outbuf) if (!gst_buffer_map (buf, &info, GST_MAP_WRITE)) goto buffer_read_error; +#ifdef G_OS_WIN32 + int cur_mode = _setmode (src->fd, O_BINARY); +#endif do { readbytes = read (src->fd, info.data, blocksize); GST_LOG_OBJECT (src, "read %" G_GSSIZE_FORMAT, readbytes); } while (readbytes == -1 && errno == EINTR); /* retry if interrupted */ +#ifdef G_OS_WIN32 + _setmode (src->fd, cur_mode); +#endif if (readbytes < 0) goto read_error; -- 2.7.4