summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Alexey Yakovenko <wakeroid@gmail.com>2009-08-14 18:30:48 +0200
committerGravatar Alexey Yakovenko <wakeroid@gmail.com>2009-08-14 18:30:48 +0200
commited321f2f97b7b9a44fee7846bc15dd31b70241e3 (patch)
tree5029d5a2cc5190d71bd58c35e844eba59bea33ab
parent06c9fe1c21c7de0c9985dff30891d6cf64ed46b8 (diff)
fixing crashbug in mp3 streaming WIP
-rw-r--r--cmp3.c2
-rw-r--r--gtkplaylist.c5
-rw-r--r--palsa.c1
-rw-r--r--streamer.c9
4 files changed, 11 insertions, 6 deletions
diff --git a/cmp3.c b/cmp3.c
index 0b9d97b2..7c63f4d0 100644
--- a/cmp3.c
+++ b/cmp3.c
@@ -544,6 +544,7 @@ cmp3_decode (void) {
char *cache = &buffer.cache[buffer.cachefill];
int i;
+ printf ("decoded %d samples, requested %d bytes, cachefill %d, eof=%f\n", synth.pcm.length, buffer.readsize, buffer.cachefill, eof);
for(i=0;i<synth.pcm.length;i++)
{
if (buffer.readsize > 0) {
@@ -579,6 +580,7 @@ cmp3_decode (void) {
if (buffer.readsize == 0 || eof) {
break;
}
+ printf ("... left to read: %d samples\n", buffer.readsize/2);
// if (buffer.readsize > 0 && endoffile) {
// // fill rest with zeroes, and return -1
// memset (buffer.output, 0, buffer.readsize);
diff --git a/gtkplaylist.c b/gtkplaylist.c
index 2048a9a0..25187132 100644
--- a/gtkplaylist.c
+++ b/gtkplaylist.c
@@ -1069,12 +1069,13 @@ strcopy_special (char *dest, const char *src, int len) {
int
gtkpl_add_file_info_cb (playItem_t *it, void *data) {
static int countdown = 0;
- if (countdown == 0) {
+ //if (countdown == 0)
+ {
GtkEntry *e = (GtkEntry *)data;
GDK_THREADS_ENTER();
gtk_entry_set_text (GTK_ENTRY (e), it->fname);
GDK_THREADS_LEAVE();
- usleep (0);
+ usleep (100);
countdown = 10;
}
countdown--;
diff --git a/palsa.c b/palsa.c
index 171d01ac..975b229d 100644
--- a/palsa.c
+++ b/palsa.c
@@ -319,6 +319,7 @@ palsa_thread (uintptr_t context) {
static void
palsa_callback (char *stream, int len) {
+ printf ("alsa requests %d bytes\n", len);
int bytesread = streamer_read (stream, len);
int ivolume = volume * 1000;
for (int i = 0; i < bytesread/2; i++) {
diff --git a/streamer.c b/streamer.c
index 936fc808..caae48b1 100644
--- a/streamer.c
+++ b/streamer.c
@@ -40,7 +40,7 @@ static int streaming_terminate;
#define STREAM_BUFFER_SIZE 200000
static int streambuffer_fill;
-static char streambuffer[STREAM_BUFFER_SIZE+1000];
+static char streambuffer[STREAM_BUFFER_SIZE];
static uintptr_t mutex;
static int nextsong = -1;
static int nextsong_pstate = -1;
@@ -120,16 +120,17 @@ streamer_thread (uintptr_t ctx) {
if (streambuffer_fill < STREAM_BUFFER_SIZE) {
int sz = STREAM_BUFFER_SIZE - streambuffer_fill;
int minsize = 512;
- if (streambuffer_fill < 16384) {
+// if (streambuffer_fill < 16384) {
minsize = 16384;
- }
+// }
sz = min (minsize, sz);
+ assert ((sz&3) == 0);
int bytesread = streamer_read_async (&streambuffer[streambuffer_fill], sz);
//printf ("req=%d, got=%d\n", sz, bytesread);
streambuffer_fill += bytesread;
}
streamer_unlock ();
- usleep (2000);
+ usleep (6000);
//printf ("fill: %d \r", streambuffer_fill);
}