mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-27 18:50:48 +00:00
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 <seungha@centricular.com> Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3070>
This commit is contained in:
parent
a29a1b21c3
commit
7050b00c10
2 changed files with 18 additions and 0 deletions
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue