Skip to content

Instantly share code, notes, and snippets.

@notmasteryet
Created September 25, 2010 01:52
Show Gist options
  • Save notmasteryet/596364 to your computer and use it in GitHub Desktop.
Save notmasteryet/596364 to your computer and use it in GitHub Desktop.
diff -r 54d40057f55a media/libsydneyaudio/src/sydney_audio_mac.c
--- a/media/libsydneyaudio/src/sydney_audio_mac.c Thu Sep 23 20:09:00 2010 -0700
+++ b/media/libsydneyaudio/src/sydney_audio_mac.c Fri Sep 24 20:51:57 2010 -0500
@@ -72,6 +72,7 @@
bool playing;
int64_t bytes_played;
int64_t total_bytes_played;
+ int64_t bytes_lost;
/* audio format info */
unsigned int rate;
@@ -156,6 +157,7 @@
s->playing = FALSE;
s->bytes_played = 0;
s->total_bytes_played = 0;
+ s->bytes_lost = 0;
s->rate = rate;
s->n_channels = n_channels;
s->bytes_per_ch = 2;
@@ -484,6 +486,7 @@
printf("!"); /* not enough audio data */
#endif
memset(dst, 0, bytes_to_copy);
+ s->bytes_lost += bytes_to_copy;
break;
}
free(s->bl_head);
@@ -539,7 +542,7 @@
}
pthread_mutex_lock(&s->mutex);
- *pos = s->total_bytes_played + s->bytes_played;
+ *pos = s->total_bytes_played + s->bytes_played - s->bytes_lost;
pthread_mutex_unlock(&s->mutex);
return SA_SUCCESS;
}
@@ -579,8 +582,9 @@
* The audio device resets its mSampleTime counter after pausing,
* so we need to clear our tracking value to keep that in sync.
*/
- s->total_bytes_played += s->bytes_played;
+ s->total_bytes_played += s->bytes_played - s->bytes_lost;
s->bytes_played = 0;
+ s->bytes_lost = 0;
pthread_mutex_unlock(&s->mutex);
/*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment