I'm trying to make an arbitrary large (~1M) sound file loop using KOS 1.3.
All I get for sound, though, is static.
I believe the problem lies with my callback:

Code:
void *sound_callback(snd_stream_hnd_t hnd, int size, int *size_out)
{
   if (size > SND_STREAM_BUFFER_MAX) {
      size = SND_STREAM_BUFFER_MAX;
   }

   /* move old data out of PCM buffer */
   if (last_read > 0) {
                                        printf("moving old data out.\n");
      sound_count -= last_read;
      if (sound_count < 0)                      // prevent underrun
         sound_count = 0;
      memcpy(sound_buffer, sound_buffer+last_read, sound_count);
      sound_ptr = sound_buffer + sound_count;
   }

   /* fill buffer with 4k chunks */
   long num_bytes_copied = 0;
   while (sound_count < size && file_remaining > 0) {           // file_remaining shouldn't be 0
if looping
      if (file_remaining >= 4096) {
         memcpy(sound_ptr, file_ptr, 4096);     // read data from file_buffer into sound_buffer
         file_remaining -= 4096;
         if (file_remaining == 0 && loop == 1)  // if loop is 1, start over
            file_remaining = file_length;

         num_bytes_copied += 4096;
         sound_ptr   += 4096;
         sound_count += 4096;
         file_ptr    += 4096;
      } else {                                  // executes if there is less than 4k in file_remaining
         memcpy(sound_ptr, file_ptr, file_remaining);
         num_bytes_copied  += file_remaining;
         if (loop == 1)
            file_remaining = file_length;       // if loop is set, start from beginning
         else
            file_remaining = 0;                 // if no loop, end it here
         sound_ptr   += file_remaining;
         sound_count += file_remaining;
         file_ptr    += file_remaining;
      }

      //sound_count += num_bytes_copied ;
      //sound_ptr   += num_bytes_copied ;

      if (num_bytes_copied  == 0)
         break;
   }

   if (sound_count > size)
      *size_out = size;
   else
      *size_out = sound_count;

   last_read = *size_out;

   if (num_bytes_copied == 0)
      return NULL;
   else
      return sound_buffer;
}
Any help would be greatly appreciated.
-yeddish