aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/cdstatus/cdstatus-0.96.05/cdstatus.patch
diff options
context:
space:
mode:
Diffstat (limited to 'recipes/cdstatus/cdstatus-0.96.05/cdstatus.patch')
-rw-r--r--recipes/cdstatus/cdstatus-0.96.05/cdstatus.patch131
1 files changed, 131 insertions, 0 deletions
diff --git a/recipes/cdstatus/cdstatus-0.96.05/cdstatus.patch b/recipes/cdstatus/cdstatus-0.96.05/cdstatus.patch
new file mode 100644
index 0000000000..913cd721e0
--- /dev/null
+++ b/recipes/cdstatus/cdstatus-0.96.05/cdstatus.patch
@@ -0,0 +1,131 @@
+*** cdstatus-0.96.05/src/cdstatus.c.orig 2005-11-26 16:23:27.000000000 +0100
+--- cdstatus-0.96.05/src/cdstatus.c 2005-11-26 19:06:57.000000000 +0100
+***************
+*** 436,441 ****
+--- 436,501 ----
+ return 0;
+ }
+
++ /* following code copied from
++ http://www.gamedev.net/reference/articles/article2091.asp
++ it has been slightly modified as we did not have a reason to output
++ big endian or float
++ */
++ static short ShortSwap( short s )
++ {
++ unsigned char b1, b2;
++
++ b1 = s & 255;
++ b2 = (s >> 8) & 255;
++
++ return (b1 << 8) + b2;
++ }
++
++ static short ShortNoSwap( short s )
++ {
++ return s;
++ }
++
++ static int LongSwap (int i)
++ {
++ unsigned char b1, b2, b3, b4;
++
++ b1 = i & 255;
++ b2 = ( i >> 8 ) & 255;
++ b3 = ( i>>16 ) & 255;
++ b4 = ( i>>24 ) & 255;
++
++ return ((int)b1 << 24) + ((int)b2 << 16) + ((int)b3 << 8) + b4;
++ }
++
++ static int LongNoSwap( int i )
++ {
++ return i;
++ }
++
++ static short (*LittleShort) ( short s );
++ static int (*LittleLong) ( int i );
++
++ static void InitEndian( void )
++ {
++ char SwapTest[2] = { 1, 0 };
++
++ if( *(short *) SwapTest == 1 )
++ {
++ // little endian
++ //set func pointers to correct funcs
++ LittleShort = ShortNoSwap;
++ LittleLong = LongNoSwap;
++ }
++ else
++ {
++ // big endian
++ LittleShort = ShortSwap;
++ LittleLong = LongSwap;
++ }
++ }
++ /* end of copied code */
++
+ static void writeWavHeader(unsigned int readframes, FILE * audio_out)
+ {
+ long int chunksize;
+***************
+*** 456,478 ****
+
+ wavHeader wHeader;
+
+ /* "RIFF" */
+! wHeader.RIFF_header = 0x46464952;
+
+ chunksize = readframes * CD_FRAMESIZE_RAW;
+! wHeader.total_size = (int32_t)(chunksize + sizeof(wavHeader));
+
+ /* "WAVEfmt " */
+! wHeader.WAVE = 0x45564157;
+! wHeader.fmt = 0x20746D66;
+
+! wHeader.subchunk_size = 16;
+! wHeader.audio_format = 1;
+! wHeader.number_channels = 2;
+! wHeader.sampling_rate = 44100;
+! wHeader.byte_rate = 176400;
+! wHeader.block_align = 4;
+! wHeader.bits_per_sample = 16;
+
+ if(fwrite((const void *) &wHeader, sizeof(wavHeader), (size_t) 1, audio_out)!=1)
+ {
+--- 516,539 ----
+
+ wavHeader wHeader;
+
++ InitEndian();
+ /* "RIFF" */
+! wHeader.RIFF_header = LittleLong(0x46464952);
+
+ chunksize = readframes * CD_FRAMESIZE_RAW;
+! wHeader.total_size = LittleLong((int32_t)(chunksize + sizeof(wavHeader)));
+
+ /* "WAVEfmt " */
+! wHeader.WAVE = LittleLong(0x45564157);
+! wHeader.fmt = LittleLong(0x20746D66);
+
+! wHeader.subchunk_size = LittleLong(16);
+! wHeader.audio_format = LittleShort(1);
+! wHeader.number_channels = LittleShort(2);
+! wHeader.sampling_rate = LittleLong(44100);
+! wHeader.byte_rate = LittleLong(176400);
+! wHeader.block_align = LittleShort(4);
+! wHeader.bits_per_sample = LittleShort(16);
+
+ if(fwrite((const void *) &wHeader, sizeof(wavHeader), (size_t) 1, audio_out)!=1)
+ {
+***************
+*** 492,497 ****
+--- 553,559 ----
+ }
+ exit(EXIT_FAILURE);
+ }
++ chunksize = LittleLong(chunksize);
+ if(fwrite((const void *) &chunksize, sizeof(long int), (size_t) 1, audio_out)!=1)
+ {
+ perror("Error writing wav file chunksize header");