Update of /cvsroot/audacity/lib-src/mod-script-pipe
In directory 
23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv30497/lib-src/mod-script-pipe

Modified Files:
        PipeServer.cpp ScripterCallback.cpp 
Added Files:
        Makefile 
Log Message:
Modifications to script plugin:

Include a basic makefile based on one of Leland's. To be able to build the
plugin you need to fill in the Audacity path.

Linux - now there are separate pipes for each direction, same as the Windows 
one.
Incidentally the problem with the second read failing was due to the test 
script.

Temporarily disabled support for getting responses back from Audacity, because 
this isn't yet handled on the Audacity side.



Index: ScripterCallback.cpp
===================================================================
RCS file: /cvsroot/audacity/lib-src/mod-script-pipe/ScripterCallback.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- ScripterCallback.cpp        27 May 2008 16:57:22 -0000      1.4
+++ ScripterCallback.cpp        30 May 2009 04:24:57 -0000      1.5
@@ -48,7 +48,7 @@
 
    // This is an example of an exported variable
 
-typedef SCRIPT_PIPE_DLL_IMPORT int (*tpExecScriptServerFunc)( wxString * pOut, 
wxString * pIn);
+typedef SCRIPT_PIPE_DLL_IMPORT int (*tpExecScriptServerFunc)( wxString * pIn);
 
 
 static tpExecScriptServerFunc pScriptServerFn=NULL;
@@ -64,7 +64,9 @@
    wxString Str1(pIn, wxConvISO8859_1);
    Str1.Replace( wxT("\r"), wxT(""));
    Str1.Replace( wxT("\n"), wxT(""));
-   (*pScriptServerFn)( &Str2, &Str1 );
+   (*pScriptServerFn)( &Str1 );
+
+   /* Responses are disabled for now.
    size_t l = Str2.Length();
    Str2+= wxT('\n');
    aStr.Clear();
@@ -79,6 +81,7 @@
          iStart = i+1;
       }
    }
+   */
 //   wxLogDebug("Added %i Strings", aStr.GetCount());
    return 1;
 }
@@ -129,6 +132,11 @@
    return 4;
 }
 
+int SCRIPT_PIPE_DLL_API ScriptServerResponseFunc( wxString * pOut )
+{
+   //wxLogDebug(wxT(*pOut));
+   return 1;
+}
 
 // This is an example of an exported function.
 int SCRIPT_PIPE_DLL_API ExtensionModuleInit(int ix)
@@ -142,7 +150,7 @@
 
    // Here is proof that the DLL was dynamically loaded and this Init function
    // called.
