[pulseaudio-commits] r1533 - /branches/lennart/src/pulsecore/sound-file.c

svnmailer-noreply at 0pointer.de svnmailer-noreply at 0pointer.de
Wed Jul 25 08:50:41 PDT 2007


Author: lennart
Date: Wed Jul 25 17:50:40 2007
New Revision: 1533

URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=3D1533&root=3Dpulseaudio&vi=
ew=3Drev
Log:
Modernize things a little bith more

Modified:
    branches/lennart/src/pulsecore/sound-file.c

Modified: branches/lennart/src/pulsecore/sound-file.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulsecore/=
sound-file.c?rev=3D1533&root=3Dpulseaudio&r1=3D1532&r2=3D1533&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
--- branches/lennart/src/pulsecore/sound-file.c (original)
+++ branches/lennart/src/pulsecore/sound-file.c Wed Jul 25 17:50:40 2007
@@ -26,31 +26,35 @@
 #endif
 =

 #include <string.h>
-#include <assert.h>
 =

 #include <sndfile.h>
 =

 #include <pulse/sample.h>
 #include <pulsecore/log.h>
+#include <pulsecore/macro.h>
 =

 #include "sound-file.h"
 #include "core-scache.h"
 =

-int pa_sound_file_load(pa_mempool *pool, const char *fname, pa_sample_spec=
 *ss, pa_channel_map *map, pa_memchunk *chunk) {
-    SNDFILE*sf =3D NULL;
+int pa_sound_file_load(
+        pa_mempool *pool,
+        const char *fname,
+        pa_sample_spec *ss,
+        pa_channel_map *map,
+        pa_memchunk *chunk) {
+    =

+    SNDFILE *sf =3D NULL;
     SF_INFO sfinfo;
     int ret =3D -1;
     size_t l;
     sf_count_t (*readf_function)(SNDFILE *sndfile, void *ptr, sf_count_t f=
rames) =3D NULL;
     void *ptr =3D NULL;
 =

-    assert(fname);
-    assert(ss);
-    assert(chunk);
+    pa_assert(fname);
+    pa_assert(ss);
+    pa_assert(chunk);
 =

-    chunk->memblock =3D NULL;
-    chunk->index =3D chunk->length =3D 0;
-
+    pa_memchunk_reset(chunk);
     memset(&sfinfo, 0, sizeof(sfinfo));
 =

     if (!(sf =3D sf_open(fname, SFM_READ, &sfinfo))) {
@@ -93,13 +97,12 @@
     if (map)
         pa_channel_map_init_auto(map, ss->channels, PA_CHANNEL_MAP_DEFAULT=
);
 =

-    if ((l =3D pa_frame_size(ss)*sfinfo.frames) > PA_SCACHE_ENTRY_SIZE_MAX=
) {
+    if ((l =3D pa_frame_size(ss) * sfinfo.frames) > PA_SCACHE_ENTRY_SIZE_M=
AX) {
         pa_log("File too large");
         goto finish;
     }
 =

     chunk->memblock =3D pa_memblock_new(pool, l);
-    assert(chunk->memblock);
     chunk->index =3D 0;
     chunk->length =3D l;
 =

@@ -125,17 +128,19 @@
         pa_memblock_unref(chunk->memblock);
 =

     return ret;
-
 }
 =

 int pa_sound_file_too_big_to_cache(const char *fname) {
+    =

     SNDFILE*sf =3D NULL;
     SF_INFO sfinfo;
     pa_sample_spec ss;
 =

+    pa_assert(fname);
+    =

     if (!(sf =3D sf_open(fname, SFM_READ, &sfinfo))) {
         pa_log("Failed to open file %s", fname);
-        return 0;
+        return -1;
     }
 =

     sf_close(sf);
@@ -165,8 +170,13 @@
     ss.rate =3D sfinfo.samplerate;
     ss.channels =3D sfinfo.channels;
 =

+    if (!pa_sample_spec_valid(&ss)) {
+        pa_log("Unsupported sample format in file %s", fname);
+        return -1;
+    }
+    =

     if ((pa_frame_size(&ss) * sfinfo.frames) > PA_SCACHE_ENTRY_SIZE_MAX) {
-        pa_log("File too large %s", fname);
+        pa_log("File too large: %s", fname);
         return 1;
     }
 =





More information about the pulseaudio-commits mailing list