mirror of
https://github.com/badaix/snapcast.git
synced 2025-05-20 12:36:17 +02:00
dont resolve
git-svn-id: svn://elaine/murooma/trunk@240 d8a302eb-03bc-478d-80e4-98257eca68ef
This commit is contained in:
parent
0ca2460971
commit
f507b931fe
3 changed files with 85 additions and 0 deletions
59
client/controller.cpp
Normal file
59
client/controller.cpp
Normal file
|
@ -0,0 +1,59 @@
|
|||
#include "controller.h"
|
||||
#include <iostream>
|
||||
#include <unistd.h>
|
||||
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
Controller::Controller() : MessageReceiver(), active_(false)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void Controller::onMessageReceived(BaseMessage* message)
|
||||
{
|
||||
if (message->type == message_type::payload)
|
||||
{
|
||||
/* if (decoder.decode((PcmChunk*)message))
|
||||
stream_->addChunk((PcmChunk*)message);
|
||||
else
|
||||
*/ delete message;
|
||||
//cout << ", decoded: " << chunk->payloadSize << ", Duration: " << chunk->getDuration() << ", sec: " << chunk->tv_sec << ", usec: " << chunk->tv_usec/1000 << ", type: " << chunk->type << "\n";
|
||||
}
|
||||
else if (message->type == message_type::header)
|
||||
{
|
||||
// decoder.setHeader((HeaderMessage*)message);
|
||||
}
|
||||
else if (message->type == message_type::sampleformat)
|
||||
{
|
||||
SampleFormat* sampleFormat = (SampleFormat*)message;
|
||||
cout << "SampleFormat rate: " << sampleFormat->rate << ", bits: " << sampleFormat->bits << ", channels: " << sampleFormat->channels << "\n";
|
||||
delete sampleFormat;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Controller::start()
|
||||
{
|
||||
|
||||
controllerThread = new thread(&Controller::worker, this);
|
||||
}
|
||||
|
||||
|
||||
void Controller::stop()
|
||||
{
|
||||
active_ = false;
|
||||
}
|
||||
|
||||
|
||||
void Controller::worker()
|
||||
{
|
||||
active_ = true;
|
||||
while (active_)
|
||||
{
|
||||
usleep(10000);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue