mirror of
https://github.com/badaix/snapcast.git
synced 2025-05-17 11:06:16 +02:00
message sub directory
git-svn-id: svn://elaine/murooma/trunk@287 d8a302eb-03bc-478d-80e4-98257eca68ef
This commit is contained in:
parent
e0a6ac9467
commit
983ded3d29
24 changed files with 137 additions and 137 deletions
|
@ -3,7 +3,7 @@ CC = /usr/bin/g++
|
|||
CFLAGS = -std=gnu++0x -Wall -Wno-unused-function -g -D_REENTRANT -DVERSION=\"$(VERSION)\" -I..
|
||||
LDFLAGS = -lrt -lpthread -lboost_system -lboost_program_options -lasound -logg -lvorbis -lvorbisenc
|
||||
|
||||
OBJ = snapClient.o stream.o player.o clientConnection.o timeProvider.o oggDecoder.o pcmDecoder.o controller.o ../common/pcmChunk.o ../common/log.o ../common/sampleFormat.o
|
||||
OBJ = snapClient.o stream.o player.o clientConnection.o timeProvider.o oggDecoder.o pcmDecoder.o controller.o ../message/pcmChunk.o ../common/log.o ../message/sampleFormat.o
|
||||
BIN = snapclient
|
||||
|
||||
all: client
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#include <boost/asio.hpp>
|
||||
#include <condition_variable>
|
||||
#include <set>
|
||||
#include "common/message.h"
|
||||
#include "message/message.h"
|
||||
|
||||
|
||||
using boost::asio::ip::tcp;
|
||||
|
|
|
@ -7,10 +7,10 @@
|
|||
#include "pcmDecoder.h"
|
||||
#include "player.h"
|
||||
#include "timeProvider.h"
|
||||
#include "common/serverSettings.h"
|
||||
#include "common/timeMsg.h"
|
||||
#include "common/requestMsg.h"
|
||||
#include "common/ackMsg.h"
|
||||
#include "message/serverSettings.h"
|
||||
#include "message/timeMsg.h"
|
||||
#include "message/requestMsg.h"
|
||||
#include "message/ackMsg.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include <thread>
|
||||
#include <atomic>
|
||||
#include "common/message.h"
|
||||
#include "message/message.h"
|
||||
#include "clientConnection.h"
|
||||
#include "decoder.h"
|
||||
#include "stream.h"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef DECODER_H
|
||||
#define DECODER_H
|
||||
#include "common/pcmChunk.h"
|
||||
#include "common/headerMessage.h"
|
||||
#include "message/pcmChunk.h"
|
||||
#include "message/headerMessage.h"
|
||||
|
||||
class Decoder
|
||||
{
|
||||
|
|
|
@ -155,9 +155,11 @@ void Stream::resetBuffers()
|
|||
|
||||
bool Stream::getPlayerChunk(void* outputBuffer, double outputBufferDacTime, unsigned long framesPerBuffer, size_t timeout)
|
||||
{
|
||||
//cout << "framesPerBuffer: " << framesPerBuffer << "\tms: " << framesPerBuffer*2 / PLAYER_CHUNK_MS_SIZE << "\t" << PLAYER_CHUNK_SIZE << "\n";
|
||||
try
|
||||
{
|
||||
//cout << "framesPerBuffer: " << framesPerBuffer << "\tms: " << framesPerBuffer*2 / PLAYER_CHUNK_MS_SIZE << "\t" << PLAYER_CHUNK_SIZE << "\n";
|
||||
int msBuffer = framesPerBuffer / format_.msRate();
|
||||
//cout << msBuffer << " ms, " << framesPerBuffer << "\t" << format_.rate/1000 << "\n";
|
||||
//cout << msBuffer << " ms, " << framesPerBuffer << "\t" << format_.rate/1000 << "\n";
|
||||
int ticks = 0;
|
||||
long currentTick = getTickCount();
|
||||
if (lastTick == 0)
|
||||
|
@ -174,9 +176,9 @@ bool Stream::getPlayerChunk(void* outputBuffer, double outputBufferDacTime, unsi
|
|||
cout << "Sleep " << sleep;
|
||||
sleep = PcmChunk::getAge(getSilentPlayerChunk(outputBuffer, framesPerBuffer)) - bufferMs + outputBufferDacTime + TimeProvider::getInstance().getDiffToServerMs();
|
||||
std::cerr << " after: " << sleep << ", chunks: " << chunks.size() << "\n";
|
||||
// std::clog << kLogNotice << "sleep: " << sleep << std::endl;
|
||||
// if (sleep > -msBuffer/2)
|
||||
// sleep = 0;
|
||||
// std::clog << kLogNotice << "sleep: " << sleep << std::endl;
|
||||
// if (sleep > -msBuffer/2)
|
||||
// sleep = 0;
|
||||
if (sleep < -msBuffer/2)
|
||||
return true;
|
||||
}
|
||||
|
@ -190,12 +192,14 @@ bool Stream::getPlayerChunk(void* outputBuffer, double outputBufferDacTime, unsi
|
|||
cout << " after: " << sleep << "\n";
|
||||
*/
|
||||
if (!chunk)
|
||||
chunk = chunks.pop();
|
||||
if (!chunks.try_pop(chunk, std::chrono::milliseconds(timeout)))
|
||||
throw 0;
|
||||
while (sleep > chunk->getDuration())
|
||||
{
|
||||
chunk = chunks.pop();
|
||||
if (!chunks.try_pop(chunk, std::chrono::milliseconds(timeout)))
|
||||
throw 0;
|
||||
sleep = chunk->getAge() - bufferMs + outputBufferDacTime + TimeProvider::getInstance().getDiffToServerMs();
|
||||
// cout << "chunk->getAge() > chunk->getDuration(): " << chunk->getAge() - bufferMs + outputBufferDacTime << " > " << chunk->getDuration() << ", chunks: " << chunks.size() << ", out: " << outputBufferDacTime << ", needed: " << msBuffer << ", sleep: " << sleep << "\n";
|
||||
// cout << "chunk->getAge() > chunk->getDuration(): " << chunk->getAge() - bufferMs + outputBufferDacTime << " > " << chunk->getDuration() << ", chunks: " << chunks.size() << ", out: " << outputBufferDacTime << ", needed: " << msBuffer << ", sleep: " << sleep << "\n";
|
||||
usleep(1000);
|
||||
}
|
||||
cout << "seek: " << PcmChunk::getAge(seek(sleep)) - bufferMs + outputBufferDacTime << "\n";
|
||||
|
@ -214,17 +218,8 @@ bool Stream::getPlayerChunk(void* outputBuffer, double outputBufferDacTime, unsi
|
|||
}
|
||||
|
||||
|
||||
|
||||
long age(0);
|
||||
try
|
||||
{
|
||||
age = PcmChunk::getAge(getNextPlayerChunk(outputBuffer, framesPerBuffer, timeout, correction)) - bufferMs + outputBufferDacTime + TimeProvider::getInstance().getDiffToServerMs();
|
||||
}
|
||||
catch(int e)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (sleep == 0)
|
||||
|
@ -255,10 +250,10 @@ bool Stream::getPlayerChunk(void* outputBuffer, double outputBufferDacTime, unsi
|
|||
std::cerr << "Sleep: " << sleep << "\n";
|
||||
|
||||
|
||||
// std::cerr << "Chunk: " << age << "\t" << outputBufferDacTime*1000 << "\n";
|
||||
// std::cerr << "Chunk: " << age << "\t" << outputBufferDacTime*1000 << "\n";
|
||||
if (ticks > 2)
|
||||
{
|
||||
// cout << age << "\n";
|
||||
// cout << age << "\n";
|
||||
updateBuffers(age);
|
||||
}
|
||||
time_t now = time(NULL);
|
||||
|
@ -270,6 +265,11 @@ bool Stream::getPlayerChunk(void* outputBuffer, double outputBufferDacTime, unsi
|
|||
std::cerr << "Chunk: " << age << "\t" << miniBuffer.median() << "\t" << shortMedian << "\t" << median << "\t" << buffer.size() << "\t" << /*cardBuffer << "\t" <<*/ outputBufferDacTime << "\n";
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch(int e)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -8,11 +8,11 @@
|
|||
#include <vector>
|
||||
#include <memory>
|
||||
#include "doubleBuffer.h"
|
||||
#include "common/message.h"
|
||||
#include "common/pcmChunk.h"
|
||||
#include "message/message.h"
|
||||
#include "message/pcmChunk.h"
|
||||
#include "message/sampleFormat.h"
|
||||
#include "common/timeUtils.h"
|
||||
#include "common/queue.h"
|
||||
#include "common/sampleFormat.h"
|
||||
|
||||
|
||||
class Stream
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef HEADER_MESSAGE_H
|
||||
#define HEADER_MESSAGE_H
|
||||
|
||||
#include "common/message.h"
|
||||
#include "message.h"
|
||||
|
||||
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef SERVER_SETTINGS_H
|
||||
#define SERVER_SETTINGS_H
|
||||
|
||||
#include "message.h"
|
||||
#include "message/message.h"
|
||||
|
||||
|
||||
|
|
@ -3,7 +3,7 @@ CC = /usr/bin/g++
|
|||
CFLAGS = -std=gnu++0x -Wall -Wno-unused-function -D_REENTRANT -DVERSION=\"$(VERSION)\" -I..
|
||||
LDFLAGS = -lrt -lpthread -lboost_system -lboost_program_options -lvorbis -lvorbisenc -logg
|
||||
|
||||
OBJ = snapServer.o controlServer.o pcmEncoder.o oggEncoder.o serverSession.o ../common/log.o ../common/pcmChunk.o ../common/sampleFormat.o
|
||||
OBJ = snapServer.o controlServer.o pcmEncoder.o oggEncoder.o serverSession.o ../common/log.o ../message/pcmChunk.o ../message/sampleFormat.o
|
||||
BIN = snapserver
|
||||
|
||||
all: server
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "controlServer.h"
|
||||
#include "common/timeMsg.h"
|
||||
#include "common/ackMsg.h"
|
||||
#include "common/requestMsg.h"
|
||||
#include "message/timeMsg.h"
|
||||
#include "message/ackMsg.h"
|
||||
#include "message/requestMsg.h"
|
||||
#include <iostream>
|
||||
|
||||
|
||||
|
|
|
@ -12,10 +12,10 @@
|
|||
#include "serverSession.h"
|
||||
#include "common/timeUtils.h"
|
||||
#include "common/queue.h"
|
||||
#include "common/message.h"
|
||||
#include "common/headerMessage.h"
|
||||
#include "common/sampleFormat.h"
|
||||
#include "common/serverSettings.h"
|
||||
#include "message/message.h"
|
||||
#include "message/headerMessage.h"
|
||||
#include "message/sampleFormat.h"
|
||||
#include "message/serverSettings.h"
|
||||
|
||||
|
||||
using boost::asio::ip::tcp;
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#ifndef ENCODER_H
|
||||
#define ENCODER_H
|
||||
#include "common/pcmChunk.h"
|
||||
#include "common/headerMessage.h"
|
||||
#include "common/sampleFormat.h"
|
||||
#include "message/pcmChunk.h"
|
||||
#include "message/headerMessage.h"
|
||||
#include "message/sampleFormat.h"
|
||||
|
||||
|
||||
class Encoder
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#include <boost/asio.hpp>
|
||||
#include <condition_variable>
|
||||
#include <set>
|
||||
#include "common/message.h"
|
||||
#include "message/message.h"
|
||||
#include "common/queue.h"
|
||||
|
||||
|
||||
|
|
|
@ -4,10 +4,10 @@
|
|||
#include "common/timeUtils.h"
|
||||
#include "common/signalHandler.h"
|
||||
#include "common/utils.h"
|
||||
#include "common/sampleFormat.h"
|
||||
#include "../server/pcmEncoder.h"
|
||||
#include "../server/oggEncoder.h"
|
||||
#include "common/message.h"
|
||||
#include "message/sampleFormat.h"
|
||||
#include "message/message.h"
|
||||
#include "pcmEncoder.h"
|
||||
#include "oggEncoder.h"
|
||||
#include "controlServer.h"
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue