|
a/mpd2src/fiforeader.cpp |
|
b/mpd2src/fiforeader.cpp |
|
... |
|
... |
64 |
}
|
64 |
}
|
65 |
}
|
65 |
}
|
66 |
return true;
|
66 |
return true;
|
67 |
}
|
67 |
}
|
68 |
|
68 |
|
|
|
69 |
const unsigned char *FifoReader::data(size_t size, ssize_t &nread)
|
|
|
70 |
{
|
|
|
71 |
nread = 0;
|
69 |
|
72 |
|
70 |
const unsigned char *FifoReader::data(size_t size)
|
|
|
71 |
{
|
|
|
72 |
//LOGDEB("FifoReader: data " << size << " bytes. blocking " << m_blocking
|
73 |
//LOGDEB("FifoReader: data " << size << " bytes. blocking " << m_blocking
|
73 |
// << endl);
|
74 |
// << endl);
|
74 |
if (m_tmpbufsize < size) {
|
75 |
if (m_tmpbufsize < size) {
|
75 |
m_tmpbuf = (unsigned char *)realloc(m_tmpbuf, size);
|
76 |
m_tmpbuf = (unsigned char *)realloc(m_tmpbuf, size);
|
76 |
m_tmpbufsize = size;
|
77 |
m_tmpbufsize = size;
|
|
... |
|
... |
87 |
} else {
|
88 |
} else {
|
88 |
remaining -= nread;
|
89 |
remaining -= nread;
|
89 |
}
|
90 |
}
|
90 |
}
|
91 |
}
|
91 |
} else {
|
92 |
} else {
|
92 |
ssize_t nread = read(m_fd, m_tmpbuf, size);
|
93 |
nread = read(m_fd, m_tmpbuf, size);
|
93 |
if (nread != ssize_t(size)) {
|
94 |
if (nread == -1) {
|
94 |
if (nread >= 0 || errno == EAGAIN) {
|
95 |
if (errno == EAGAIN)
|
95 |
if (nread < 0)
|
96 |
return m_tmpbuf;
|
96 |
nread = 0;
|
|
|
97 |
//LOGDEB("FifoReader::data: inserting " << size - nread <<
|
|
|
98 |
// " bytes\n");
|
|
|
99 |
memset(m_tmpbuf + nread, 0, size - nread);
|
|
|
100 |
} else {
|
|
|
101 |
LOGERR("FifoReader::read: ret " << nread << " errno " <<
|
97 |
LOGERR("FifoReader::read: ret " << nread << " errno " <<
|
102 |
errno << " : " << strerror(errno) << endl);
|
98 |
errno << " : " << strerror(errno) << endl);
|
103 |
return 0;
|
99 |
return 0;
|
104 |
}
|
100 |
} else if (size - (size_t)nread > 0) {
|
|
|
101 |
LOGDEB("FifoReader::data: inserting " << size - nread <<
|
|
|
102 |
" bytes\n");
|
|
|
103 |
memset(m_tmpbuf + nread, 0, size - nread);
|
105 |
}
|
104 |
}
|
106 |
}
|
105 |
}
|
107 |
|
106 |
|
108 |
if (m_needswap)
|
107 |
if (m_needswap)
|
109 |
swapSamples(m_tmpbuf, bytesPerSample(), m_tmpbufsize / bytesPerSample());
|
108 |
swapSamples(m_tmpbuf, bytesPerSample(), m_tmpbufsize / bytesPerSample());
|
110 |
|
109 |
|