From e7b055f5fe90a205970117878d4648e84e457f68 Mon Sep 17 00:00:00 2001 From: Chris Tallon Date: Fri, 26 Jan 2007 18:06:27 +0000 Subject: [PATCH] Updates for gcc 3.4.5. H3 updates to find mtd device (using kernel 2.4.31) --- GNUmakefile | 11 ++++++----- Makefile.nmake | 8 ++++++++ dsock.cc | 11 +++++++++++ main.cc | 2 +- mtd.h | 2 +- mtdmvp.cc | 37 +++++++++++++++++++++++++++++++++++-- mtdmvp.h | 2 +- mtdwin.cc | 2 +- mtdwin.h | 2 +- player.cc | 6 +++--- player.h | 2 +- playerradio.cc | 4 ++-- playerradio.h | 2 +- vchannellist.cc | 2 +- vradiorec.cc | 16 ++++++++-------- vvideolive.cc | 16 ++++++++-------- vvideorec.cc | 16 ++++++++-------- 17 files changed, 97 insertions(+), 44 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index 3ad83c0..ae83373 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -1,10 +1,11 @@ -CC = /opt/crosstool/powerpc-405-linux-gnu/gcc-2.95.3-glibc-2.2.5/bin/powerpc-405-linux-gnu-g++ +CC=/home/chris/mvp/vomp/compiler/crosstool/gcc-3.4.5-glibc-2.2.5/powerpc-405-linux-gnu/bin/powerpc-405-linux-gnu-g++ +#CC = /opt/crosstool/powerpc-405-linux-gnu/gcc-2.95.3-glibc-2.2.5/bin/powerpc-405-linux-gnu-g++ STRIP = /opt/crosstool/powerpc-405-linux-gnu/gcc-2.95.3-glibc-2.2.5/bin/powerpc-405-linux-gnu-strip CXX = $(CC) INCLUDES = -I../jpeg-6b -CXXFLAGS_DEV = -g -O0 -Wall -Woverloaded-virtual -Wshadow -Werror -DDEV -D_GNU_SOURCE $(INCLUDES) -CXXFLAGS_REL = -O3 -Wall -Woverloaded-virtual -Wshadow -Werror -D_GNU_SOURCE $(INCLUDES) +CXXFLAGS_DEV = -g -O0 -Wall -Wshadow -Werror -DDEV -D_GNU_SOURCE $(INCLUDES) +CXXFLAGS_REL = -O3 -Wall -Wshadow -Werror -D_GNU_SOURCE $(INCLUDES) LDFLAGS = -Wall -static LIBPATHS = @@ -24,7 +25,7 @@ OBJECTS = $(OBJECTS1) $(OBJECTSMVP) default: dev fresh: clean default -vompclient: $(OBJECTS) +vompclient: $(OBJECTS) $(CROSSLIBS) $(CC) $(LDFLAGS) $(LIBPATHS) $(RELEASE) -o vompclient $(OBJECTS) $(CROSSLIBS) $(LIBS) strip: @@ -35,7 +36,7 @@ install: cp vompclient /diskless/nfs/mvp rm -f /diskless/nfs/wmvp/vompclient cp vompclient /diskless/nfs/wmvp - + debug: ../../gdb/gdb-6.3-target-ppc/gdb/gdb /diskless/nfs/mvp/vompclient /diskless/nfs/mvp/core.* diff --git a/Makefile.nmake b/Makefile.nmake index 013c476..52fba99 100644 --- a/Makefile.nmake +++ b/Makefile.nmake @@ -1,3 +1,11 @@ + +############################### + +# ! Chris - WRONG FILE ! + +############################### + + CXXFLAGS_DEV = -g -O0 -Wall -Woverloaded-virtual -Wshadow -Werror -DDEV -D_GNU_SOURCE $(INCLUDES) CXXFLAGS_REL = /I"$(DXSDK_DIR)\Include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "NEW_DEMUXER" /nologo /EHsc /MD /GS /W3 /c /TP LDFLAGS = /INCREMENTAL:NO /NOLOGO /NODEFAULTLIB /SUBSYSTEM:WINDOWS /OPT:REF /OPT:ICF /LIBPATH:"$(DXSDK_DIR)\Lib\x86" diff --git a/dsock.cc b/dsock.cc index af6cf1e..64f35ac 100644 --- a/dsock.cc +++ b/dsock.cc @@ -205,6 +205,15 @@ void DatagramSocket::send(char *ipa, short port, char *message, int length) ULONG DatagramSocket::getIPNumber(ULONG num) { +#ifndef WIN32 + return INADDR_ANY; + + // gcc 3.4 says: + // warning: Using 'gethostbyname' in statically linked applications requires at runtime + // the shared libraries from the glibc version used for linking + +#else + char buffer[100]; ULONG returnaddress; @@ -225,4 +234,6 @@ ULONG DatagramSocket::getIPNumber(ULONG num) int get_ip=(num%num_ip);//Just wrap around, if no interface are present any more memcpy(&returnaddress, hosts->h_addr_list[get_ip], sizeof(ULONG)); return returnaddress; + +#endif } diff --git a/main.cc b/main.cc index b5f56e8..0f96160 100644 --- a/main.cc +++ b/main.cc @@ -190,7 +190,7 @@ int main(int argc, char** argv) shutdown(1); } - success = mtd->init("/dev/mtd1"); + success = mtd->init(); if (success) { logger->log("Core", Log::INFO, "Mtd module initialised"); diff --git a/mtd.h b/mtd.h index 0ab7749..9784a16 100644 --- a/mtd.h +++ b/mtd.h @@ -30,7 +30,7 @@ class Mtd virtual ~Mtd(); static Mtd* getInstance(); - virtual int init(char* device)=0; + virtual int init()=0; virtual int shutdown()=0; virtual short getPALorNTSC()=0; diff --git a/mtdmvp.cc b/mtdmvp.cc index 0860a16..24654ed 100644 --- a/mtdmvp.cc +++ b/mtdmvp.cc @@ -30,14 +30,47 @@ MtdMVP::~MtdMVP() { } -int MtdMVP::init(char* device) +int MtdMVP::init() { if (initted) return 0; initted = 1; + FILE* fp = fopen("/proc/mtd", "r"); + if (!fp) + { + Log::getInstance()->log("MTD", Log::DEBUG, "Could not open /proc/mtd"); + initted = 0; + return 0; + } + + char buffer[1024]; + char mtdNumberChar = '\0'; + + while(!feof(fp)) + { + fgets(buffer, 1023, fp); + if (strstr(buffer, "HCW MediaMVP VPD")) + { + mtdNumberChar = buffer[3]; + } + } + fclose(fp); + + if (mtdNumberChar == '\0') + { + Log::getInstance()->log("MTD", Log::DEBUG, "Failed to find correct /dev/mtdX device"); + initted = 0; + return 0; + } + + strcpy(buffer, "/dev/mtd"); + strncat(buffer, &mtdNumberChar, 1); + Log::getInstance()->log("MTD", Log::DEBUG, "Located MTD device: %s", buffer); + + int fd; - if ((fd = open("/dev/mtd1", O_RDONLY)) < 0) + if ((fd = open(buffer, O_RDONLY)) < 0) { Log::getInstance()->log("MTD", Log::DEBUG, "Open fail"); initted = 0; diff --git a/mtdmvp.h b/mtdmvp.h index 8b110d3..21d6404 100644 --- a/mtdmvp.h +++ b/mtdmvp.h @@ -52,7 +52,7 @@ class MtdMVP : public Mtd MtdMVP(); ~MtdMVP(); - int init(char* device); + int init(); int shutdown(); short getPALorNTSC(); diff --git a/mtdwin.cc b/mtdwin.cc index 51cc3c6..401289d 100644 --- a/mtdwin.cc +++ b/mtdwin.cc @@ -30,7 +30,7 @@ MtdWin::~MtdWin() { } -int MtdWin::init(char* device) +int MtdWin::init() { if (initted) return 0; initted = 1; diff --git a/mtdwin.h b/mtdwin.h index debd5d4..46ffb98 100644 --- a/mtdwin.h +++ b/mtdwin.h @@ -29,7 +29,7 @@ class MtdWin : public Mtd MtdWin(); ~MtdWin(); - virtual int init(char* device); + virtual int init(); virtual int shutdown(); virtual short getPALorNTSC(); diff --git a/player.cc b/player.cc index 20ed763..6266041 100644 --- a/player.cc +++ b/player.cc @@ -260,11 +260,11 @@ void Player::fastBackward() unLock(); } -void Player::jumpToPercent(int percent) +void Player::jumpToPercent(double percent) { lock(); logger->log("Player", Log::DEBUG, "JUMP TO %i%%", percent); - ULONG newFrame = percent * lengthFrames / 100; + ULONG newFrame = (ULONG)(percent * lengthFrames / 100); switchState(S_JUMP, newFrame); // unLock(); - let thread unlock this } @@ -1106,7 +1106,7 @@ void Player::threadFeedScan() // scan has got to the end of what we knew to be there before we started scanning baseFrameNumber = iframeNumber; - frameTimeOffset = abs(iframeNumber - currentFrameNumber) * 1000 / (video->getFPS() * ifactor); + frameTimeOffset = abs((int)iframeNumber - (int)currentFrameNumber) * 1000 / (video->getFPS() * ifactor); #ifndef WIN32 gettimeofday(&clock0, NULL); #else diff --git a/player.h b/player.h index c76eece..666cc17 100644 --- a/player.h +++ b/player.h @@ -65,7 +65,7 @@ class Player : public Thread_TYPE, public Callback void pause(); void fastForward(); void fastBackward(); - void jumpToPercent(int percent); + void jumpToPercent(double percent); void skipForward(int seconds); void skipBackward(int seconds); void jumpToMark(int mark); diff --git a/playerradio.cc b/playerradio.cc index dfe79cf..9f8f6e2 100644 --- a/playerradio.cc +++ b/playerradio.cc @@ -237,11 +237,11 @@ void PlayerRadio::pause() unLock(); } -void PlayerRadio::jumpToPercent(int percent) +void PlayerRadio::jumpToPercent(double percent) { lock(); logger->log("PlayerRadio", Log::DEBUG, "JUMP TO %i%%", percent); - ULONG newPacket = percent * lengthPackets / 100; + ULONG newPacket = (ULONG)(percent * lengthPackets / 100); switchState(S_JUMP, newPacket); unLock(); } diff --git a/playerradio.h b/playerradio.h index ea6ac12..cb4802a 100644 --- a/playerradio.h +++ b/playerradio.h @@ -59,7 +59,7 @@ class PlayerRadio : public Thread_TYPE, public Callback void play(ULONG apid); // Live radio void stop(); void pause(); - void jumpToPercent(int percent); + void jumpToPercent(double percent); void skipForward(int seconds); void skipBackward(int seconds); diff --git a/vchannellist.cc b/vchannellist.cc index e23a7f9..f9aa5d4 100644 --- a/vchannellist.cc +++ b/vchannellist.cc @@ -242,4 +242,4 @@ void VChannelList::processMessage(Message* m) } } } -} \ No newline at end of file +} diff --git a/vradiorec.cc b/vradiorec.cc index 989a37c..8febeb4 100644 --- a/vradiorec.cc +++ b/vradiorec.cc @@ -289,19 +289,19 @@ void VRadioRec::processMessage(Message* m) case Player::CONNECTION_LOST: // connection lost detected { // I can't handle this, send it to command - Message* m = new Message(); - m->to = Command::getInstance(); - m->message = Message::CONNECTION_LOST; - Command::getInstance()->postMessageNoLock(m); + Message* m2 = new Message(); + m2->to = Command::getInstance(); + m2->message = Message::CONNECTION_LOST; + Command::getInstance()->postMessageNoLock(m2); break; } case Player::STOP_PLAYBACK: { // FIXME Obselete ish - improve this - Message* m = new Message(); // Must be done after this thread finishes, and must break into master mutex - m->to = Command::getInstance(); - m->message = Message::STOP_PLAYBACK; - Command::getInstance()->postMessageNoLock(m); + Message* m2 = new Message(); // Must be done after this thread finishes, and must break into master mutex + m2->to = Command::getInstance(); + m2->message = Message::STOP_PLAYBACK; + Command::getInstance()->postMessageNoLock(m2); break; } } diff --git a/vvideolive.cc b/vvideolive.cc index c1703f3..aed1931 100644 --- a/vvideolive.cc +++ b/vvideolive.cc @@ -287,19 +287,19 @@ void VVideoLive::processMessage(Message* m) { Log::getInstance()->log("VVideoLive", Log::DEBUG, "Received connection lost from player"); // I can't handle this, send it to command - Message* m = new Message(); - m->to = Command::getInstance(); - m->message = Message::CONNECTION_LOST; - Command::getInstance()->postMessageNoLock(m); + Message* m2 = new Message(); + m2->to = Command::getInstance(); + m2->message = Message::CONNECTION_LOST; + Command::getInstance()->postMessageNoLock(m2); break; } case Player::STREAM_END: { // I can't handle this, send it to command - improve this - Message* m = new Message(); // Must be done after this thread finishes, and must break into master mutex - m->to = Command::getInstance(); - m->message = Message::STREAM_END; - Command::getInstance()->postMessageNoLock(m); + Message* m2 = new Message(); // Must be done after this thread finishes, and must break into master mutex + m2->to = Command::getInstance(); + m2->message = Message::STREAM_END; + Command::getInstance()->postMessageNoLock(m2); break; } case Player::ASPECT43: diff --git a/vvideorec.cc b/vvideorec.cc index fc13e0c..afe0ef0 100644 --- a/vvideorec.cc +++ b/vvideorec.cc @@ -436,19 +436,19 @@ void VVideoRec::processMessage(Message* m) case Player::CONNECTION_LOST: // connection lost detected { // I can't handle this, send it to command - Message* m = new Message(); - m->to = Command::getInstance(); - m->message = Message::CONNECTION_LOST; - Command::getInstance()->postMessageNoLock(m); + Message* m2 = new Message(); + m2->to = Command::getInstance(); + m2->message = Message::CONNECTION_LOST; + Command::getInstance()->postMessageNoLock(m2); break; } case Player::STOP_PLAYBACK: { // FIXME Obselete ish - improve this - Message* m = new Message(); // Must be done after this thread finishes, and must break into master mutex - m->to = Command::getInstance(); - m->message = Message::STOP_PLAYBACK; - Command::getInstance()->postMessageNoLock(m); + Message* m2 = new Message(); // Must be done after this thread finishes, and must break into master mutex + m2->to = Command::getInstance(); + m2->message = Message::STOP_PLAYBACK; + Command::getInstance()->postMessageNoLock(m2); break; } case Player::ASPECT43: -- 2.39.5