Skip to content

Commit

Permalink
new binary without GUI (no dependencies on X for embedded systems)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaromil committed Aug 22, 2008
1 parent 47437ec commit 119f192
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 24 deletions.
12 changes: 8 additions & 4 deletions Makefile
Expand Up @@ -14,23 +14,27 @@ GTKLIBS = `pkg-config --libs gtk+-2.0`
# debugging flags:
#CPPFLAGS = -I. -Ixmlrpc++ -Wall -g -ggdb $(GTKFLAGS)
# optimized flags:
CPPFLAGS = -I. -Ixmlrpc++ -Wall -O2 -fomit-frame-pointer -ffast-math $(GTKFLAGS)
CPPFLAGS = -I. -Ixmlrpc++ -Wall -O2 -fomit-frame-pointer -ffast-math




LIBS = xmlrpc++/libxmlrpc++.a -lpthread -lssl

IVYSYNC_OBJ = decoder.o thread.o linklist.o utils.o cmdline.o gui.o xmlrpc.o
IVYSYNC_OBJ = decoder.o thread.o linklist.o utils.o cmdline.o xmlrpc.o

all: xmlrpc ivysync
all: xmlrpc ivysync ivysync-nox

xmlrpc:
cd xmlrpc++ && $(MAKE)

ivysync: $(IVYSYNC_OBJ)
ivysync: $(IVYSYNC_OBJ) gui.o
$(CPP) $(CPPFLAGS) -o ivysync $(IVYSYNC_OBJ) $(LIBS) $(GTKLIBS)

ivysync-nox: $(IVYSYNC_OBJ)
$(CPP) $(CPPFLAGS) -o ivysync-nox $(IVYSYNC_OBJ) $(LIBS)


#make clean
clean:
rm -rf *.o *~ ivysync
Expand Down
26 changes: 21 additions & 5 deletions cmdline.cpp
Expand Up @@ -35,7 +35,11 @@
#include <decoder.h>

#include <xmlrpc.h>

#ifdef WITH_GUI
#include <gui.h>
#endif


#include <utils.h>

Expand All @@ -50,16 +54,18 @@ int videobuf = 64;
// our global linklist holding all instantiated decoders
Linklist decoders;

#ifdef WITH_GUI
// graphical interface
Gui *gui;
#endif

// xmlrpc interface
XmlRpcServer *xmlrpc;

// Threaded daemon
IvySyncDaemon *ivydaemon;

char *help =
const char *help =
"Usage: ivysync [-hsDgt] [ -d /dev/video16 [ -p playmode files ] ]\n"
" -h --help show this help\n"
" -t --test dummy testrun: don't open devices\n"
Expand All @@ -68,18 +74,23 @@ char *help =
" -d --device activate a device (i.e. /dev/video16)\n"
" -b --buffer size of video buffer in KB (default 64)\n"
" -p --playmode playlist mode (play|cont|loop|rand)\n"
" -x --xmlrpc run XmlRpc daemon on a network port\n"
" -g --gui start the graphical user interface\n";
#ifdef WITH_GUI
" -g --gui start the graphical user interface\n"
#endif
" -x --xmlrpc run XmlRpc daemon on a network port\n";

const char *short_options = "-hd:sb:x:p:gtD:";

