Hello community,

here is the log from the commit of package gramofile for openSUSE:Factory 
checked in at 2012-05-03 10:56:43
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/gramofile (Old)
 and      /work/SRC/openSUSE:Factory/.gramofile.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "gramofile", Maintainer is "[email protected]"

Changes:
--------
--- /work/SRC/openSUSE:Factory/gramofile/gramofile.changes      2011-10-06 
16:03:00.000000000 +0200
+++ /work/SRC/openSUSE:Factory/.gramofile.new/gramofile.changes 2012-05-03 
10:56:56.000000000 +0200
@@ -1,0 +2,18 @@
+Fri Apr 20 16:04:10 CEST 2012 - [email protected]
+
+- Add all patches from debian that we don't already have:
+  20-overflow-fixes.dpatch
+  20-shell-quoting.dpatch
+  20-via-kludge.dpatch
+  20-warning-fixes.dpatch
+  30-basename-fix.dpatch
+  40-fast-swap-and-buffer.dpatch
+  50-cmf3.dpatch
+  60-bplay_in_gramo.dpatch
+  70-endian-fixes.dpatch
+  91_rename_cdrecord_wodim.dpatch
+
+  70-endian-fixes.dpatch is the most important one as it fixes
+  endianess bugs as well as making 64 bit binaries work again.
+
+-------------------------------------------------------------------

New:
----
  20-overflow-fixes.dpatch
  20-shell-quoting.dpatch
  20-via-kludge.dpatch
  20-warning-fixes.dpatch
  30-basename-fix.dpatch
  40-fast-swap-and-buffer.dpatch
  50-cmf3.dpatch
  60-bplay_in_gramo.dpatch
  70-endian-fixes.dpatch
  80_fix_wav_length.dpatch
  91_rename_cdrecord_wodim.dpatch

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ gramofile.spec ++++++
--- /var/tmp/diff_new_pack.r2eWVP/_old  2012-05-03 10:56:57.000000000 +0200
+++ /var/tmp/diff_new_pack.r2eWVP/_new  2012-05-03 10:56:57.000000000 +0200
@@ -1,7 +1,7 @@
 #
 # spec file for package gramofile
 #
-# Copyright (c) 2011 SUSE LINUX Products GmbH, Nuernberg, Germany.
+# Copyright (c) 2012 SUSE LINUX Products GmbH, Nuernberg, Germany.
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -15,23 +15,34 @@
 # Please submit bugfixes or comments via http://bugs.opensuse.org/
 #
 
-# norootforbuild
-
 
 Name:           gramofile
 BuildRequires:  ncurses-devel
+#BuildRequires:  fftw3-devel
 Url:            http://www.opensourcepartners.nl/~costar/gramofile/
 Version:        1.6
-Release:        379
+Release:        0
+Summary:        Digitize Audio Records
 License:        GPL-2.0+
 Group:          Productivity/Multimedia/Sound/Editors and Convertors
-Summary:        Digitize Audio Records
 Source0:        gramofile-%{version}.tar.gz
 Source1:        gramofile.1
 Patch1:         gramofile-1.6-makefiles.dif
 Patch2:         gramofile-codecleanup.dif
-Patch20:        20-no-busy-wait-after-rec.dpatch
-Patch90:        90_report_recording_errors.dpatch
+Patch3:         20-no-busy-wait-after-rec.dpatch
+Patch4:         90_report_recording_errors.dpatch
+Patch5:         20-overflow-fixes.dpatch
+Patch6:         20-shell-quoting.dpatch
+Patch7:         20-via-kludge.dpatch
+Patch8:         20-warning-fixes.dpatch
+Patch9:         30-basename-fix.dpatch
+Patch10:        40-fast-swap-and-buffer.dpatch
+Patch11:        50-cmf3.dpatch
+Patch12:        60-bplay_in_gramo.dpatch
+Patch13:        70-endian-fixes.dpatch
+Patch14:        80_fix_wav_length.dpatch
+Patch15:        91_rename_cdrecord_wodim.dpatch
+
 Provides:       gramofil = %{version}-%{release}
 Obsoletes:      gramofil < %{version}
 BuildRoot:      %{_tmppath}/%{name}-%{version}-build
@@ -53,8 +64,20 @@
 %setup -q
 %patch1 -p1
 %patch2 -p1
-%patch20 -p0
-%patch90 -p0
+%patch3
+%patch4
+%patch5
+%patch6
+%patch7
+%patch8
+%patch9
+%patch10
+# Disable for now, needs to be ported to fftw3
+#%%patch11
+%patch12
+%patch13
+%patch14
+%patch15
 
 %build
 %{__make} %{?_smp_mflags} CC="%__cc"

++++++ 20-no-busy-wait-after-rec.dpatch ++++++
--- /var/tmp/diff_new_pack.r2eWVP/_old  2012-05-03 10:56:57.000000000 +0200
+++ /var/tmp/diff_new_pack.r2eWVP/_new  2012-05-03 10:56:57.000000000 +0200
@@ -1,7 +1,6 @@
 # Do not busy wait for confirmation after recording. [dk]
 #PATCHOPTIONS: -p0
-Index: bplaysrc/shmbuf.c
-===================================================================
+
 --- bplaysrc/shmbuf.c.orig
 +++ bplaysrc/shmbuf.c
 @@ -443,7 +443,7 @@ printw(" %d",cbuff);

++++++ 20-overflow-fixes.dpatch ++++++
# Patch by James Tappin <[email protected]>
# Rediffed into unified format. [dk]

--- signpr_cmf2.c       2011-08-14 13:21:45.869218469 +0200
+++ signpr_cmf2.c       2011-08-14 13:27:14.797217296 +0200
@@ -646,19 +646,25 @@
 
   /* Should be /64, but the signal is extremely soft, so divide by less to
      get more quantization levels (more accurate) */
-  sum.left /= 10;
-  sum.right /= 10;
+  sum.left /= 4;
+  sum.right /= 4;
 #endif
 
-  if (sum.left < 32767)
-    sample.left = sum.left;
-  else
+  if (sum.left > 32767)
     sample.left = 32767;
