Mercurial > audlegacy-plugins
comparison src/sndfile/plugin.c @ 2555:04b1b020be88
VFS file handle was not correctly closed and freed in certain situations,
causing a filehandle shortage and crash. Fixed, based on patch and report
by Teru KAMOGASHIRA.
| author | Matti Hamalainen <ccr@tnsp.org> |
|---|---|
| date | Thu, 08 May 2008 22:16:12 +0300 |
| parents | 8d09a4d017ea |
| children | bd3a24b39058 |
comparison
equal
deleted
inserted
replaced
| 2554:8d09a4d017ea | 2555:04b1b020be88 |
|---|---|
| 93 sf_tell | 93 sf_tell |
| 94 }; | 94 }; |
| 95 | 95 |
| 96 | 96 |
| 97 static SNDFILE * | 97 static SNDFILE * |
| 98 open_sndfile_from_uri(gchar *filename, VFSFile *vfsfile, SF_INFO *tmp_sfinfo) | 98 open_sndfile_from_uri(gchar *filename, VFSFile **vfsfile, SF_INFO *tmp_sfinfo) |
| 99 { | 99 { |
| 100 SNDFILE *snd_file = NULL; | 100 SNDFILE *snd_file = NULL; |
| 101 vfsfile = aud_vfs_fopen(filename, "rb"); | 101 *vfsfile = aud_vfs_fopen(filename, "rb"); |
| 102 | 102 |
| 103 if (vfsfile == NULL) | 103 if (*vfsfile == NULL) |
| 104 return NULL; | 104 return NULL; |
| 105 | 105 |
| 106 snd_file = sf_open_virtual (&sf_virtual_io, SFM_READ, tmp_sfinfo, vfsfile); | 106 snd_file = sf_open_virtual (&sf_virtual_io, SFM_READ, tmp_sfinfo, *vfsfile); |
| 107 if (snd_file == NULL) | 107 if (snd_file == NULL) |
| 108 aud_vfs_fclose(vfsfile); | 108 aud_vfs_fclose(*vfsfile); |
| 109 | 109 |
| 110 return snd_file; | 110 return snd_file; |
| 111 } | 111 } |
| 112 | 112 |
| 113 static void | 113 static void |
| 141 SNDFILE *tmp_sndfile; | 141 SNDFILE *tmp_sndfile; |
| 142 SF_INFO tmp_sfinfo; | 142 SF_INFO tmp_sfinfo; |
| 143 gboolean lossy = FALSE; | 143 gboolean lossy = FALSE; |
| 144 gchar *codec, *format, *subformat; | 144 gchar *codec, *format, *subformat; |
| 145 | 145 |
| 146 tmp_sndfile = open_sndfile_from_uri(filename, vfsfile, &tmp_sfinfo); | 146 tmp_sndfile = open_sndfile_from_uri(filename, &vfsfile, &tmp_sfinfo); |
| 147 if ( sf_get_string(tmp_sndfile, SF_STR_TITLE) == NULL) | 147 if ( sf_get_string(tmp_sndfile, SF_STR_TITLE) == NULL) |
| 148 aud_tuple_associate_string(ti, FIELD_TITLE, NULL, g_path_get_basename(filename)); | 148 aud_tuple_associate_string(ti, FIELD_TITLE, NULL, g_path_get_basename(filename)); |
| 149 else | 149 else |
| 150 aud_tuple_associate_string(ti, FIELD_TITLE, NULL, sf_get_string(tmp_sndfile, SF_STR_TITLE)); | 150 aud_tuple_associate_string(ti, FIELD_TITLE, NULL, sf_get_string(tmp_sndfile, SF_STR_TITLE)); |
| 151 | 151 |
| 349 VFSFile *vfsfile = NULL; | 349 VFSFile *vfsfile = NULL; |
| 350 SNDFILE *tmp_sndfile; | 350 SNDFILE *tmp_sndfile; |
| 351 SF_INFO tmp_sfinfo; | 351 SF_INFO tmp_sfinfo; |
| 352 | 352 |
| 353 /* Have to open the file to see if libsndfile can handle it. */ | 353 /* Have to open the file to see if libsndfile can handle it. */ |
| 354 tmp_sndfile = open_sndfile_from_uri(filename, vfsfile, &tmp_sfinfo); | 354 tmp_sndfile = open_sndfile_from_uri(filename, &vfsfile, &tmp_sfinfo); |
| 355 | 355 |
| 356 if (!tmp_sndfile) | 356 if (!tmp_sndfile) |
| 357 return FALSE; | 357 return FALSE; |
| 358 | 358 |
| 359 /* It can so close file and return TRUE. */ | 359 /* It can so close file and return TRUE. */ |
| 444 return; | 444 return; |
| 445 | 445 |
| 446 pcmbitwidth = 32; | 446 pcmbitwidth = 32; |
| 447 song_title = get_title(playback->filename); | 447 song_title = get_title(playback->filename); |
| 448 | 448 |
| 449 sndfile = open_sndfile_from_uri(playback->filename, vfsfile, &sfinfo); | 449 sndfile = open_sndfile_from_uri(playback->filename, &vfsfile, &sfinfo); |
| 450 | 450 |
| 451 if (!sndfile) | 451 if (!sndfile) |
| 452 return; | 452 return; |
| 453 | 453 |
| 454 bit_rate = sfinfo.samplerate * pcmbitwidth; | 454 bit_rate = sfinfo.samplerate * pcmbitwidth; |
