code blocks

git-svn-id: svn://elaine/murooma/trunk@271 d8a302eb-03bc-478d-80e4-98257eca68ef
This commit is contained in:
(no author) 2014-09-17 06:05:07 +00:00
parent 2cf7855261
commit 16ef1ae634
53 changed files with 2074 additions and 1759 deletions

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_workspace_layout_file>
<ActiveProject path="SnapClient.cbp" />
<PreferredTarget name="Debug" />
<ActiveProject path="SnapServer.cbp" />
<PreferredTarget name="Release" />
</CodeBlocks_workspace_layout_file>

View file

@ -32,13 +32,47 @@
<Add option="-std=c++11" />
<Add option="-Wall" />
<Add option="-fexceptions" />
<Add option="-Wno-unused-function" />
<Add directory="." />
</Compiler>
<Linker>
<Add library="pthread" />
<Add library="boost_system" />
<Add library="boost_program_options" />
<Add library="vorbis" />
<Add library="vorbisenc" />
<Add library="ogg" />
</Linker>
<Unit filename="common/headerMessage.h" />
<Unit filename="common/log.cpp" />
<Unit filename="common/log.h" />
<Unit filename="common/message.h" />
<Unit filename="common/pcmChunk.cpp" />
<Unit filename="common/pcmChunk.h" />
<Unit filename="common/queue.h" />
<Unit filename="common/requestMsg.h" />
<Unit filename="common/sampleFormat.cpp" />
<Unit filename="common/sampleFormat.h" />
<Unit filename="common/serverSettings.h" />
<Unit filename="common/signalHandler.h" />
<Unit filename="common/socketConnection.cpp" />
<Unit filename="common/socketConnection.h" />
<Unit filename="common/timeMsg.h" />
<Unit filename="common/timeUtils.h" />
<Unit filename="common/utils.h" />
<Unit filename="common/wireChunk.h" />
<Unit filename="server/controlServer.cpp" />
<Unit filename="server/controlServer.h" />
<Unit filename="server/encoder.h" />
<Unit filename="server/oggEncoder.cpp" />
<Unit filename="server/oggEncoder.h" />
<Unit filename="server/pcmEncoder.cpp" />
<Unit filename="server/pcmEncoder.h" />
<Unit filename="server/serverConnection.cpp" />
<Unit filename="server/serverConnection.h" />
<Unit filename="server/snapServer.cpp" />
<Unit filename="server/streamServer.cpp" />
<Unit filename="server/streamServer.h" />
<Extensions>
<code_completion />
<debugger />

View file

@ -1,9 +1,154 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_layout_file>
<ActiveTarget name="Debug" />
<File name="server/snapServer.cpp" open="1" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<ActiveTarget name="Release" />
<File name="server/controlServer.h" open="1" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="4599" topLine="167" />
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
<File name="common/requestMsg.h" open="1" top="0" tabpos="9" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
<File name="common/message.h" open="1" top="0" tabpos="16" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
<File name="common/pcmChunk.cpp" open="1" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
<File name="common/log.cpp" open="1" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
<File name="server/oggEncoder.h" open="1" top="0" tabpos="25" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
<File name="common/sampleFormat.cpp" open="1" top="0" tabpos="17" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
<File name="common/wireChunk.h" open="1" top="0" tabpos="26" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
<File name="server/serverConnection.cpp" open="1" top="0" tabpos="12" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
<File name="common/socketConnection.h" open="1" top="0" tabpos="15" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
<File name="common/headerMessage.h" open="1" top="0" tabpos="22" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
<File name="common/timeMsg.h" open="1" top="0" tabpos="10" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
<File name="common/socketConnection.cpp" open="1" top="0" tabpos="21" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
<File name="server/oggEncoder.cpp" open="1" top="0" tabpos="28" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="168" />
</Cursor>
</File>
<File name="server/pcmEncoder.cpp" open="1" top="0" tabpos="11" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
<File name="common/sampleFormat.h" open="1" top="0" tabpos="30" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
<File name="common/log.h" open="1" top="0" tabpos="13" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
<File name="common/pcmChunk.h" open="1" top="0" tabpos="8" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
<File name="server/streamServer.h" open="1" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
<File name="server/encoder.h" open="1" top="0" tabpos="19" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
<File name="common/timeUtils.h" open="1" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
<File name="server/pcmEncoder.h" open="1" top="0" tabpos="23" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
<File name="common/serverSettings.h" open="1" top="0" tabpos="29" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
<File name="server/controlServer.cpp" open="1" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="215" topLine="82" />
</Cursor>
</File>
<File name="common/queue.h" open="1" top="0" tabpos="14" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
<File name="common/utils.h" open="1" top="0" tabpos="30" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
<File name="common/signalHandler.h" open="1" top="0" tabpos="20" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
<File name="server/streamServer.cpp" open="1" top="0" tabpos="24" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
<File name="server/snapServer.cpp" open="1" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="4569" topLine="114" />
</Cursor>
</File>
<File name="server/serverConnection.h" open="1" top="0" tabpos="18" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
</CodeBlocks_layout_file>

