diff options
author | 2011-05-20 18:50:41 +0200 | |
---|---|---|
committer | 2011-05-20 18:50:41 +0200 | |
commit | 0f32609233bf3952221e583367291f0b6ba11c39 (patch) | |
tree | 05e0bae6bb8b2502c092ba69f9fa8dea733a5e6a /plugins/sndfile | |
parent | 41a1d2519d3b427532d88c3814d096e48b3afcd9 (diff) |
fixed U8 support in sndfile plugin
Diffstat (limited to 'plugins/sndfile')
-rw-r--r-- | plugins/sndfile/sndfile.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/plugins/sndfile/sndfile.c b/plugins/sndfile/sndfile.c index f5db72d6..a84486fb 100644 --- a/plugins/sndfile/sndfile.c +++ b/plugins/sndfile/sndfile.c @@ -42,6 +42,7 @@ typedef struct { int endsample; int currentsample; int bitrate; + int sf_format; } sndfile_info_t; // vfs wrapper for sf @@ -170,6 +171,7 @@ sndfile_init (DB_fileinfo_t *_info, DB_playItem_t *it) { return -1; } _info->plugin = &plugin; + info->sf_format = inf.format&0x000f; switch (inf.format&0x000f) { case SF_FORMAT_PCM_S8: @@ -265,7 +267,15 @@ sndfile_read (DB_fileinfo_t *_info, char *bytes, int size) { int n = 0; n = sf_read_raw (info->ctx, (short *)bytes, size); + + if (info->sf_format == SF_FORMAT_PCM_U8) { + for (int i = 0; i < n; i++) { + int sample = ((uint8_t *)bytes)[i]; + ((int8_t *)bytes)[i] = sample-0x80; + } + } n /= samplesize; + info->currentsample += n; size = n * samplesize; |