--- a/mpd2src/fiforeader.cpp
+++ b/mpd2src/fiforeader.cpp
@@ -66,9 +66,10 @@
return true;
}
+const unsigned char *FifoReader::data(size_t size, ssize_t &nread)
+{
+ nread = 0;
-const unsigned char *FifoReader::data(size_t size)
-{
//LOGDEB("FifoReader: data " << size << " bytes. blocking " << m_blocking
// << endl);
if (m_tmpbufsize < size) {
@@ -89,20 +90,18 @@
}
}
} else {
- ssize_t nread = read(m_fd, m_tmpbuf, size);
- if (nread != ssize_t(size)) {
- if (nread >= 0 || errno == EAGAIN) {
- if (nread < 0)
- nread = 0;
- //LOGDEB("FifoReader::data: inserting " << size - nread <<
- // " bytes\n");
- memset(m_tmpbuf + nread, 0, size - nread);
- } else {
- LOGERR("FifoReader::read: ret " << nread << " errno " <<
- errno << " : " << strerror(errno) << endl);
- return 0;
- }
- }
+ nread = read(m_fd, m_tmpbuf, size);
+ if (nread == -1) {
+ if (errno == EAGAIN)
+ return m_tmpbuf;
+ LOGERR("FifoReader::read: ret " << nread << " errno " <<
+ errno << " : " << strerror(errno) << endl);
+ return 0;
+ } else if (size - (size_t)nread > 0) {
+ LOGDEB("FifoReader::data: inserting " << size - nread <<
+ " bytes\n");
+ memset(m_tmpbuf + nread, 0, size - nread);
+ }
}
if (m_needswap)