-   wxDialog Dlg( (wxWindow*)NULL, (wxWindowID)-1, wxT("mod-script-pipe - 
Dialog Loaded by Plug In"), wxPoint(0,0));
+   //wxDialog Dlg( (wxWindow*)NULL, (wxWindowID)-1, wxT("mod-script-pipe - 
Dialog Loaded by Plug In"), wxPoint(0,0));
 
 
 #if 0
@@ -155,10 +163,12 @@
    S.EndStatic();
 #endif
 
+   /*
    Dlg.Fit();
    Dlg.Move( 100,100 );
    int id = Dlg.ShowModal();
-printf("id = %d\n", id);
+   */
+//printf("id = %d\n", id);
    // return -1 for cancel, anything else for OK.
 //   return (id==wxID_CANCEL)?-1:42;
    return 0;

--- NEW FILE: Makefile ---
# -----------------------------------------------------------------------------
# Build mod-script-pipe plugin
#
# EXPERIMENTAL!
# (Based on a Makefile by Leland)
#

# -----------------------------------------------------------------------------
# NOTE: Change this to the base of the Audacity source distribution, or specify
#       via command line or environment
#
AUDACITY_DIR = 

# -----------------------------------------------------------------------------
# NOTE: Set to the names of your objects and final module name
#
OBJS = PipeServer.o ScripterCallback.o
MOD = mod-script-pipe.so

# -----------------------------------------------------------------------------
# NOTE: Set any custom flags you may need
#
CXXFLAGS += -Wall -O9
CXXFLAGS += -DCC_HASVISIBILITY # Normally provided by configure
CXXFLAGS += -DBUILDING_SCRIPT_PIPE
CXXFLAGS += -D__WXDEBUG__ -D__WXGTK__

# -----------------------------------------------------------------------------
# Hopefully the rest is generic enough to satisfy most needs
# -----------------------------------------------------------------------------

CXXFLAGS += -DAUDACITY_DLL_API= -I$(AUDACITY_DIR)/src
CXXFLAGS += ${shell set -x ; sed -e '/override CXXFLAGS/!d;s/override CXXFLAGS 
+= //;s...@$$(top_srcdir)@$(AUDACITY_DIR)@g' $(AUDACITY_DIR)/src/Makefile}

LDFLAGS += ${shell sed -e '/^LIBS/!d;s/LIBS *=//' $(AUDACITY_DIR)/src/Makefile}

SYS = $(shell uname -s)

ifeq ($(SYS),Darwin)
   CXXFLAGS += -arch i386 -arch ppc -isysroot /Developer/SDKs/MacOSX10.4u.sdk 
-mmacosx-version-min=10.4
   LDFLAGS += $(CXXFLAGS) -dynamiclib -undefined suppress
else
   CXXFLAGS += -fPIC -fvisibility=hidden
   LDFLAGS += -shared
endif

LD = g++

all: basecheck $(MOD)

# -----------------------------------------------------------------------------
# Make sure we can get to the Audacity source
#
basecheck:
        @if test -z "$(AUDACITY_DIR)/src/Audacity.h"                   ; \
        then                                                             \
          echo "You need to set AUDACITY_DIR equal to the base"        ; \
          echo "of your Audacity source directory.  You can do"        ; \
          echo "this via an environemnt variable, include it on"       ; \
          echo "the make command line or set it at the top of"         ; \
          echo "the Makefile."                                         ; \
     exit 1                                                       ; \
        fi

# -----------------------------------------------------------------------------
# Build it
#
$(MOD): $(OBJS)
        $(LD) $(LDFLAGS) -o $(MOD) $(OBJS)
        @mkdir -p $(AUDACITY_DIR)/modules
        @cp $(MOD) $(AUDACITY_DIR)/modules
        @echo
        @echo "$(MOD) has been copied to $(AUDACITY_DIR)/modules"
        @echo


# -----------------------------------------------------------------------------
# Cleanup
#
clean:
        -rm $(MOD) $(OBJS)

Index: PipeServer.cpp
===================================================================
RCS file: /cvsroot/audacity/lib-src/mod-script-pipe/PipeServer.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- PipeServer.cpp      27 May 2008 16:57:22 -0000      1.3
+++ PipeServer.cpp      30 May 2009 04:24:56 -0000      1.4
@@ -1,4 +1,3 @@
-
 #if defined(WIN32)
 
 #define WIN32_LEAN_AND_MEAN            // Exclude rarely-used stuff from 
Windows headers
@@ -111,7 +110,7 @@
 #include <unistd.h>
 #include <string.h>
 
-const char fifotmpl[] = "/tmp/audacity_script_pipe.%d";
+const char fifotmpl[] = "/tmp/audacity_script_pipe.%s.%d";
 
 const int nBuff = 1024;
 
@@ -120,39 +119,44 @@
 
 void PipeServer()
 {
-   FILE *fifo = NULL;
+   FILE *fromFifo = NULL;
+   FILE *toFifo = NULL;
    int rc;
    char buf[nBuff];
-   char fifoname[nBuff];
-   
-   sprintf(fifoname, fifotmpl, getuid());
+   char toFifoName[nBuff];
+   char fromFifoName[nBuff];
 
-   rc = mkfifo(fifoname, S_IRWXU);
+   sprintf(toFifoName, fifotmpl, "to", getuid());
+   sprintf(fromFifoName, fifotmpl, "from", getuid());
+
+   unlink(toFifoName);
+   unlink(fromFifoName);
+
+   rc = mkfifo(fromFifoName, S_IRWXU) & mkfifo(toFifoName, S_IRWXU);
    if (rc < 0)
    {
-      perror("Unable to create fifo");
+      perror("Unable to create fifos");
       printf("Ignoring...");
 //      return;
    }
 
-   fifo = fopen(fifoname, "rw");
-   if (fifo == NULL)
+   fromFifo = fopen(fromFifoName, "w");
+   if (fromFifo == NULL)
    {
-      perror("Unable to open fifo");
+      perror("Unable to open fifo from server to script");
       return;
    }
 
-   while (true)
+   toFifo = fopen(toFifoName, "r");
+   if (toFifo == NULL)
    {
-      int len;
-
-      if (fgets(buf, sizeof(buf), fifo) == NULL)
-      {
-         perror("Read failed on fifo");
-         break;
-      }
+      perror("Unable to open fifo to server from script");
+      return;
+   }
 
-      len = strlen(buf);
+   while (fgets(buf, sizeof(buf), toFifo) != NULL)
+   {
+      int len = strlen(buf);
       if (len <= 1)
       {
          continue;
@@ -160,6 +164,7 @@
 
       buf[len - 1] = '\0';
 
+      printf("Server received %s\n", buf);
       DoSrv(buf);
 
       while (true)
@@ -171,18 +176,19 @@
          }
          printf(buf);
 
-         fwrite(buf, 1, len, fifo);
+         fwrite(buf, 1, len, fromFifo);
       }
-
-      // Here until I figure out why the second read fails.
-      break;
    }
 
-   if (fifo != NULL)
-   {
-      fclose(fifo);
-   }
+   printf("Read failed on fifo, quitting\n");
 
-   unlink(fifoname);
+   if (toFifo != NULL)
+      fclose(toFifo);
+
+   if (fromFifo != NULL)
+      fclose(fromFifo);
+
+   unlink(toFifoName);
+   unlink(fromFifoName);
 }
 #endif


------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT 
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, & 
iPhoneDevCamp as they present alongside digital heavyweights like Barbarian 
Group, R/GA, & Big Spaceship. http://p.sf.net/sfu/creativitycat-com 
_______________________________________________
Audacity-cvs mailing list
Audacity-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/audacity-cvs

Reply via email to