|
a/mpd2src/fiforeader.cpp |
|
b/mpd2src/fiforeader.cpp |
|
... |
|
... |
39 |
setAudioParams(sampleRate, bitsPerSample, chans);
|
39 |
setAudioParams(sampleRate, bitsPerSample, chans);
|
40 |
}
|
40 |
}
|
41 |
|
41 |
|
42 |
FifoReader::~FifoReader()
|
42 |
FifoReader::~FifoReader()
|
43 |
{
|
43 |
{
|
44 |
if (m_fd >= 0)
|
44 |
if (m_fn.compare("stdin") && m_fd >= 0)
|
45 |
::close(m_fd);
|
45 |
::close(m_fd);
|
46 |
|
46 |
|
47 |
if (m_tmpbuf)
|
47 |
if (m_tmpbuf)
|
48 |
free(m_tmpbuf);
|
48 |
free(m_tmpbuf);
|
49 |
}
|
49 |
}
|
50 |
|
50 |
|
51 |
bool FifoReader::open()
|
51 |
bool FifoReader::open()
|
52 |
{
|
52 |
{
|
53 |
LOGDEB("FifoReader::open: blocking: " << m_blocking << endl);
|
53 |
LOGDEB("FifoReader::open: blocking: " << m_blocking << endl);
|
54 |
|
54 |
if (m_fn.compare("stdin")) {
|
55 |
int flags = m_blocking ? O_RDONLY : O_RDONLY|O_NONBLOCK;
|
55 |
int flags = m_blocking ? O_RDONLY : O_RDONLY|O_NONBLOCK;
|
56 |
if ((m_fd = ::open(m_fn.c_str(), flags)) < 0) {
|
56 |
if ((m_fd = ::open(m_fn.c_str(), flags)) < 0) {
|
57 |
LOGERR("open() errno " << errno << " on " << m_fn << endl);
|
57 |
LOGERR("open() errno " << errno << " on " << m_fn << endl);
|
58 |
return false;
|
58 |
return false;
|
|
|
59 |
}
|
|
|
60 |
} else {
|
|
|
61 |
m_fd = 0;
|
|
|
62 |
if (!m_blocking) {
|
|
|
63 |
fcntl(m_fd, F_SETFL, O_NONBLOCK);
|
|
|
64 |
}
|
59 |
}
|
65 |
}
|
60 |
return true;
|
66 |
return true;
|
61 |
}
|
67 |
}
|
62 |
|
68 |
|
63 |
|
69 |
|