aboutsummaryrefslogtreecommitdiffstats
path: root/src/inputPlugins/audiofile_plugin.c
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2008-09-01 16:24:41 -0700
committerEric Wong <normalperson@yhbt.net>2008-09-01 16:24:41 -0700
commitc36029fc806cf083de3aaf1344d6bd2be8db316f (patch)
treeda88b1f073b8125d764b94b924492d2b05ea4c69 /src/inputPlugins/audiofile_plugin.c
parentaa0755f53545fcf343f791f04760f6b934e022e4 (diff)
parent6982a829e22d2bc7cf7c829c4430a4ea6f5bc7fa (diff)
downloadmpd-c36029fc806cf083de3aaf1344d6bd2be8db316f.tar.gz
mpd-c36029fc806cf083de3aaf1344d6bd2be8db316f.tar.xz
mpd-c36029fc806cf083de3aaf1344d6bd2be8db316f.zip
Merge branch 'mk/cleanups'
* mk/cleanups: (60 commits) pass constant pointers const pointers unsigned integers and size_t oggflac: fix GCC warnings include cleanup protect locate.h from double inclusion playlist: eliminate unused fd parameters jack: made "sample_size" static const moved jack configuration to the JackData struct jack: removed unused macros jack: don't set audioOutput->data=NULL jack: initialize JackData in jack_initDriver() jack: added freeJackClient() jack: initialize jd->client after !jd check jack: eliminate superfluous freeJackData() calls mp3: converted the MUTEFRAME_ macros to an enum mp3: converted the DECODE_ constants to an enum wavpack: don't use "isp" before initialization wavpack: moved code to wavpack_open_wvc() simplified code in the ogg decoder plugin ...
Diffstat (limited to 'src/inputPlugins/audiofile_plugin.c')
-rw-r--r--src/inputPlugins/audiofile_plugin.c57
1 files changed, 25 insertions, 32 deletions
diff --git a/src/inputPlugins/audiofile_plugin.c b/src/inputPlugins/audiofile_plugin.c
index 114a87786..fcebf562b 100644
--- a/src/inputPlugins/audiofile_plugin.c
+++ b/src/inputPlugins/audiofile_plugin.c
@@ -22,11 +22,7 @@
#ifdef HAVE_AUDIOFILE
-#include "../utils.h"
-#include "../audio.h"
#include "../log.h"
-#include "../pcm_utils.h"
-#include "../os_compat.h"
#include <audiofile.h>
@@ -51,6 +47,8 @@ static int audiofile_decode(char *path)
int bits;
mpd_uint16 bitRate;
struct stat st;
+ int ret, current = 0;
+ char chunk[CHUNK_SIZE];
if (stat(path, &st) < 0) {
ERROR("failed to stat: %s\n", path);
@@ -88,34 +86,29 @@ static int audiofile_decode(char *path)
fs = (int)afGetVirtualFrameSize(af_fp, AF_DEFAULT_TRACK, 1);
- {
- int ret, eof = 0, current = 0;
- char chunk[CHUNK_SIZE];
-
- while (!eof) {
- if (dc_seek()) {
- dc_action_begin();
- current = dc.seek_where *
- dc.audio_format.sampleRate;
- afSeekFrame(af_fp, AF_DEFAULT_TRACK, current);
- dc_action_end();
- }
-
- ret =
- afReadFrames(af_fp, AF_DEFAULT_TRACK, chunk,
- CHUNK_SIZE / fs);
- if (ret <= 0)
- eof = 1;
- else {
- current += ret;
- ob_send(chunk, ret * fs,
- (float)current /
- (float)dc.audio_format.sampleRate,
- bitRate,
- NULL);
- if (dc_intr())
- break;
- }
+ while (1) {
+ if (dc_seek()) {
+ dc_action_begin();
+ current = dc.seek_where *
+ dc.audio_format.sampleRate;
+ afSeekFrame(af_fp, AF_DEFAULT_TRACK, current);
+ dc_action_end();
+ }
+
+ ret =
+ afReadFrames(af_fp, AF_DEFAULT_TRACK, chunk,
+ CHUNK_SIZE / fs);
+ if (ret <= 0)
+ break;
+ else {
+ current += ret;
+ ob_send(chunk, ret * fs,
+ (float)current /
+ (float)dc.audio_format.sampleRate,
+ bitRate,
+ NULL);
+ if (dc_intr())
+ break;
}
}
afCloseFile(af_fp);