changeset 1684:a81d0a7d9059 trunk

[svn] - amidi-plug uses vfs now
author giacomo
date Wed, 13 Sep 2006 16:05:01 -0700
parents e9c24e35bd76
children 0ca5a530be95
files ChangeLog Plugins/Input/amidi-plug/amidi-plug.c Plugins/Input/amidi-plug/i_midi.c Plugins/Input/amidi-plug/i_midi.h
diffstat 4 files changed, 32 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Wed Sep 13 15:59:49 2006 -0700
+++ b/ChangeLog	Wed Sep 13 16:05:01 2006 -0700
@@ -1,3 +1,14 @@
+2006-09-13 22:59:49 +0000  Giacomo Lozito <james@develia.org>
+  revision [2303]
+  - File stream API for audacious vfs; uses real getc/ungetc functions for vfs_stdio and emulated functions for vfs_gnome
+
+  Changes:        Modified:
+  +3 -0           trunk/libaudacious/vfs.h  
+  +0 -9           trunk/libaudacious/vfs_common.c  
+  +35 -0          trunk/libaudacious/vfs_gnome.c  
+  +12 -0          trunk/libaudacious/vfs_stdio.c  
+
+
 2006-09-13 21:01:54 +0000  Jonathan Schleifer <js@h3c.de>
   revision [2301]
   Added BSD make to the recommended make versions since it's officially supported now.
--- a/Plugins/Input/amidi-plug/amidi-plug.c	Wed Sep 13 15:59:49 2006 -0700
+++ b/Plugins/Input/amidi-plug/amidi-plug.c	Wed Sep 13 16:05:01 2006 -0700
@@ -31,19 +31,19 @@
 static gint amidiplug_is_our_file( gchar * filename )
 {
 #if defined(MIDIFILE_PROBE_MAGICBYTES)
-    FILE * fp;
+    VFSFile * fp;
     gchar magic_bytes[4];
 
-    fp = fopen( filename , "rb" );
+    fp = vfs_fopen( filename , "rb" );
 
     if ( fp == NULL )
       return FALSE;
 
-    fread( magic_bytes , 1 , 4 , fp );
+    vfs_fread( magic_bytes , 1 , 4 , fp );
 
     if ( !strncmp( magic_bytes , "MThd" , 4 ) )
     {
-      fclose( fp );
+      vfs_fclose( fp );
       DEBUGMSG( "MIDI found, %s is a standard midi file\n" , filename );
       return TRUE;
     }
@@ -52,16 +52,16 @@
     {
       /* skip the four bytes after RIFF,
          then read the next four */
-      fseek( fp , 4 , SEEK_CUR );
-      fread( magic_bytes , 1 , 4 , fp );
+      vfs_fseek( fp , 4 , SEEK_CUR );
+      vfs_fread( magic_bytes , 1 , 4 , fp );
       if ( !strncmp( magic_bytes , "RMID" , 4 ) )
       {
-        fclose( fp );
+        vfs_fclose( fp );
         DEBUGMSG( "MIDI found, %s is a riff midi file\n" , filename );
         return TRUE;
       }
     }
-    fclose( fp );
+    vfs_fclose( fp );
 #else
     gchar * ext = strrchr( filename, '.' );
     /* check the filename extension */
@@ -391,7 +391,7 @@
   }
 
   DEBUGMSG( "PLAY requested, opening file: %s\n" , filename );
-  midifile.file_pointer = fopen( filename , "rb" );
+  midifile.file_pointer = vfs_fopen( filename , "rb" );
   if (!midifile.file_pointer)
   {
     g_warning( "Cannot open %s\n" , filename );
@@ -469,7 +469,7 @@
     }
   }
 
-  fclose( midifile.file_pointer );
+  vfs_fclose( midifile.file_pointer );
   return;
 }
 
--- a/Plugins/Input/amidi-plug/i_midi.c	Wed Sep 13 15:59:49 2006 -0700
+++ b/Plugins/Input/amidi-plug/i_midi.c	Wed Sep 13 16:05:01 2006 -0700
@@ -43,7 +43,7 @@
 gint i_midi_file_read_byte( midifile_t * mf )
 {
   ++mf->file_offset;
-  return getc(mf->file_pointer);
+  return vfs_getc(mf->file_pointer);
 }
 
 
@@ -55,7 +55,7 @@
   value |= i_midi_file_read_byte(mf) << 8;
   value |= i_midi_file_read_byte(mf) << 16;
   value |= i_midi_file_read_byte(mf) << 24;
-  return !feof(mf->file_pointer) ? value : -1;
+  return !vfs_feof(mf->file_pointer) ? value : -1;
 }
 
 
@@ -102,7 +102,7 @@
       }
     }
   }
-  return !feof(mf->file_pointer) ? value : -1;
+  return !vfs_feof(mf->file_pointer) ? value : -1;
 }
 
 
@@ -158,7 +158,7 @@
         last_cmd = cmd;
     } else {
       /* running status */
-      ungetc(c, mf->file_pointer);
+      vfs_ungetc(c, mf->file_pointer);
       mf->file_offset--;
       cmd = last_cmd;
       if (!cmd)
@@ -398,7 +398,7 @@
     {
       gint id = i_midi_file_read_id(mf);
       len = i_midi_file_read_int(mf,4);
-      if ( feof(mf->file_pointer) )
+      if ( vfs_feof(mf->file_pointer) )
       {
         g_warning( "%s: unexpected end of file\n" , mf->file_name );
         return 0;
@@ -447,7 +447,7 @@
     gint id = i_midi_file_read_id(mf);
     gint len = i_midi_file_read_32_le(mf);
 
-    if ( feof(mf->file_pointer) )
+    if ( vfs_feof(mf->file_pointer) )
       return 0;
 
     if ( id == MAKE_ID('d', 'a', 't', 'a') )
@@ -720,7 +720,7 @@
 {
   i_midi_init( mf );
   DEBUGMSG( "PARSE_FROM_FILENAME requested, opening file: %s\n" , filename );
-  mf->file_pointer = fopen( filename , "rb" );
+  mf->file_pointer = vfs_fopen( filename , "rb" );
   if (!mf->file_pointer)
   {
     g_warning( "Cannot open %s\n" , filename );
@@ -758,7 +758,7 @@
       i_midi_setget_length( mf );
 
       /* ok, mf has been filled with information; successfully return */
-      fclose( mf->file_pointer );
+      vfs_fclose( mf->file_pointer );
       return 1;
     }
 
@@ -770,6 +770,6 @@
   }
 
   /* something failed */
-  fclose( mf->file_pointer );
+  vfs_fclose( mf->file_pointer );
   return 0;
 }
--- a/Plugins/Input/amidi-plug/i_midi.h	Wed Sep 13 15:59:49 2006 -0700
+++ b/Plugins/Input/amidi-plug/i_midi.h	Wed Sep 13 16:05:01 2006 -0700
@@ -23,6 +23,7 @@
 
 #include "i_common.h"
 #include "i_midievent.h"
+#include "libaudacious/vfs.h"
 
 #define MAKE_ID(c1, c2, c3, c4) ((c1) | ((c2) << 8) | ((c3) << 16) | ((c4) << 24))
 
@@ -234,7 +235,7 @@
 
 typedef struct
 {
-  FILE * file_pointer;
+  VFSFile * file_pointer;
   gchar * file_name;
   gint file_offset;