summaryrefslogtreecommitdiff
path: root/apps/codecs/libpcm/ieee_float.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/codecs/libpcm/ieee_float.c')
-rw-r--r--apps/codecs/libpcm/ieee_float.c29
1 files changed, 17 insertions, 12 deletions
diff --git a/apps/codecs/libpcm/ieee_float.c b/apps/codecs/libpcm/ieee_float.c
index c0e91a46cb..0530993f31 100644
--- a/apps/codecs/libpcm/ieee_float.c
+++ b/apps/codecs/libpcm/ieee_float.c
@@ -28,33 +28,38 @@
28 28
29static struct pcm_format *fmt; 29static struct pcm_format *fmt;
30 30
31static bool set_format(struct pcm_format *format, const unsigned char *fmtpos) 31static bool set_format(struct pcm_format *format)
32{ 32{
33 fmt = format; 33 fmt = format;
34 34
35 (void)fmtpos;
36
37 if (fmt->bitspersample != 32 && fmt->bitspersample != 64) 35 if (fmt->bitspersample != 32 && fmt->bitspersample != 64)
38 { 36 {
39 DEBUGF("CODEC_ERROR: ieee float must be 32 or 64 bitspersample %d\n", fmt->bitspersample); 37 DEBUGF("CODEC_ERROR: ieee float must be 32 or 64 bitspersample: %d\n",
38 fmt->bitspersample);
40 return false; 39 return false;
41 } 40 }
42 41
43 fmt->bytespersample = fmt->bitspersample >> 3; 42 fmt->bytespersample = fmt->bitspersample >> 3;
44 fmt->blockalign = fmt->bytespersample; 43 fmt->samplesperblock = fmt->blockalign / (fmt->bytespersample * fmt->channels);
45 44
46 /* chunksize is computed so that one chunk is about 1/50s. */ 45 /* chunksize = about 1/50[sec] data */
47 fmt->chunksize = (ci->id3->frequency * fmt->channels / 50) * fmt->blockalign; 46 fmt->chunksize = (ci->id3->frequency / (50 * fmt->samplesperblock))
47 * fmt->blockalign;
48 48
49 return true; 49 return true;
50} 50}
51 51
52static uint32_t get_seek_pos(long seek_time) 52static struct pcm_pos *get_seek_pos(long seek_time,
53 uint8_t *(*read_buffer)(size_t *realsize))
53{ 54{
54 uint32_t newpos; 55 static struct pcm_pos newpos;
55 56 uint32_t newblock = ((uint64_t)seek_time * ci->id3->frequency)
56 newpos = ((uint64_t)(seek_time * ci->id3->frequency * fmt->channels / 1000LL))*fmt->blockalign; 57 / (1000LL * fmt->samplesperblock);
57 return newpos; 58
59 (void)read_buffer;
60 newpos.pos = newblock * fmt->blockalign;
61 newpos.samples = newblock * fmt->samplesperblock;
62 return &newpos;
58} 63}
59 64
60static int decode(const uint8_t *inbuf, size_t inbufsize, 65static int decode(const uint8_t *inbuf, size_t inbufsize,