[Vorbis-dev] vorbis-tools 1.4.0, ogg123 and MinGW

LM lmemsm at gmail.com
Thu Feb 14 05:18:53 PST 2013


On Wed, Feb 13, 2013 at 5:12 PM, Ralph Giles <giles at thaumas.net> wrote:
> Indeed it is. I've updated the to the latest version of the ACX_PTHREAD
> macro, which includes a similar change. Would you mind testing the code
> from https://svn.xiph.org/trunk/vorbis-tools/ ?

Is there an easy way to get a tarball down?  I don't have svn
installed at present.  If it helps, I downloaded configure.ac,
autogen.sh, Makefile.am, acx_pthread.m4, pkg.m4 and a few other files
that looked like they'd been changed and updated the source from the
1.4.0 tarball with those files.  It does look like these changes fixed
the issue with not finding the pthreads library.  Ran autogen.sh and
./configure and got back:
checking whether pthreads work with -pthread... yes

> The mailing list is good. I'm not aware of any particular instructions
> for building until mingw. Are you using it on Windows, or as a cross
> compiler from Linux?

I'm building it directly on Windows using MinGW (version 4.7.2) from (
http://www.mingw.org ).  Unfortunately, it's getting to the point
where what may compile on one version of MinGW may not compiler on
another (such as a cross-compiler or the 32 and 64 bit versions at
http://mingw-w64.sourceforge.net/ ).

I am able to get vorbis-tools (and ogg123) to build successfully once
I do some patching.  I also wanted to mention, xiph.org has some
really useful libraries and utilities and I'd like to thank the people
that help make them available.

Once pthreads is found, I needed the following changes to the
vorbis-tools 1.4.0 source to get ogg123 to compile with the version of
MinGW I have installed.  If the difference information doesn't come
through in a readable format by e-mail, let me know and I can attempt
to attach as a file and e-mail it or send some other way.  Summary of
changes:  MinGW doesn't have wait.h.  rand and srand replace random
and srandom which aren't available.  Windows has more limited signal
handling than POSIX machines.  Couldn't find NAME_MAX or MAXNAMELEN in
the MinGW include files.  Doesn't have setlinebuf but does have
setvbuf.

diff -Naurp src/vorbis-tools-1.4.0/ogg123/buffer.c
tmp/vorbis-tools-1.4.0/ogg123/buffer.c
--- src/vorbis-tools-1.4.0/ogg123/buffer.c	2010-03-24 04:10:47 -0400
+++ tmp/vorbis-tools-1.4.0/ogg123/buffer.c	
@@ -20,7 +20,9 @@
 #endif

 #include <sys/types.h>
+#ifndef _WIN32
 #include <sys/wait.h>
+#endif
 #include <sys/time.h>
 #include <string.h>
 #include <fcntl.h>
@@ -82,12 +84,14 @@ void buffer_thread_init (buf_t *buf)
   DEBUG("Enter buffer_thread_init");

   /* Block signals to this thread */
+#ifndef _WIN32
   sigfillset(&set);
   sigaddset(&set, SIGINT);
   sigaddset(&set, SIGTSTP);
   sigaddset(&set, SIGCONT);
   if (pthread_sigmask(SIG_BLOCK, &set, NULL) != 0)
     DEBUG("pthread_sigmask failed");
+#endif
 }


diff -Naurp src/vorbis-tools-1.4.0/ogg123/ogg123.c
tmp/vorbis-tools-1.4.0/ogg123/ogg123.c
--- src/vorbis-tools-1.4.0/ogg123/ogg123.c	2010-03-24 04:11:11 -0400
+++ tmp/vorbis-tools-1.4.0/ogg123/ogg123.c	
@@ -51,6 +51,11 @@
 #include "ogg123.h"
 #include "i18n.h"

+#ifdef _WIN32
+#define random rand
+#define srandom srand
+#endif
+
 extern int exit_status; /* from status.c */

 void play (char *source_string);
@@ -120,6 +125,7 @@ void signal_handler (int signo)
     sig_request.exit = 1;
     break;

+#ifndef _WIN32
   case SIGTSTP:
     sig_request.pause = 1;
     /* buffer_Pause (Options.outputOpts.buffer);
@@ -136,9 +142,12 @@ void signal_handler (int signo)
        }
     */
     break;
+#endif

+#ifndef _WIN32
   case SIGCONT:
     break;  /* Don't need to do anything special to resume */
+#endif
   }
 }

@@ -465,8 +474,10 @@ int main(int argc, char **argv)
   /* Setup signal handlers and callbacks */

   signal (SIGINT, signal_handler);
+#ifndef _WIN32
   signal (SIGTSTP, signal_handler);
   signal (SIGCONT, signal_handler);
+#endif
   signal (SIGTERM, signal_handler);

   if (options.remote) {
@@ -646,7 +657,9 @@ void play (char *source_string)
 	if (audio_buffer)
 	  buffer_thread_pause (audio_buffer);

+#ifndef _WIN32
 	kill (getpid(), SIGSTOP); /* We block here until we unpause */
+#endif
 	
 	/* Done pausing */
 	if (audio_buffer)
diff -Naurp src/vorbis-tools-1.4.0/ogg123/playlist.c
tmp/vorbis-tools-1.4.0/ogg123/playlist.c
--- src/vorbis-tools-1.4.0/ogg123/playlist.c	2010-03-24 00:28:47 -0400
+++ tmp/vorbis-tools-1.4.0/ogg123/playlist.c	
@@ -34,6 +34,10 @@
 /* Work with *BSD differences */
 #if !defined(NAME_MAX) && defined(MAXNAMLEN)
 #define NAME_MAX MAXNAMLEN
+#else
+#if !defined(NAME_MAX)
+#define NAME_MAX FILENAME_MAX
+#endif
 #endif

 playlist_element_t *playlist_element_create(char *filename)
diff -Naurp src/vorbis-tools-1.4.0/ogg123/remote.c
tmp/vorbis-tools-1.4.0/ogg123/remote.c
--- src/vorbis-tools-1.4.0/ogg123/remote.c	2010-03-24 04:11:11 -0400
+++ tmp/vorbis-tools-1.4.0/ogg123/remote.c	
@@ -255,7 +255,11 @@ void remote_mainloop(void) {
   char fname[MAXBUF+1];

   /* Need to output line by line! */
+#ifndef _WIN32
   setlinebuf(stdout);
+#else
+  setvbuf(stdout, (char *) NULL, _IONBF, 0);
+#endif

   /* Send a greeting */
   send_msg("R ogg123 from " PACKAGE " " VERSION);


More information about the Vorbis-dev mailing list