mirror of
https://github.com/badaix/snapcast.git
synced 2025-07-05 02:37:38 +02:00
xxx
git-svn-id: svn://elaine/murooma/trunk@128 d8a302eb-03bc-478d-80e4-98257eca68ef
This commit is contained in:
parent
d94f6c99da
commit
4f5cbb5e25
2 changed files with 17 additions and 7 deletions
|
@ -22,8 +22,16 @@ using namespace std;
|
|||
void alive(zmq::socket_t* worker)
|
||||
{
|
||||
// Tell the router we're ready for work
|
||||
zmq::message_t message;
|
||||
while (1) {
|
||||
s_send (*worker, "ping");
|
||||
int res = worker->recv(&message);
|
||||
if (res == 0)
|
||||
{
|
||||
std::string recvMsg = std::string(static_cast<char*>(message.data()), message.size());
|
||||
}
|
||||
else
|
||||
cout << "Error: " << res << "\n";
|
||||
sleep(1);
|
||||
}
|
||||
}
|
||||
|
@ -32,7 +40,7 @@ void alive(zmq::socket_t* worker)
|
|||
void control(zmq::socket_t* worker)
|
||||
{
|
||||
// Tell the router we're ready for work
|
||||
// s_send (*worker, "ready");
|
||||
s_send (*worker, "ready");
|
||||
while (1) {
|
||||
std::string cmd = s_recv (*worker);
|
||||
vector<std::string> splitCmd = split(cmd);
|
||||
|
@ -46,14 +54,16 @@ void control(zmq::socket_t* worker)
|
|||
int main () {
|
||||
cout << getMacAddress() << "\n";
|
||||
zmq::context_t context(1);
|
||||
zmq::socket_t worker (context, ZMQ_DEALER);
|
||||
zmq::socket_t worker (context, ZMQ_REQ);
|
||||
srand (time(NULL));
|
||||
// We use a string identity for ease here
|
||||
string macAddress = getMacAddress();
|
||||
worker.setsockopt(ZMQ_IDENTITY, macAddress.c_str(), macAddress.length());
|
||||
// int timeout = 1000;
|
||||
// worker.setsockopt(ZMQ_RCVTIMEO, &timeout, sizeof(timeout));
|
||||
worker.connect("tcp://127.0.0.1:123459");
|
||||
|
||||
std::thread controlThread(control, &worker);
|
||||
// std::thread controlThread(control, &worker);
|
||||
std::thread aliveThread(alive, &worker);
|
||||
controlThread.join();
|
||||
return 0;
|
||||
|
|
|
@ -77,7 +77,7 @@ timeval Stream::getNextPlayerChunk(short* outputBuffer, int correction)
|
|||
}
|
||||
else
|
||||
{
|
||||
int idx(chunk->idx);
|
||||
/* int idx(chunk->idx);
|
||||
for (size_t n=0; n<PLAYER_CHUNK_SIZE; n+=2)
|
||||
{
|
||||
*(outputBuffer + n) = chunk->payload[idx];
|
||||
|
@ -97,8 +97,8 @@ timeval Stream::getNextPlayerChunk(short* outputBuffer, int correction)
|
|||
}
|
||||
}
|
||||
chunk->idx = idx;
|
||||
|
||||
/* size_t missing = PLAYER_CHUNK_SIZE;// + correction*PLAYER_CHUNK_MS_SIZE;
|
||||
*/
|
||||
size_t missing = PLAYER_CHUNK_SIZE;// + correction*PLAYER_CHUNK_MS_SIZE;
|
||||
if (chunk->idx + PLAYER_CHUNK_SIZE > WIRE_CHUNK_SIZE)
|
||||
{
|
||||
if (outputBuffer != NULL)
|
||||
|
@ -118,7 +118,7 @@ timeval Stream::getNextPlayerChunk(short* outputBuffer, int correction)
|
|||
chunks.pop_front();
|
||||
delete chunk;
|
||||
}
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
return tv;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue