--- a/mpd2src/songcastsender.cpp
+++ b/mpd2src/songcastsender.cpp
@@ -18,6 +18,9 @@
#include "songcastsender.h"
extern bool g_quitrequest;
+
+// Decide if using a busyloop on blocking sources (rather than the timer)
+static const bool optionbusy = true;
SongcastSender::SongcastSender(Environment& aEnv, OhmSender* aSender,
OhmSenderDriver* aDriver, const Brx& aUri,
@@ -63,14 +66,15 @@
// and the upnp side stops working (no sender advertised).
// Maybe the best approach would be to start a separate thread and
// use busyreading. Using the main thread for now.
- static const bool optionbusy = true;
+ LOGDEB("SongcastSender::Start: Enabled " << aEnabled << " iPaused " <<
+ iPaused << endl);
+ if (aEnabled)
+ Play();
if (iPaced || !optionbusy) {
- LOGDEB("SongcastSender::Start: using timers. Enabled? " << aEnabled << endl);
- if (aEnabled)
- Play();
+ LOGDEB("SongcastSender::Start: using timers\n");
return true;
} else {
- LOGDEB("SongcastSender::Start: block on reading only\n");
+ LOGDEB("SongcastSender::Start: using read-blocking loop\n");
busyRdWr();
return false;
}
@@ -84,9 +88,11 @@
if (m_audio)
m_audio->open();
iPaused = false;
- iLastTimeUs = 0;
- iTimeOffsetUs = 0;
- iTimer.FireIn(kPeriodMs);
+ if (iPaced || !optionbusy) {
+ iLastTimeUs = 0;
+ iTimeOffsetUs = 0;
+ iTimer.FireIn(kPeriodMs);
+ }
}
iMutex.Signal();
}
@@ -154,7 +160,8 @@
void SongcastSender::busyRdWr()
{
- LOGDEB("SongcastSender:busyRdWr: packetbytes " << iPacketBytes << endl);
+ LOGDEB("SongcastSender:busyRdWr: packetbytes " << iPacketBytes <<
+ " iPaused " << iPaused << endl);
while (true) {
if (g_quitrequest) {
return;
@@ -167,7 +174,7 @@
if (g_quitrequest) {
return;
}
- m_encoder->encode(cp, nread, iPaused || g_quitrequest);
+ m_encoder->encode(cp, nread, iPaused);
}
}