char *short_options = "-hd:sb:x:p:gtD:";
const struct option long_options[] = {
{ "help", no_argument, NULL, 'h'},
{ "device", required_argument, NULL, 'd'},
{ "scan", no_argument, NULL, 's'},
{ "buffer", required_argument, NULL, 'b'},
{ "xmlrpc", required_argument, NULL, 'x'},
{ "playmode", required_argument, NULL, 'p'},
#ifdef WITH_GUI
{ "gui", no_argument, NULL, 'g'},
#endif
{ "test", no_argument, NULL, 't'},
{ "debug", required_argument, NULL, 'D'},
{0, 0, 0, 0}
Expand All @@ -90,7 +101,9 @@ void quitproc (int Sig) { /* signal handling */
N("received signal %u on process %u",Sig,getpid());
A("please wait while quitting threads");

#ifdef WITH_GUI
if(graphical) gtk_main_quit();
#endif

Decoder *dec;
dec = (Decoder*)decoders.begin();
Expand Down Expand Up @@ -122,7 +135,7 @@ int cmdline(int argc, char **argv) {
int c;
int res;

N("IvySync 0.3 / (c)2004-2006 Denis Rojo <jaromil@dyne.org>");
N("IvySync 0.5 / (c)2004-2008 Denis Roio <jaromil@dyne.org>");

do {
res = getopt_long(argc, argv, short_options, long_options, NULL);
Expand Down Expand Up @@ -283,6 +296,8 @@ int main(int argc, char **argv) {
exit(0);
}

#ifdef WITH_GUI

/////////////////////////////////
// setup the graphical interface
if(graphical)
Expand All @@ -305,6 +320,7 @@ int main(int argc, char **argv) {
}
////////////////////////////////

#endif

////////////////////////////////
/// setup the XMLRPC interface
Expand Down
17 changes: 15 additions & 2 deletions decoder.cpp
Expand Up @@ -18,6 +18,9 @@
* Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

#include <stdlib.h>
#include <string.h>

#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
Expand All @@ -29,8 +32,10 @@

#include <decoder.h>
#include <utils.h>
#include <gui.h>

#ifdef WITH_GUI
#include <gui.h>
#endif


Decoder::Decoder()
Expand All @@ -41,7 +46,9 @@ Decoder::Decoder()
playing = false;
stopped = false;
dummy = false;
#ifdef WITH_GUI
gui = false;
#endif
quit = true;

filesize = 0L;
Expand All @@ -59,7 +66,7 @@ Decoder::~Decoder() {
quit = true;
}

bool Decoder::init(char *dev) {
bool Decoder::init(const char *dev) {
int len;

if(dummy) {
Expand Down Expand Up @@ -186,8 +193,10 @@ void Decoder::update() {
}
}

#ifdef WITH_GUI
// refresh the GUI if present
if(gui) gui->refresh();
#endif

}

Expand Down Expand Up @@ -291,8 +300,10 @@ void Decoder::run() {

do { // inner reading loop

#ifdef WITH_GUI
// update the GUI
if(gui) gui->refresh();
#endif

// process asynchronous flags
if(quit || stopped) break;
Expand Down Expand Up @@ -651,6 +662,7 @@ int Decoder::load() {
return c;
}

#ifdef WITH_GUI
int Decoder::save() {
FILE *fd;
char *home = getenv("HOME");
Expand Down Expand Up @@ -693,3 +705,4 @@ int Decoder::save() {
fclose(fd);
return c;
}
#endif
7 changes: 6 additions & 1 deletion decoder.h
Expand Up @@ -51,15 +51,18 @@
// maximum path lenght
#define MAXPATH 512

#ifdef WITH_GUI
class Playlist; // graphical interface
#endif


class Decoder : public Thread, public Entry {

public:
Decoder();
~Decoder();

bool init(char *dev);
bool init(const char *dev);

bool setup(bool *sync, int bufsize);

Expand Down Expand Up @@ -106,7 +109,9 @@ class Decoder : public Thread, public Entry {
Linklist playlist;
Entry *current; ///< path of movie currently playing

#ifdef WITH_GUI
Playlist *gui; ///< pointer to the GUI, NULL if none
#endif

bool dummy; // for dummy test run without devices

Expand Down
2 changes: 1 addition & 1 deletion linklist.h
Expand Up @@ -60,7 +60,7 @@ class Linklist {
Entry *search(char *name);
int *completion(char *needle);

Entry *Linklist::selected();
Entry *selected();

Entry *operator[](int pos) { return pick(pos); };

Expand Down
12 changes: 6 additions & 6 deletions utils.cpp
Expand Up @@ -17,7 +17,7 @@
*/

#include <iostream>
#include <string>
#include <string.h>
#include <cstdio>
#include <stdlib.h>
#include <stdarg.h>
Expand All @@ -44,7 +44,7 @@ int get_debug() {
return(verbosity);
}

void N(char *format, ...) {
void N(const char *format, ...) {
va_list arg;
va_start(arg, format);

Expand All @@ -54,7 +54,7 @@ void N(char *format, ...) {
va_end(arg);
}

void D(char *format, ...) {
void D(const char *format, ...) {
if(verbosity>=FUNC) {
va_list arg;
va_start(arg, format);
Expand All @@ -66,7 +66,7 @@ void D(char *format, ...) {
}
}

void E(char *format, ...) {
void E(const char *format, ...) {
va_list arg;
va_start(arg, format);

Expand All @@ -76,7 +76,7 @@ void E(char *format, ...) {
va_end(arg);
}

void A(char *format, ...) {
void A(const char *format, ...) {
va_list arg;
va_start(arg, format);

Expand All @@ -86,7 +86,7 @@ void A(char *format, ...) {
va_end(arg);
}

void W(char *format, ...) {
void W(const char *format, ...) {
if(verbosity>=WARN) {
va_list arg;
va_start(arg, format);
Expand Down
10 changes: 5 additions & 5 deletions utils.h
Expand Up @@ -24,11 +24,11 @@
void set_debug(int lev);
int get_debug();

void N(char *format, ...);
void A(char *format, ...);
void W(char *format, ...);
void E(char *format, ...);
void D(char *format, ...);
void N(const char *format, ...);
void A(const char *format, ...);
void W(const char *format, ...);
void E(const char *format, ...);
void D(const char *format, ...);

void jsleep(int sec, long nsec);

Expand Down

0 comments on commit 119f192

Please sign in to comment.