-
-  if (sum.right < 32767)
-    sample.right = sum.right;
+  else if (sum.left < -32768)
+    sample.left = -32768;
   else
+    sample.left = sum.left;
+
+
+  if (sum.right > 32767)
     sample.right = 32767;
+  else if (sum.right < -32768)
+    sample.right = -32768;
+  else 
+    sample.right = sum.right;
+
 
   return sample;
 }
@@ -762,6 +768,9 @@
     b_t.left;
   if (i > 32767)
     i = 32767;
+  else if (i < -32768)
+    i = -32768;
+
   returnval.left = i;
 
   i = (labs (w_t.right - b_t.right) * 1000)
@@ -769,6 +778,8 @@
     b_t.right;
   if (i > 32767)
     i = 32767;
+  else if (i < -32768)
+    i = -32768;
   returnval.right = i;
 
   return returnval;
++++++ 20-shell-quoting.dpatch ++++++
#Patch by Jon Schewe <[email protected]>

--- playwav.c   2011-08-14 13:21:45.809217714 +0200
+++ playwav.c   2011-08-14 13:27:14.941717336 +0200
@@ -44,11 +44,11 @@
     case FILE_EXISTS:
 
       if (usebeginendtime)
-       sprintf (shellcmd, "bplay_gramo -S -s 44100 -b 16 -J %ld -T %ld %s",
+       sprintf (shellcmd, "bplay_gramo -S -s 44100 -b 16 -J %ld -T %ld \"%s\"",
                 (long) (begintime * 44100),
                 (long) ((endtime - begintime) * 44100), filename);
       else
-       sprintf (shellcmd, "bplay_gramo -S -s 44100 -b 16 %s", filename);
+       sprintf (shellcmd, "bplay_gramo -S -s 44100 -b 16 \"%s\"", filename);
       /* defaults for raw files (but no -r, so .wav's supply their own
          parameters) - you can even listen to executables in CD quality (: */
 
@@ -771,11 +771,11 @@
       def_prog_mode ();                /* save terminal state */
 
       if (usebeginendtime)
-       sprintf (shellcmd, "bplay_gramo -S -s 44100 -b 16 -J %ld -T %ld %s",
+       sprintf (shellcmd, "bplay_gramo -S -s 44100 -b 16 -J %ld -T %ld \"%s\"",
                 (long) (begintime * 44100),
                 (long) ((endtime - begintime) * 44100), filename);
       else
-       sprintf (shellcmd, "bplay_gramo -S -s 44100 -b 16 %s", filename);
+       sprintf (shellcmd, "bplay_gramo -S -s 44100 -b 16 \"%s\"", filename);
       /* defaults for raw files (but no -r, so .wav's supply their own
          parameters */
 

--- reclp_main.c        2011-08-14 13:21:45.817217244 +0200
+++ reclp_main.c        2011-08-14 13:27:14.941717336 +0200
@@ -30,7 +30,7 @@
 
   def_prog_mode ();            /* save terminal state */
 
-  sprintf (shellcmd, "brec_gramo -S -s 44100 -b 16 -t 6000 -w %s",
+  sprintf (shellcmd, "brec_gramo -S -s 44100 -b 16 -t 6000 -w \"%s\"",
           filename);
   system (shellcmd);
 
++++++ 20-via-kludge.dpatch ++++++
# Patch by Joerg Specht <[email protected]>
# Cleaned up some cruft in @@ lines--weird. [dk]

--- bplaysrc/sndfunc.c  2011-08-14 13:21:45.753217822 +0200
+++ bplaysrc/sndfunc.c  2011-08-14 13:27:15.113717191 +0200
@@ -22,6 +22,7 @@
 
 /* Globals */
 int audio, abuf_size, fmt_mask;
+int audio_recorder;
 
 /* Prototypes */
 void sync_audio(void);
@@ -36,6 +37,7 @@
 void init_sound(int recorder)
 {
     /* Attempt to open the audio device */
+    audio_recorder = recorder;
     audio = open(AUDIO, (recorder)? O_RDONLY : O_WRONLY);
     if (audio == -1)
        ErrDie(AUDIO);
@@ -76,6 +78,9 @@
 
 void sync_audio(void)
 {
+    /* at least Linux' via82cxxx_audio-driver reports error    */
+    /* when trying to SNDCTL_DSP_SYNC in O_RDONLY mode         */
     if (ioctl (audio, SNDCTL_DSP_SYNC, NULL) < 0)
+      if (!audio_recorder)
        ErrDie(AUDIO);
 }
++++++ 20-warning-fixes.dpatch ++++++
# Patch by Tom Harvey <[email protected]>
# Rediffed. [dk]
# Also changed return type of bplay.c. [dk]

Index: errorwindow.c
===================================================================
--- errorwindow.c.orig  2012-04-20 15:46:45.454097683 +0200
+++ errorwindow.c       2012-04-20 15:47:57.307364730 +0200
@@ -11,6 +11,7 @@
 #include "buttons.h"
 #include "boxes.h"
 #include "textwindow.h"
+
 #include <string.h>
 #ifndef OLD_CURSES
 #include <ncurses.h>
Index: gramofile.c
===================================================================
--- gramofile.c.orig    2012-04-20 15:46:45.454097683 +0200
+++ gramofile.c 2012-04-20 15:46:45.491096792 +0200
@@ -64,4 +64,5 @@ main (int argc, char *argv[])
   mainmenu (startdir);
 
   finishmenu (0);
+  return 0;
 }
Index: signpr_cmf.c
===================================================================
--- signpr_cmf.c.orig   2012-04-20 15:46:45.454097683 +0200
+++ signpr_cmf.c        2012-04-20 15:46:45.491096792 +0200
@@ -89,8 +89,8 @@ cond_median_param_screen (parampointer_t
   {
     " ^: no neat interpolation.              v: broad ticks not filtered out.  
     ",
     " ^: less ticks detected.                v: not all of tick interpolated.  
     ",
-    " ^: bad following of dynamics.          v: less ticks detected.           
     ",
-    " ^: bad following of dynamics.          v: less ticks detected.           
     ",
+    " ^: bad following of dynamics.          v: fewer ticks detected.          
     ",
+    " ^: bad following of dynamics.          v: fewer ticks detected.          
     ",
     " ^: only strong ticks detected.         v: music-ticks also filtered out. 
     ",
     " Discard changes.                                                         
     ",
     " Reset default values.                                                    
     ",
Index: signpr_cmf2.c
===================================================================
--- signpr_cmf2.c.orig  2012-04-20 15:46:45.473097227 +0200
+++ signpr_cmf2.c       2012-04-20 15:46:45.492096768 +0200
@@ -91,9 +91,9 @@ cond_median2_param_screen (parampointer_
 
   char *helplines[8] =
   {
-    " ^: less ticks detected.                v: not all of tick interpolated.  
     ",
-    " ^: bad following of dynamics.          v: less ticks detected.           
     ",
-    " ^: bad following of dynamics.          v: less ticks detected.           
     ",
+    " ^: fewer ticks detected.               v: not all of tick interpolated.  
     ",
+    " ^: bad following of dynamics.          v: fewer ticks detected.          
     ",
+    " ^: bad following of dynamics.          v: fewer ticks detected.          
     ",
     " ^: detected tick length too short      v: detected tick length longer.   
     ",
     " ^: only strong ticks detected.         v: music-ticks also filtered out. 
     ",
     " Discard changes.                                                         
     ",
++++++ 30-basename-fix.dpatch ++++++
# <30-basename-fix.dpatch> by Daniel Kobras <[email protected]>
#
# Use the POSIX basename(3), get rid of private prototype that wasn't used
# anyway. Remove the now unneeded REDHAT50 define from the Makefile.
#
# Explanation: Previously, the code used glibc's basename but didn't realise
# it was a GNU extension. Alternatively, one could define _GNU_SOURCE, but
# I opted for the--hopefully--more portable POSIX version. (Unlike the GNU
# version, the POSIX version may potentially modify its argument.)

Index: bplaysrc/bplay.c
===================================================================
--- bplaysrc/bplay.c.orig       2012-04-20 15:49:48.068691577 +0200
+++ bplaysrc/bplay.c    2012-04-20 15:51:36.017084288 +0200
@@ -20,6 +20,10 @@
 #include <sys/time.h>
 #include <sys/resource.h>
 
+#ifdef linux
+#include <libgen.h>
+#endif
+
 #ifndef __FreeBSD__
 #include <sys/soundcard.h>
 #else
@@ -53,16 +57,6 @@ int forked;
 
 /* Prototypes */
 
-#ifdef linux
-/* This is in libc, but not in the header files. -- but it IS in
-   Red Hat 5.0.... Libc6?
-   well i'd guess its not in the headers because its nonstandard, i.e.
-   (probably) only exists on linux...  -nox */
-#ifndef REDHAT50
-extern char *basename(char *name);
-#endif
-#endif
-
 void Usage(void);
 void ErrDie(char *err);
 void Die(char *err);
@@ -107,11 +101,14 @@ int main(int argc, char *argv[])
        sndf_t filetype;                /* The file type */
        int mods;                       /* So user can override */
        int optc;                       /* For getopt */
+       char *tmp = NULL;               /* Do not clobber argv[0] */
 
        init_curses();
 
 #ifdef __GLIBC__
-       progname = basename(argv[0]);   /* For errors */
+       tmp = strdup(argv[0]);          /* POSIX basename may modify its arg */
+       progname = basename(tmp);       /* For errors */
+       free(tmp);
 #else
        progname = strrchr(argv[0], '/');  /* Replacement for e.g. FreeBSD */
        if (!progname || !*++progname)
++++++ 40-fast-swap-and-buffer.dpatch ++++++
# Patch by J. Dru Lemley.

Index: Makefile
===================================================================
--- Makefile.orig       2012-04-20 15:53:01.592016038 +0200
+++ Makefile    2012-04-20 15:53:51.999797199 +0200
@@ -28,7 +28,7 @@ LDFLAGS =
 ########## CHOOSE YOUR ARCHITECTURE:    (NOTE: also see bplaysrc/Makefile!)
 
 # For Linux (and maybe others), use these:
-CFLAGS = $(RPM_OPT_FLAGS) -W -Wall -DTURBO_MEDIAN -DTURBO_BUFFER
+CFLAGS = $(RPM_OPT_FLAGS) -funroll-loops -W -Wall -DTURBO_MEDIAN -DTURBO_BUFFER
 DEPS = $(OBJS) makebplay
 LIBS = -lncurses -lm
 COPY_A = -a
Index: endian.h
===================================================================
--- endian.h.orig       2000-03-28 23:07:26.000000000 +0200
+++ endian.h    2012-04-20 15:53:01.647014708 +0200
@@ -8,4 +8,10 @@ extern u_short SwapTwoBytes (u_short);
 extern u_long SwapFourBytes (u_long);
 extern sample_t SwapSample (sample_t);
 
+/* macro to swap endianness of values in a sample_t with */
+/* a few 32-bit operations -- very fast                  */
+#define SWAPSAMPLEREF(s) *((uint32_t *)(s)) = \
+       ((*((uint32_t *)(s)) & 0xff00ff00) >> 8) | \
+       ((*((uint32_t *)(s)) & 0x00ff00ff) << 8)
+
 #endif
Index: signpr_wav.c
===================================================================
--- signpr_wav.c.orig   2000-03-28 23:07:26.000000000 +0200
+++ signpr_wav.c        2012-04-20 15:55:42.566130285 +0200
@@ -22,6 +22,8 @@
 /* ----- SOURCE & READING -------------------------------------------------- */
 
 FILE *sourcefile;
+int num_read_samples_buffered = 0;
+sample_t readsamplebuffer[44100];
 
 int
 openwavsource (char *filename)
@@ -106,6 +108,7 @@ processed.");
     }
 
   /* Well, everything seems to be OK */
+  num_read_samples_buffered = 0;
   return 1;
 }
 
@@ -113,6 +116,7 @@ void
 closewavsource ()
 {
   fclose (sourcefile);
+  num_read_samples_buffered = 0;
 }
 
 int
@@ -121,6 +125,9 @@ seeksamplesource (long samplenumber)
 {
   struct stat buf;
 
+  /* throw away buffer on fseek */
+  num_read_samples_buffered = 0;
+
   if (fstat (fileno (sourcefile), &buf))
     return 0;
 
@@ -136,21 +143,27 @@ seeksamplesource (long samplenumber)
 sample_t
 readsamplesource ()
 {
-  sample_t sample;
+  /* millions of calls to fread sure slow things down.... buffer it a little */
+  static int i;
 
-  if (fread (&sample, 1, 4, sourcefile) != 4)
-    {
-      /* reading after end of file - this just happens when using
-         pre-read buffers! */
-      sample.left = 0;
-      sample.right = 0;
-    }
+  if (i >= num_read_samples_buffered)
+  {
+    num_read_samples_buffered = fread(readsamplebuffer, 4, 
sizeof(readsamplebuffer)/4, sourcefile);
+    i = 0;
+    if (!num_read_samples_buffered)
+      {
+        /* reading after end of file - this just happens when using
+           pre-read buffers! */
+        readsamplebuffer[0].left = 0;
+        readsamplebuffer[0].right = 0;
+       return readsamplebuffer[0];
+      }
+  }
 
 #ifdef SWAP_ENDIAN
-  sample = SwapSample (sample);
+  SWAPSAMPLEREF (readsamplebuffer+i);
 #endif
-
-  return sample;
+  return readsamplebuffer[i++];
 }
 
 
@@ -158,6 +171,8 @@ readsamplesource ()
 
 FILE *destfile;
 int destfileispipe;            /* remember open() - - -> close() */
+int num_write_samples_buffered = 0;
+sample_t writesamplebuffer[44100];
 
 int
 openwavdest (char *filename, long bcount)
@@ -216,12 +231,20 @@ openwavdest (char *filename, long bcount
 
   fwrite (&header, sizeof (header), 1, destfile);
 
+  num_write_samples_buffered = 0;  /* just in case */
   return 1;
 }
 
+void flushwritebuffer()
+{
+       fwrite(writesamplebuffer, 4 * num_write_samples_buffered, 1, destfile);
+       num_write_samples_buffered = 0;
+}
+
 void
 closewavdest ()
 {
+  flushwritebuffer();
   if (destfileispipe)
     pclose (destfile);
   else
@@ -233,8 +256,9 @@ writesampledest (sample_t sample)
 {
 
 #ifdef SWAP_ENDIAN
-  sample = SwapSample (sample);
+  SWAPSAMPLEREF(&sample);
 #endif
-
-  fwrite (&sample, 4, 1, destfile);
+  if (num_write_samples_buffered == (sizeof (writesamplebuffer) / 4))
+       flushwritebuffer();
+  writesamplebuffer[num_write_samples_buffered++] = sample;
 }
++++++ 50-cmf3.dpatch ++++++
++++ 1335 lines (skipped)

++++++ 60-bplay_in_gramo.dpatch ++++++
# Call bplay and brec from dedicated locations rather than from the standard
# path. Good for the Debian package, maybe not that desirable for the
# upstream package. [dk]

--- playwav.c   2011-08-14 13:27:14.941717336 +0200
+++ playwav.c   2011-08-14 13:27:16.193217596 +0200
@@ -32,23 +32,47 @@
 #include <curses.h>
 #endif
 
+#define BPLAYCMD "/usr/lib/bplay_gramo"
 
 void
 playwav_playit (char *filename, int usebeginendtime, double begintime,
                double endtime)
 {
-  char shellcmd[500];
-
+  char shellcmd[500], *tmp;
+  int len, ret;
+  
   switch (checkfile (filename))
     {
     case FILE_EXISTS:
-
+           
+      tmp = shellcmd;
+      len = 500;
+retry:
       if (usebeginendtime)
-       sprintf (shellcmd, "bplay_gramo -S -s 44100 -b 16 -J %ld -T %ld \"%s\"",
+       ret = snprintf (tmp, len,
+                 BPLAYCMD " -S -s 44100 -b 16 -J %ld -T %ld \"%s\"",
                 (long) (begintime * 44100),
                 (long) ((endtime - begintime) * 44100), filename);
       else
-       sprintf (shellcmd, "bplay_gramo -S -s 44100 -b 16 \"%s\"", filename);
+       ret = snprintf (tmp, len,
+                       BPLAYCMD " -S -s 44100 -b 16 \"%s\"", filename);
+
+      if (ret > len)
+        {
+          tmp = alloca(ret);
+          len = ret;
+          if (tmp)
+            goto retry;
+           error_window ("The system ran out of memory");
+          break;
+       }
+          
+      if (ret == -1)
+       {
+          error_window ("Cannot handle file names this long. Sorry.");
+          break;
+       }
+
       /* defaults for raw files (but no -r, so .wav's supply their own
          parameters) - you can even listen to executables in CD quality (: */
 

--- reclp_main.c        2011-08-14 13:27:14.941717336 +0200
+++ reclp_main.c        2011-08-14 13:27:16.193217596 +0200
@@ -18,20 +18,39 @@
 #include <curses.h>
 #endif
 
+#define BRECCMD "/usr/lib/brec_gramo"
 
 void
 record_from_lp (char *startdir)
 {
   char filename[250];
-  char shellcmd[500];
+  char shellcmd[500], *tmp;
+  int ret, len;
 
   if (!record_from_lp_get_filename (startdir, filename))
     return;
 
   def_prog_mode ();            /* save terminal state */
 
-  sprintf (shellcmd, "brec_gramo -S -s 44100 -b 16 -t 6000 -w \"%s\"",
-          filename);
+  tmp = shellcmd;
+  len = 500;
+
+retry:  
+  ret = snprintf (tmp, 500, BRECCMD " -S -s 44100 -b 16 -t 6000 -w \"%s\"",
+                 filename);
+
+  if (ret > len)
+    {
+       tmp = alloca(ret);
+       len = ret;
+       if (tmp)
+         goto retry;
+       return;
+    }
+
+  if (ret == -1)
+    return;
+  
   system (shellcmd);
 
   reset_prog_mode ();          /* reset terminal state */
++++++ 70-endian-fixes.dpatch ++++++
# Fix endianness bugs in WAV and VOC headers on big-endian archs.
# Use POSIX size types to avoid broken headers on 64bit archs.
# Disable padding in structs that read/write raw on-disk data.
# Merged with endianness patch by Tom Harvey <[email protected]>
# [dk]

Index: bplaysrc/bplay.c
===================================================================
--- bplaysrc/bplay.c.orig       2012-04-20 16:01:14.461139421 +0200
+++ bplaysrc/bplay.c    2012-04-20 16:03:12.609289818 +0200
@@ -30,6 +30,30 @@
 #include <machine/soundcard.h>
 #endif
 
+/* Needed for BYTE_ORDER and BIG/LITTLE_ENDIAN macros. */
+#ifndef _BSD_SOURCE
+# define _BSD_SOURCE
+# include <endian.h>
+# undef  _BSD_SOURCE
+#else
+# include <endian.h>
+#endif
+
+#include <sys/types.h>
+#include <byteswap.h>
+
+/* Adapted from the byteorder macros in the Linux kernel. */
+#if BYTE_ORDER == LITTLE_ENDIAN
+#define cpu_to_le32(x) (x)
+#define cpu_to_le16(x) (x)
+#else
+#define cpu_to_le32(x) bswap_32((x))
+#define cpu_to_le16(x) bswap_16((x))
+#endif
+
+#define le32_to_cpu(x) cpu_to_le32((x))
+#define le16_to_cpu(x) cpu_to_le16((x))
+
 #include "fmtheaders.h"
 
 #include "../yesnowindow.h"
@@ -287,23 +311,26 @@ int main(int argc, char *argv[])
                                char *data = "data";
 
                                memcpy(&(header.main_chunk), riff, 4);
-                               header.length = sizeof(wavhead) - 8 + bcount;
+                               header.length = cpu_to_le32(sizeof(wavhead)
+                                               - 8 + bcount);
                                memcpy(&(header.chunk_type), wave, 4);
 
                                memcpy(&(header.sub_chunk), fmt, 4);
-                               header.sc_len = 16;
-                               header.format = 1;
-                               header.modus = stereo + 1;
-                               header.sample_fq = speed;
-                               header.byte_p_sec = ((bits > 8)? 
2:1)*(stereo+1)*speed;
+                               header.sc_len = cpu_to_le32(16);
+                               header.format = cpu_to_le16(1);
+                               header.modus = cpu_to_le16(stereo + 1);
+                               header.sample_fq = cpu_to_le32(speed);
+                               header.byte_p_sec = cpu_to_le32(((bits > 8)?
+                                               2:1)*(stereo+1)*speed);
 /* Correction by J.A. Bezemer: */
-                               header.byte_p_spl = ((bits > 8)? 
2:1)*(stereo+1);
+                               header.byte_p_spl = cpu_to_le16(((bits > 8)?
+                                               2:1)*(stereo+1));
                        /* was: header.byte_p_spl = (bits > 8)? 2:1; */
 
-                               header.bit_p_spl = bits;
+                               header.bit_p_spl = cpu_to_le16(bits);
 
                                memcpy(&(header.data_chunk), data, 4);
-                               header.data_length = bcount;
+                               header.data_length = cpu_to_le32(bcount);
                                write(thefd, &header, sizeof(header));
                        }
                case F_RAW:
@@ -333,9 +360,9 @@ int main(int argc, char *argv[])
 
                                for (i=0;i<20;i++)
                                        header.Magic[i] = VOC_MAGIC[i];
-                               header.BlockOffset = 0x1a;
-                               header.Version = 0x0114;
-                               header.IDCode = 0x111F;
+                               header.BlockOffset = cpu_to_le16(0x1a);
+                               header.Version = cpu_to_le16(0x0114);
+                               header.IDCode = cpu_to_le16(0x111F);
                                write(thefd, &header, sizeof(vochead));
 
                                snd_parm(speed, bits, stereo);
@@ -346,10 +373,10 @@ int main(int argc, char *argv[])
                                ablk.BlockLen[0] = (i + 12) & 0xFF;
                                ablk.BlockLen[1] = ((i + 12) >> 8) & 0xFF;
                                ablk.BlockLen[2] = ((i + 12) >> 16) & 0xFF;
-                               bblk.SamplesPerSec = speed;
+                               bblk.SamplesPerSec = cpu_to_le32(speed);
                                bblk.BitsPerSample = bits;
                                bblk.Channels = stereo + 1;
-                               bblk.Format = (bits == 8)? 0 : 4;
+                               bblk.Format = cpu_to_le16((bits == 8)? 0 : 4);
                                write(thefd, &ablk, sizeof(ablk));
                                write(thefd, &bblk, sizeof(bblk));
                                shmrec(thefd, i, 1);
@@ -473,6 +500,17 @@ long bcount = 0, bjump = 0;
 
     memcpy((void*)&wavhd, (void*)hd_buf, 20);
     count = read(thefd, ((char*)&wavhd)+20, sizeof(wavhd) - 20);
+
+    wavhd.length = le32_to_cpu(wavhd.length);
+    wavhd.sc_len = le32_to_cpu(wavhd.sc_len);
+    wavhd.format = le16_to_cpu(wavhd.format);
+    wavhd.modus = le16_to_cpu(wavhd.modus);
+    wavhd.sample_fq = le32_to_cpu(wavhd.sample_fq);
+    wavhd.byte_p_sec = le32_to_cpu(wavhd.byte_p_sec);
+    wavhd.byte_p_spl = le16_to_cpu(wavhd.byte_p_spl);
+    wavhd.bit_p_spl = le16_to_cpu(wavhd.bit_p_spl);
+    wavhd.data_length = le32_to_cpu(wavhd.data_length);
+
     if(wavhd.format != 1) Die("Input is not a PCM WAV file");
 #ifndef LP2CD
     if (! (mods&MSPEED))
@@ -515,6 +553,11 @@ void playvoc(int thefd, char hd_buf[20])
     fprintf(stderr, "Playing Creative Labs Voice file ...\n");
     memcpy((void*)&vochd, (void*)hd_buf, 20);
     count = read(thefd, ((char*)&vochd)+20, sizeof(vochd) - 20);
+
+    vochd.BlockOffset = le16_to_cpu(vochd.BlockOffset);
+    vochd.Version = le16_to_cpu(vochd.Version);
+    vochd.IDCode = le16_to_cpu(vochd.IDCode);
+
     fprintf(stderr, "Format version %d.%d\n", vochd.Version>>8,
        vochd.Version&0xFF);
     if (vochd.IDCode != (~vochd.Version+0x1234))
@@ -563,6 +606,9 @@ void playvoc(int thefd, char hd_buf[20])
        {
        blockT8 tblock;
        read(thefd, (char*)&tblock, sizeof(tblock));
+
+       tblock.TimeConstant = le16_to_cpu(tblock.TimeConstant);
+
        if(tblock.PackMethod != 0) Die("Non PCM VOC block");
        speed = 256000000/(65536 - tblock.TimeConstant);
        bits = 8;
@@ -575,6 +621,10 @@ void playvoc(int thefd, char hd_buf[20])
        {
        blockT9 tblock;
        read(thefd, (char*)&tblock, sizeof(tblock));
+
+       tblock.SamplesPerSec = le32_to_cpu(tblock.SamplesPerSec);
+       tblock.Format = le16_to_cpu(tblock.Format);
+
        if(tblock.Format != 0 && tblock.Format != 4)
            Die("Non PCM VOC block");
        speed = tblock.SamplesPerSec;
Index: bplaysrc/fmtheaders.h
===================================================================
--- bplaysrc/fmtheaders.h.orig  1997-02-10 21:32:20.000000000 +0100
+++ bplaysrc/fmtheaders.h       2012-04-20 16:02:36.361164344 +0200
@@ -3,44 +3,50 @@
 
 #include <sys/types.h>
 
+#ifdef __GNUC__
+# define PACKED(x)      __attribute__((packed)) x
+#else
+# define PACKED(x)     x
+#endif
+
 /* Definitions for .VOC files */
 
 #define VOC_MAGIC      "Creative Voice File\032"
 
-#define DATALEN(bp)    ((u_long)(bp.BlockLen[0]) | \
-                         ((u_long)(bp.BlockLen[1]) << 8) | \
-                         ((u_long)(bp.BlockLen[2]) << 16) )
+#define DATALEN(bp)    ((u_int32_t)(bp.BlockLen[0]) | \
+                         ((u_int32_t)(bp.BlockLen[1]) << 8) | \
+                         ((u_int32_t)(bp.BlockLen[2]) << 16) )
 
 typedef struct vochead {
-  u_char  Magic[20];   /* must be VOC_MAGIC */
-  u_short BlockOffset; /* Offset to first block from top of file */
-  u_short Version;     /* VOC-file version */
-  u_short IDCode;      /* complement of version + 0x1234 */
-} vochead;
+  u_int8_t  Magic[20]; /* must be VOC_MAGIC */
+  u_int16_t BlockOffset;       /* Offset to first block from top of file */
+  u_int16_t Version;   /* VOC-file version */
+  u_int16_t IDCode;    /* complement of version + 0x1234 */
+} PACKED(vochead);
 
 typedef struct blockTC {
-  u_char  BlockID;
-  u_char  BlockLen[3]; /* low, mid, high byte of length of rest of block */
-} blockTC;
+  u_int8_t  BlockID;
+  u_int8_t  BlockLen[3];       /* low, mid, high byte of length of rest of 
block */
+} PACKED(blockTC);
 
 typedef struct blockT1 {
-  u_char  TimeConstant;
-  u_char  PackMethod;
-} blockT1;
+  u_int8_t  TimeConstant;
+  u_int8_t  PackMethod;
+} PACKED(blockT1);
 
 typedef struct blockT8 {
-  u_short TimeConstant;
-  u_char  PackMethod;
-  u_char  VoiceMode;
-} blockT8;
+  u_int16_t TimeConstant;
+  u_int8_t  PackMethod;
+  u_int8_t  VoiceMode;
+} PACKED(blockT8);
 
 typedef struct blockT9 {
-  u_int   SamplesPerSec;
-  u_char  BitsPerSample;
-  u_char  Channels;
-  u_short Format;
-  u_char   reserved[4];
-} blockT9;
+  u_int32_t SamplesPerSec;
+  u_int8_t  BitsPerSample;
+  u_int8_t  Channels;
+  u_int16_t Format;
+  u_int8_t  reserved[4];
+} PACKED(blockT9);
   
 
 
@@ -51,21 +57,21 @@ typedef struct blockT9 {
    it works on all WAVE-file I have
 */
 typedef struct wavhead {
-  u_long       main_chunk;     /* 'RIFF' */
-  u_long       length;         /* Length of rest of file */
-  u_long       chunk_type;     /* 'WAVE' */
-
-  u_long       sub_chunk;      /* 'fmt ' */
-  u_long       sc_len;         /* length of sub_chunk, =16 (rest of chunk) */
-  u_short      format;         /* should be 1 for PCM-code */
-  u_short      modus;          /* 1 Mono, 2 Stereo */
-  u_long       sample_fq;      /* frequence of sample */
-  u_long       byte_p_sec;
-  u_short      byte_p_spl;     /* samplesize; 1 or 2 bytes */
-  u_short      bit_p_spl;      /* 8, 12 or 16 bit */ 
-
-  u_long       data_chunk;     /* 'data' */
-  u_long       data_length;    /* samplecount (lenth of rest of block?)*/
-} wavhead;
+  u_int32_t    main_chunk;     /* 'RIFF' */
+  u_int32_t    length;         /* Length of rest of file */
+  u_int32_t    chunk_type;     /* 'WAVE' */
+
+  u_int32_t    sub_chunk;      /* 'fmt ' */
+  u_int32_t    sc_len;         /* length of sub_chunk, =16 (rest of chunk) */
+  u_int16_t    format;         /* should be 1 for PCM-code */
+  u_int16_t    modus;          /* 1 Mono, 2 Stereo */
+  u_int32_t    sample_fq;      /* frequence of sample */
+  u_int32_t    byte_p_sec;
+  u_int16_t    byte_p_spl;     /* samplesize; 1 or 2 bytes */
+  u_int16_t    bit_p_spl;      /* 8, 12 or 16 bit */
+
+  u_int32_t    data_chunk;     /* 'data' */
+  u_int32_t    data_length;    /* samplecount (lenth of rest of block?)*/
+} PACKED(wavhead);
 
 #endif
Index: bplaysrc/sndfunc.c
===================================================================
--- bplaysrc/sndfunc.c.orig     2012-04-20 16:01:14.446139781 +0200
+++ bplaysrc/sndfunc.c  2012-04-20 16:01:14.494138625 +0200
@@ -66,6 +66,9 @@ void snd_parm(int speed, int bits, int s
        sync_audio();
 
        /* Set the sample speed, size and stereoness */
+       /* We only use values of 8 and 16 for bits. This implies
+        * unsigned data for 8 bits, and little-endian signed for 16 bits.
+        */
        if (ioctl(audio, SNDCTL_DSP_SAMPLESIZE, &bits) < 0)
            ErrDie(AUDIO);
        if (ioctl(audio, SNDCTL_DSP_STEREO, &stereo) < 0)
Index: endian.c
===================================================================
--- endian.c.orig       2000-03-28 23:07:25.000000000 +0200
+++ endian.c    2012-04-20 16:01:14.494138625 +0200
@@ -24,10 +24,10 @@ SwapTwo (short w)
   return (tmp);
 }
 
-u_long
-SwapFourBytes (u_long dw)
+u_int32_t
+SwapFourBytes (u_int32_t dw)
 {
-  register u_long tmp;
+  register u_int32_t tmp;
   tmp = (dw & 0x000000FF);
   tmp = ((dw & 0x0000FF00) >> 0x08) | (tmp << 0x08);
   tmp = ((dw & 0x00FF0000) >> 0x10) | (tmp << 0x08);
Index: endian.h
===================================================================
--- endian.h.orig       2012-04-20 16:01:14.469139227 +0200
+++ endian.h    2012-04-20 16:01:14.494138625 +0200
@@ -4,8 +4,10 @@
 #ifndef _GETBIG
 #define _GETBIG 1
 
+#include <sys/types.h>
+
 extern u_short SwapTwoBytes (u_short);
-extern u_long SwapFourBytes (u_long);
+extern u_int32_t SwapFourBytes (u_int32_t);
 extern sample_t SwapSample (sample_t);
 
 /* macro to swap endianness of values in a sample_t with */
Index: fmtheaders.h
===================================================================
--- fmtheaders.h.orig   2000-03-28 23:07:26.000000000 +0200
+++ fmtheaders.h        2012-04-20 16:02:18.449596395 +0200
@@ -3,54 +3,50 @@
 
 #include <sys/types.h>
 
+#ifdef __GNUC__
+# define PACKED(x)      __attribute__((packed)) x
+#else
+# define PACKED(x)     x
+#endif
+
 /* Definitions for .VOC files */
 
 #define VOC_MAGIC      "Creative Voice File\032"
 
-#define DATALEN(bp)    ((u_long)(bp.BlockLen[0]) | \
-                         ((u_long)(bp.BlockLen[1]) << 8) | \
-                         ((u_long)(bp.BlockLen[2]) << 16) )
-
-typedef struct vochead
-  {
-    u_char Magic[20];          /* must be VOC_MAGIC */
-    u_short BlockOffset;       /* Offset to first block from top of file */
-    u_short Version;           /* VOC-file version */
-    u_short IDCode;            /* complement of version + 0x1234 */
-  }
-vochead;
-
-typedef struct blockTC
-  {
-    u_char BlockID;
-    u_char BlockLen[3];                /* low, mid, high byte of length of 
rest of block */
-  }
-blockTC;
-
-typedef struct blockT1
-  {
-    u_char TimeConstant;
-    u_char PackMethod;
-  }
-blockT1;
-
-typedef struct blockT8
-  {
-    u_short TimeConstant;
-    u_char PackMethod;
-    u_char VoiceMode;
-  }
-blockT8;
-
-typedef struct blockT9
-  {
-    u_int SamplesPerSec;
-    u_char BitsPerSample;
-    u_char Channels;
-    u_short Format;
-    u_char reserved[4];
-  }
-blockT9;
+#define DATALEN(bp)    ((u_int32_t)(bp.BlockLen[0]) | \
+                         ((u_int32_t)(bp.BlockLen[1]) << 8) | \
+                         ((u_int32_t)(bp.BlockLen[2]) << 16) )
+
+typedef struct vochead {
+  u_int8_t  Magic[20]; /* must be VOC_MAGIC */
+  u_int16_t BlockOffset;       /* Offset to first block from top of file */
+  u_int16_t Version;   /* VOC-file version */
+  u_int16_t IDCode;    /* complement of version + 0x1234 */
+} PACKED(vochead);
+
+typedef struct blockTC {
+  u_int8_t  BlockID;
+  u_int8_t  BlockLen[3];       /* low, mid, high byte of length of rest of 
block */
+} PACKED(blockTC);
+
+typedef struct blockT1 {
+  u_int8_t  TimeConstant;
+  u_int8_t  PackMethod;
+} PACKED(blockT1);
+
+typedef struct blockT8 {
+  u_int16_t TimeConstant;
+  u_int8_t  PackMethod;
+  u_int8_t  VoiceMode;
+} PACKED(blockT8);
+
+typedef struct blockT9 {
+  u_int32_t SamplesPerSec;
+  u_int8_t  BitsPerSample;
+  u_int8_t  Channels;
+  u_int16_t Format;
+  u_int8_t  reserved[4];
+} PACKED(blockT9);
 
 
 
@@ -59,25 +55,23 @@ blockT9;
 /* it's in chunks like .voc and AMIGA iff, but my source say there
    are in only in this combination, so I combined them in one header;
    it works on all WAVE-file I have
- */
-typedef struct wavhead
-  {
-    u_long main_chunk;         /* 'RIFF' */
-    u_long length;             /* Length of rest of file */
-    u_long chunk_type;         /* 'WAVE' */
-
-    u_long sub_chunk;          /* 'fmt ' */
-    u_long sc_len;             /* length of sub_chunk, =16 (rest of chunk) */
-    u_short format;            /* should be 1 for PCM-code */
-    u_short modus;             /* 1 Mono, 2 Stereo */
-    u_long sample_fq;          /* frequence of sample */
-    u_long byte_p_sec;
-    u_short byte_p_spl;                /* samplesize; 1 or 2 bytes */
-    u_short bit_p_spl;         /* 8, 12 or 16 bit */
-
-    u_long data_chunk;         /* 'data' */
-    u_long data_length;                /* samplecount (lenth of rest of 
block?) */
-  }
-wavhead;
+*/
+typedef struct wavhead {
+  u_int32_t    main_chunk;     /* 'RIFF' */
+  u_int32_t    length;         /* Length of rest of file */
+  u_int32_t    chunk_type;     /* 'WAVE' */
+
+  u_int32_t    sub_chunk;      /* 'fmt ' */
+  u_int32_t    sc_len;         /* length of sub_chunk, =16 (rest of chunk) */
+  u_int16_t    format;         /* should be 1 for PCM-code */
+  u_int16_t    modus;          /* 1 Mono, 2 Stereo */
+  u_int32_t    sample_fq;      /* frequence of sample */
+  u_int32_t    byte_p_sec;
+  u_int16_t    byte_p_spl;     /* samplesize; 1 or 2 bytes */
+  u_int16_t    bit_p_spl;      /* 8, 12 or 16 bit */
+
+  u_int32_t    data_chunk;     /* 'data' */
+  u_int32_t    data_length;    /* samplecount (lenth of rest of block?)*/
+} PACKED(wavhead);
 
 #endif
++++++ 80_fix_wav_length.dpatch ++++++
# Add post-recording fixup of length fields in wav header to reflect
# correct file size when recording was stopped prematurely by the user.

--- bplaysrc/bplay.c    2011-08-14 13:27:16.377717882 +0200
+++ bplaysrc/bplay.c    2011-08-14 13:27:16.605717839 +0200
@@ -297,14 +297,14 @@
                        filetype = F_RAW;       /* Change to change default */
                switch(filetype)
                {
+                       wavhead header;
+
                case F_WAV:
                        /* Spit out header here... */
 #ifndef LP2CD
                        fprintf(stderr, "Writing MS WAV sound file");
 #endif
                        {
-                               wavhead header;
-
                                char *riff = "RIFF";
                                char *wave = "WAVE";
                                char *fmt = "fmt ";
@@ -346,6 +346,25 @@
                        initsems(0, 1);
 
                        shmrec(thefd, bcount, 1);
+
+                       /* Rewrite header with updated length fields now
+                        * that we know the true file size. Writing is done
+                        * in a separate process, so it's easiest to gather
+                        * the number of bytes written from fstat(). [dk]
+                        */
+                       if (filetype == F_WAV &&
+                           lseek(thefd, 0, SEEK_SET) != -1) {
+                               struct stat st;
+                               if (fstat(thefd, &st) != -1) {
+                                       header.length = cpu_to_le32(
+                                               (u_int32_t) (st.st_size - 8));
+                                       header.data_length = cpu_to_le32(
+                                               (u_int32_t) (st.st_size -
+                                                       sizeof(header)));
+                                       write(thefd, &header, sizeof(header));
+                               }
+                       }
+                               
                        break;
                case F_VOC:
                        /* Spit out header here... */
++++++ 90_report_recording_errors.dpatch ++++++
--- /var/tmp/diff_new_pack.r2eWVP/_old  2012-05-03 10:56:57.000000000 +0200
+++ /var/tmp/diff_new_pack.r2eWVP/_new  2012-05-03 10:56:57.000000000 +0200
@@ -1,7 +1,6 @@
 # Report errors during recording to the user. [dk]
 #PATCHOPTIONS: -p0
-Index: bplaysrc/shmbuf.c
-===================================================================
+
 --- bplaysrc/shmbuf.c.orig
 +++ bplaysrc/shmbuf.c
 @@ -80,10 +80,12 @@ static char *bigbuff;

++++++ 91_rename_cdrecord_wodim.dpatch ++++++
# This patch removes all occurences of "cdrecord" in the source and 
documentation.
# This includes removing a link to a (not existing anymore) site of Schilling. 
#
# Also changes the packagefile to suggest wodim instead of cdrecord.
#
#  by Tobias Frost, [email protected], 12-31-2006
#PATCHOPTIONS -p1


--- mainmenu.c  2011-08-14 13:27:15.277217351 +0200
+++ mainmenu.c  2011-08-14 13:27:16.945717435 +0200
@@ -219,7 +219,7 @@
 separation points are computed (previous option), separate audio files \
 will be generated, each containing one track.",
 
-    "This option is not implemented yet. You can use the `cdrecord' \
+    "This option is not implemented yet. You can use the `wodim' \
 or `xcdroast' program to create CDs from sound files on the harddisk.",
 
     "(Parts of) sound files can be played with this option."

--- README      2011-08-14 13:21:45.009217561 +0200
+++ README      2011-08-14 13:27:16.945717435 +0200
@@ -217,19 +217,16 @@
 
 Write an audio CD: 
  - This option is not yet implemented. There are some plans to program a
-    uniform user interface to the cdrecord(1) program here. You have to
+    uniform user interface to the wodim(1) program here. You have to
     use the bare program for this moment. Try something like
 
-    cdrecord -v speed=2 dev=0,2,0 -audio -pad track01.wav track02.wav ... 
+    wodim -v speed=2 dev=0,2,0 -audio -pad track01.wav track02.wav ... 
 
-    Actual information on cdrecord may be found on:
-    http://www.fokus.gmd.de/research/cc/glone/employees/
-                                     joerg.schilling/private/cdrecord.html
-
-    If you like a graphical front-end to write CD's, try the xcdroast
-    program:
-    http://www.fh-muenchen.de/rz/xcdroast
-    (Note: you may have to use the wav2cdr utility.)
+    Please check out the wodim package or the cdrkit-doc package for 
+    details.
+    
+    You always can use a graphical front-end to write CD's, like the 
+    xcdroast program. See the xcdroast package for details.
 
 Play an audio file: 
  - Make sure the PCM and Master volumes are set high enough, and your
-- 
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to