media/libsydneyaudio/pause-resume.patch
author Vitor Menezes <vmenezes@mozilla.com>
Wed, 03 Aug 2011 11:30:58 -0700
changeset 74547 88d8bfd7ef647fcdbac1fdf3d3f819d554599846
parent 28483 8cae9be96140390727d4e69d92b2cb76f2f21255
permissions -rw-r--r--
Only override font properties when in quirks mode. (Bug 403524) r=dbaron Font tags cause NS_STYLE_TEXT_DECORATION_LINE_OVERRIDE_ALL in quirks mode only, so that standards mode (in which font tags don't cause the override) can use the same codepath in the near future.

diff --git a/media/libsydneyaudio/src/sydney_audio_alsa.c b/media/libsydneyaudio/src/sydney_audio_alsa.c
index a57f640..5c2f113 100644
--- a/media/libsydneyaudio/src/sydney_audio_alsa.c
+++ b/media/libsydneyaudio/src/sydney_audio_alsa.c
@@ -307,9 +307,9 @@ sa_stream_pause(sa_stream_t *s) {
   if (s == NULL || s->output_unit == NULL) {
     return SA_ERROR_NO_INIT;
   }
-#if 0 /* TODO */
-  AudioOutputUnitStop(s->output_unit);
-#endif
+
+  if (snd_pcm_pause(s->output_unit, 1) != 0)
+    return SA_ERROR_NOT_SUPPORTED;
 
   return SA_SUCCESS;
 }
@@ -322,12 +322,8 @@ sa_stream_resume(sa_stream_t *s) {
     return SA_ERROR_NO_INIT;
   }
 
-  /*
-   * The audio device resets its mSampleTime counter after pausing,
-   * so we need to clear our tracking value to keep that in sync.
-   */
-  s->bytes_played = s->bytes_written = 0;
-
+  if (snd_pcm_pause(s->output_unit, 0) != 0)
+    return SA_ERROR_NOT_SUPPORTED;
   return SA_SUCCESS;
 }
 
diff --git a/media/libsydneyaudio/src/sydney_audio_mac.c b/media/libsydneyaudio/src/sydney_audio_mac.c
index 8a7621c..d0fa148 100644
--- a/media/libsydneyaudio/src/sydney_audio_mac.c
+++ b/media/libsydneyaudio/src/sydney_audio_mac.c
@@ -70,6 +70,7 @@ struct sa_stream {
   pthread_mutex_t   mutex;
   bool              playing;
   int64_t           bytes_played;
+  int64_t           total_bytes_played;
 
   /* audio format info */
   unsigned int      rate;
@@ -153,6 +154,7 @@ sa_stream_create_pcm(
   s->output_unit  = NULL;
   s->playing      = FALSE;
   s->bytes_played = 0;
+  s->total_bytes_played = 0;
   s->rate         = rate;
   s->n_channels   = n_channels;
   s->bytes_per_ch = 2;
@@ -536,7 +538,7 @@ sa_stream_get_position(sa_stream_t *s, sa_position_t position, int64_t *pos) {
   }
 
   pthread_mutex_lock(&s->mutex);
-  *pos = s->bytes_played;
+  *pos = s->total_bytes_played + s->bytes_played;
   pthread_mutex_unlock(&s->mutex);
   return SA_SUCCESS;
 }
@@ -573,6 +575,7 @@ sa_stream_resume(sa_stream_t *s) {
    * 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->bytes_played = 0;
   pthread_mutex_unlock(&s->mutex);