[pulseaudio-commits] r1578 - /branches/lennart/src/pulsecore/sound-file.c
svnmailer-noreply at 0pointer.de
svnmailer-noreply at 0pointer.de
Sun Aug 5 06:52:03 PDT 2007
Author: lennart
Date: Sun Aug 5 15:52:01 2007
New Revision: 1578
URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=3D1578&root=3Dpulseaudio&vi=
ew=3Drev
Log:
minor optimization for cacheing in of samples by using posix_fadvise
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=3D1578&root=3Dpulseaudio&r1=3D1577&r2=3D1578&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 Sun Aug 5 15:52:01 2007
@@ -26,12 +26,16 @@
#endif
=
#include <string.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <errno.h>
=
#include <sndfile.h>
=
#include <pulse/sample.h>
#include <pulsecore/log.h>
#include <pulsecore/macro.h>
+#include <pulsecore/core-error.h>
=
#include "sound-file.h"
#include "core-scache.h"
@@ -49,6 +53,7 @@
size_t l;
sf_count_t (*readf_function)(SNDFILE *sndfile, void *ptr, sf_count_t f=
rames) =3D NULL;
void *ptr =3D NULL;
+ int fd;
=
pa_assert(fname);
pa_assert(ss);
@@ -57,8 +62,20 @@
pa_memchunk_reset(chunk);
memset(&sfinfo, 0, sizeof(sfinfo));
=
- if (!(sf =3D sf_open(fname, SFM_READ, &sfinfo))) {
+ if ((fd =3D open(fname, O_RDONLY|O_NOCTTY)) < 0) {
+ pa_log("Failed to open file %s: %s", fname, pa_cstrerror(errno));
+ goto finish;
+ }
+
+ if (posix_fadvise(fd, 0, 0, POSIX_FADV_SEQUENTIAL) < 0) {
+ pa_log_warn("POSIX_FADV_SEQUENTIAL failed: %s", pa_cstrerror(errno=
));
+ goto finish;
+ } else
+ pa_log_debug("POSIX_FADV_SEQUENTIAL succeeded.");
+ =
+ if (!(sf =3D sf_open_fd(fd, SFM_READ, &sfinfo, 1))) {
pa_log("Failed to open file %s", fname);
+ close(fd);
goto finish;
}
=
More information about the pulseaudio-commits
mailing list