struct audio_file* audio_file_open ( const struct vfsref vr  )  [read]

Fill an audio_file struct with the appropiate information and function calls, and open the file handle.

Definition at line 93 of file audio_file.c.

00094 {
00095         const char *ext;
00096         struct audio_file *out = NULL;
00097         unsigned int i;
00098 
00099         out = g_slice_new0(struct audio_file);
00100         
00101         out->fp = vfs_open(vr);
00102         if (out->fp == NULL)
00103                 goto bad;
00104 
00105         /* Store file extension */
00106         if ((ext = strrchr(vfs_filename(vr), '.')) != NULL)
00107                 ext++;
00108 
00109         for (i = 0; i < NUM_FORMATS; i++) {
00110                 if (fseek(out->fp, 0, SEEK_SET) != 0)
00111                         out->stream = 1;
00112 
00113                 if (formats[i].open(out, ext) == 0) {
00114                         /* Assign the format to the file */
00115                         out->drv = &formats[i];
00116                         break;
00117                 }
00118         }
00119 
00120         if (out->drv == NULL) {
00121                 /* No matched format */
00122                 fclose(out->fp);
00123                 goto bad;
00124         }
00125 
00126         /* No tag - just use the display name then */
00127         if (out->title == NULL)
00128                 out->title = g_strdup(vfs_name(vr));
00129 
00130         return (out);
00131 
00132 bad:
00133         g_slice_free(struct audio_file, out);
00134         return (NULL);
00135 }

Here is the call graph for this function:

Here is the caller graph for this function:

 All Data Structures Files Functions Variables Defines
Generated on Mon Mar 15 04:45:03 2010 for herrie by  doxygen 1.6.3