message sub directory

git-svn-id: svn://elaine/murooma/trunk@287 d8a302eb-03bc-478d-80e4-98257eca68ef
This commit is contained in:
(no author) 2014-09-21 14:28:14 +00:00
parent e0a6ac9467
commit 983ded3d29
24 changed files with 137 additions and 137 deletions

View file

@ -3,7 +3,7 @@ CC = /usr/bin/g++
CFLAGS = -std=gnu++0x -Wall -Wno-unused-function -g -D_REENTRANT -DVERSION=\"$(VERSION)\" -I.. 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 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 BIN = snapclient
all: client all: client

View file

@ -9,7 +9,7 @@
#include <boost/asio.hpp> #include <boost/asio.hpp>
#include <condition_variable> #include <condition_variable>
#include <set> #include <set>
#include "common/message.h" #include "message/message.h"
using boost::asio::ip::tcp; using boost::asio::ip::tcp;

View file

@ -7,10 +7,10 @@
#include "pcmDecoder.h" #include "pcmDecoder.h"
#include "player.h" #include "player.h"
#include "timeProvider.h" #include "timeProvider.h"
#include "common/serverSettings.h" #include "message/serverSettings.h"
#include "common/timeMsg.h" #include "message/timeMsg.h"
#include "common/requestMsg.h" #include "message/requestMsg.h"
#include "common/ackMsg.h" #include "message/ackMsg.h"
using namespace std; using namespace std;

View file

@ -3,7 +3,7 @@
#include <thread> #include <thread>
#include <atomic> #include <atomic>
#include "common/message.h" #include "message/message.h"
#include "clientConnection.h" #include "clientConnection.h"
#include "decoder.h" #include "decoder.h"
#include "stream.h" #include "stream.h"

View file

@ -1,7 +1,7 @@
#ifndef DECODER_H #ifndef DECODER_H
#define DECODER_H #define DECODER_H
#include "common/pcmChunk.h" #include "message/pcmChunk.h"
#include "common/headerMessage.h" #include "message/headerMessage.h"
class Decoder class Decoder
{ {

View file

@ -154,6 +154,8 @@ void Stream::resetBuffers()
bool Stream::getPlayerChunk(void* outputBuffer, double outputBufferDacTime, unsigned long framesPerBuffer, size_t timeout) bool Stream::getPlayerChunk(void* outputBuffer, double outputBufferDacTime, unsigned long framesPerBuffer, size_t timeout)
{
try
{ {
//cout << "framesPerBuffer: " << framesPerBuffer << "\tms: " << framesPerBuffer*2 / PLAYER_CHUNK_MS_SIZE << "\t" << PLAYER_CHUNK_SIZE << "\n"; //cout << "framesPerBuffer: " << framesPerBuffer << "\tms: " << framesPerBuffer*2 / PLAYER_CHUNK_MS_SIZE << "\t" << PLAYER_CHUNK_SIZE << "\n";
int msBuffer = framesPerBuffer / format_.msRate(); int msBuffer = framesPerBuffer / format_.msRate();
@ -190,10 +192,12 @@ bool Stream::getPlayerChunk(void* outputBuffer, double outputBufferDacTime, unsi
cout << " after: " << sleep << "\n"; cout << " after: " << sleep << "\n";
*/ */
if (!chunk) if (!chunk)
chunk = chunks.pop(); if (!chunks.try_pop(chunk, std::chrono::milliseconds(timeout)))
throw 0;
while (sleep > chunk->getDuration()) 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(); 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); usleep(1000);
@ -214,17 +218,8 @@ bool Stream::getPlayerChunk(void* outputBuffer, double outputBufferDacTime, unsi
} }
long age(0); long age(0);
try
{
age = PcmChunk::getAge(getNextPlayerChunk(outputBuffer, framesPerBuffer, timeout, correction)) - bufferMs + outputBufferDacTime + TimeProvider::getInstance().getDiffToServerMs(); age = PcmChunk::getAge(getNextPlayerChunk(outputBuffer, framesPerBuffer, timeout, correction)) - bufferMs + outputBufferDacTime + TimeProvider::getInstance().getDiffToServerMs();
}
catch(int e)
{
return false;
}
if (sleep == 0) if (sleep == 0)
@ -271,6 +266,11 @@ bool Stream::getPlayerChunk(void* outputBuffer, double outputBufferDacTime, unsi
} }
return true; return true;
} }
catch(int e)
{
return false;
}
}