View file

@ -32,19 +32,55 @@
<Add option="-std=c++11" />
<Add option="-Wall" />
<Add option="-fexceptions" />
<Add option="-Wno-unused-function" />
<Add directory="." />
</Compiler>
<Linker>
<Add library="pthread" />
<Add library="portaudio" />
<Add library="vorbisenc" />
<Add library="vorbis" />
<Add library="ogg" />
<Add library="asound" />
<Add library="boost_program_options" />
<Add library="boost_system" />
<Add library="pthread" />
</Linker>
<Unit filename="client/clientConnection.cpp" />
<Unit filename="client/clientConnection.h" />
<Unit filename="client/controller.cpp" />
<Unit filename="client/controller.h" />
<Unit filename="client/decoder.h" />
<Unit filename="client/doubleBuffer.h" />
<Unit filename="client/oggDecoder.cpp" />
<Unit filename="client/oggDecoder.h" />
<Unit filename="client/pcmDecoder.cpp" />
<Unit filename="client/pcmDecoder.h" />
<Unit filename="client/player.cpp" />
<Unit filename="client/player.h" />
<Unit filename="client/snapClient.cpp" />
<Unit filename="client/stream.cpp" />
<Unit filename="client/stream.h" />
<Unit filename="common/chunk.cpp" />
<Unit filename="common/chunk.h" />
<Unit filename="client/streamClient.cpp" />
<Unit filename="client/streamClient.h" />
<Unit filename="client/timeProvider.cpp" />
<Unit filename="client/timeProvider.h" />
<Unit filename="common/headerMessage.h" />
<Unit filename="common/log.cpp" />
<Unit filename="common/log.h" />
<Unit filename="common/message.h" />
<Unit filename="common/pcmChunk.cpp" />
<Unit filename="common/pcmChunk.h" />
<Unit filename="common/queue.h" />
<Unit filename="common/requestMsg.h" />
<Unit filename="common/sampleFormat.cpp" />
<Unit filename="common/sampleFormat.h" />
<Unit filename="common/serverSettings.h" />
<Unit filename="common/signalHandler.h" />
<Unit filename="common/socketConnection.cpp" />
<Unit filename="common/socketConnection.h" />
<Unit filename="common/timeMsg.h" />
<Unit filename="common/timeUtils.h" />
<Unit filename="common/utils.h" />
<Unit filename="common/wireChunk.h" />
<Extensions>
<code_completion />
<debugger />

View file

@ -1,19 +1,64 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_layout_file>
<ActiveTarget name="Debug" />
<File name="client/stream.cpp" open="1" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="767" topLine="7" />
</Cursor>
</File>
<File name="client/stream.h" open="1" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<ActiveTarget name="Release" />
<File name="client/player.cpp" open="1" top="0" tabpos="16" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
<File name="common/chunk.h" open="1" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<File name="client/clientConnection.h" open="1" top="0" tabpos="10" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="720" topLine="10" />
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
<File name="client/pcmDecoder.cpp" open="1" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
<File name="common/utils.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="707" topLine="26" />
</Cursor>
</File>
<File name="client/pcmDecoder.h" open="1" top="0" tabpos="17" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
<File name="client/decoder.h" open="1" top="0" tabpos="11" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
<File name="client/timeProvider.cpp" open="1" top="0" tabpos="8" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
<File name="client/controller.cpp" open="1" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
<File name="client/clientConnection.cpp" open="1" top="0" tabpos="9" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
<File name="common/timeUtils.h" open="0" top="0" tabpos="0" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="999" topLine="39" />
</Cursor>
</File>
<File name="client/timeProvider.h" open="1" top="0" tabpos="15" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
<File name="client/streamClient.h" open="1" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
<File name="client/doubleBuffer.h" open="1" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
@ -21,9 +66,39 @@
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
<File name="client/stream.h" open="1" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
<File name="client/snapClient.cpp" open="1" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="2862" topLine="20" />
<Cursor1 position="1647" topLine="39" />
</Cursor>
</File>
<File name="client/controller.h" open="1" top="0" tabpos="13" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
<File name="client/oggDecoder.cpp" open="1" top="0" tabpos="14" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
<File name="client/stream.cpp" open="1" top="1" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="767" topLine="20" />
</Cursor>
</File>
<File name="client/player.h" open="1" top="0" tabpos="18" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="11" />
</Cursor>
</File>
<File name="client/oggDecoder.h" open="1" top="0" tabpos="12" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor>
<Cursor1 position="0" topLine="0" />
</Cursor>
</File>
</CodeBlocks_layout_file>

