diff options
Diffstat (limited to 'src/inputPlugins/audiofile_plugin.c')
-rw-r--r-- | src/inputPlugins/audiofile_plugin.c | 57 |
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); |