View file

@ -8,11 +8,11 @@
#include <vector> #include <vector>
#include <memory> #include <memory>
#include "doubleBuffer.h" #include "doubleBuffer.h"
#include "common/message.h" #include "message/message.h"
#include "common/pcmChunk.h" #include "message/pcmChunk.h"
#include "message/sampleFormat.h"
#include "common/timeUtils.h" #include "common/timeUtils.h"
#include "common/queue.h" #include "common/queue.h"
#include "common/sampleFormat.h"
class Stream class Stream

View file

@ -1,7 +1,7 @@
#ifndef HEADER_MESSAGE_H #ifndef HEADER_MESSAGE_H
#define HEADER_MESSAGE_H #define HEADER_MESSAGE_H
#include "common/message.h" #include "message.h"

View file

@ -1,7 +1,7 @@
#ifndef SERVER_SETTINGS_H #ifndef SERVER_SETTINGS_H
#define SERVER_SETTINGS_H #define SERVER_SETTINGS_H
#include "message.h" #include "message/message.h"

View file

@ -3,7 +3,7 @@ CC = /usr/bin/g++
CFLAGS = -std=gnu++0x -Wall -Wno-unused-function -D_REENTRANT -DVERSION=\"$(VERSION)\" -I.. CFLAGS = -std=gnu++0x -Wall -Wno-unused-function -D_REENTRANT -DVERSION=\"$(VERSION)\" -I..
LDFLAGS = -lrt -lpthread -lboost_system -lboost_program_options -lvorbis -lvorbisenc -logg 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 BIN = snapserver
all: server all: server

View file

@ -1,7 +1,7 @@
#include "controlServer.h" #include "controlServer.h"
#include "common/timeMsg.h" #include "message/timeMsg.h"
#include "common/ackMsg.h" #include "message/ackMsg.h"
#include "common/requestMsg.h" #include "message/requestMsg.h"
#include <iostream> #include <iostream>

View file

@ -12,10 +12,10 @@
#include "serverSession.h" #include "serverSession.h"
#include "common/timeUtils.h" #include "common/timeUtils.h"
#include "common/queue.h" #include "common/queue.h"
#include "common/message.h" #include "message/message.h"
#include "common/headerMessage.h" #include "message/headerMessage.h"
#include "common/sampleFormat.h" #include "message/sampleFormat.h"
#include "common/serverSettings.h" #include "message/serverSettings.h"
using boost::asio::ip::tcp; using boost::asio::ip::tcp;

View file

@ -1,8 +1,8 @@
#ifndef ENCODER_H #ifndef ENCODER_H
#define ENCODER_H #define ENCODER_H
#include "common/pcmChunk.h" #include "message/pcmChunk.h"
#include "common/headerMessage.h" #include "message/headerMessage.h"
#include "common/sampleFormat.h" #include "message/sampleFormat.h"
class Encoder class Encoder

View file

@ -9,7 +9,7 @@
#include <boost/asio.hpp> #include <boost/asio.hpp>
#include <condition_variable> #include <condition_variable>
#include <set> #include <set>
#include "common/message.h" #include "message/message.h"
#include "common/queue.h" #include "common/queue.h"

View file

@ -4,10 +4,10 @@
#include "common/timeUtils.h" #include "common/timeUtils.h"
#include "common/signalHandler.h" #include "common/signalHandler.h"
#include "common/utils.h" #include "common/utils.h"
#include "common/sampleFormat.h" #include "message/sampleFormat.h"
#include "../server/pcmEncoder.h" #include "message/message.h"
#include "../server/oggEncoder.h" #include "pcmEncoder.h"
#include "common/message.h" #include "oggEncoder.h"
#include "controlServer.h" #include "controlServer.h"