View file

@ -45,7 +45,10 @@ cout << "connected\n";
}
while(active_)
{
cout << ".";
getNextMessage();
cout << "|";
cout.flush();
}
}
catch (const std::exception& e)

View file

@ -46,7 +46,8 @@ bool OggDecoder::decode(PcmChunk* chunk)
if (result==0)
break; /* need more data */
if(result<0)
{ /* missing or corrupt data at this page position */
{
/* missing or corrupt data at this page position */
fprintf(stderr,"Corrupt or missing data in bitstream; continuing...\n");
continue;
}

View file

@ -131,10 +131,13 @@ void Player::worker()
if (stream_->getPlayerChunk(buff, (float)delay / stream_->format.msRate(), frames, 500))
{
if ((pcm = snd_pcm_writei(pcm_handle, buff, frames)) == -EPIPE) {
if ((pcm = snd_pcm_writei(pcm_handle, buff, frames)) == -EPIPE)
{
printf("XRUN.\n");
snd_pcm_prepare(pcm_handle);
} else if (pcm < 0) {
}
else if (pcm < 0)
{
printf("ERROR. Can't write to PCM device. %s\n", snd_strerror(pcm));
}
}

View file

@ -1,6 +1,7 @@
#include "log.h"
Log::Log(std::string ident, int facility) {
Log::Log(std::string ident, int facility)
{
facility_ = facility;
priority_ = LOG_DEBUG;
strncpy(ident_, ident.c_str(), sizeof(ident_));
@ -9,8 +10,10 @@ Log::Log(std::string ident, int facility) {
openlog(ident_, LOG_PID, facility_);
}
int Log::sync() {
if (buffer_.length()) {
int Log::sync()
{
if (buffer_.length())
{
if (priority_ == dbg)
std::cout << buffer_.c_str();
else
@ -21,16 +24,21 @@ int Log::sync() {
return 0;
}
int Log::overflow(int c) {
if (c != EOF) {
int Log::overflow(int c)
{
if (c != EOF)
{
buffer_ += static_cast<char>(c);
} else {
}
else
{
sync();
}
return c;
}
std::ostream& operator<< (std::ostream& os, const LogPriority& log_priority) {
std::ostream& operator<< (std::ostream& os, const LogPriority& log_priority)
{
static_cast<Log *>(os.rdbuf())->priority_ = (int)log_priority;
if (log_priority == dbg)
os.flush();

View file

@ -7,7 +7,8 @@
#define logd std::clog << dbg
enum LogPriority {
enum LogPriority
{
kLogEmerg = LOG_EMERG, // system is unusable
kLogAlert = LOG_ALERT, // action must be taken immediately
kLogCrit = LOG_CRIT, // critical conditions
@ -21,7 +22,8 @@ enum LogPriority {
std::ostream& operator<< (std::ostream& os, const LogPriority& log_priority);
class Log : public std::basic_streambuf<char, std::char_traits<char> > {
class Log : public std::basic_streambuf<char, std::char_traits<char> >
{
public:
explicit Log(std::string ident, int facility);

View file

@ -22,7 +22,10 @@ public:
uint16_t sampleSize;
uint16_t frameSize;
float msRate() const { return (float)rate/1000.f; }
float msRate() const
{
return (float)rate/1000.f;
}
virtual void read(std::istream& stream)
{

View file

@ -6,9 +6,11 @@
extern bool g_terminated;
void signal_handler(int sig) {
void signal_handler(int sig)
{
switch(sig) {
switch(sig)
{
case SIGHUP:
syslog(LOG_WARNING, "Received SIGHUP signal.");
break;

View file

@ -13,19 +13,22 @@
// trim from start
static inline std::string &ltrim(std::string &s) {
static inline std::string &ltrim(std::string &s)
{
s.erase(s.begin(), std::find_if(s.begin(), s.end(), std::not1(std::ptr_fun<int, int>(std::isspace))));
return s;
}
// trim from end
static inline std::string &rtrim(std::string &s) {
static inline std::string &rtrim(std::string &s)
{
s.erase(std::find_if(s.rbegin(), s.rend(), std::not1(std::ptr_fun<int, int>(std::isspace))).base(), s.end());
return s;
}
// trim from both ends
static inline std::string &trim(std::string &s) {
static inline std::string &trim(std::string &s)
{
return ltrim(rtrim(s));
}