summaryrefslogtreecommitdiff
path: root/cvorbis.c
diff options
context:
space:
mode:
authorGravatar Alexey Yakovenko <wakeroid@gmail.com>2009-07-08 21:30:31 +0200
committerGravatar Alexey Yakovenko <wakeroid@gmail.com>2009-07-08 22:50:46 +0200
commit425f2d8d2b252e027593808a8e297193e2c9f7de (patch)
treee848ed02ac5f68839124ffb4144dbfad31bd4be6 /cvorbis.c
parentbb6da46236137f12be28147f93ea9654c5ccc125 (diff)
[WIP] seamless playback
Diffstat (limited to 'cvorbis.c')
-rw-r--r--cvorbis.c21
1 files changed, 8 insertions, 13 deletions
diff --git a/cvorbis.c b/cvorbis.c
index f8b4e94e..8b3acb6e 100644
--- a/cvorbis.c
+++ b/cvorbis.c
@@ -39,7 +39,7 @@ void
cvorbis_free (void) {
if (file) {
ov_clear (&vorbis_file);
- //fclose (file); -- ov_clear closes it
+ //fclose (file); //-- ov_clear closes it
file = NULL;
vi = NULL;
}
@@ -49,37 +49,32 @@ int
cvorbis_read (char *bytes, int size)
{
if (!file)
- return -1;
+ return 0;
+ int initsize = size;
for (;;)
{
// read ogg
long ret=ov_read (&vorbis_file, bytes, size, 0, 2, 1, &cur_bit_stream);
if (ret < 0)
{
- printf ("WARNING: ogg vorbis decoder tells error %x\n", ret);
- memset (bytes, 0, size);
- return -1;
+ break;
}
else if (ret == 0) {
- if (size > 0) {
- memset (bytes, 0, size);
- }
- return -1;
+ break;
}
else if (ret < size)
{
size -= ret;
bytes += ret;
-// if (ret == 0) {
-// ov_raw_seek (&vorbis_file, 0);
-// }
}
else {
+ size = 0;
break;
}
}
cvorbis.info.position = ov_time_tell(&vorbis_file);
- return 0;
+
+ return initsize - size;
}
int