зеркало из https://github.com/mozilla/gecko-dev.git
Bug 466699 - libsydneyaudio fixes for avsync - rs=roc
This commit is contained in:
Родитель
3f7058f3aa
Коммит
87754583fb
|
@ -6,3 +6,6 @@ the Mozilla build system.
|
|||
http://svn.annodex.net/libsydneyaudio/trunk
|
||||
|
||||
The svn revision number used was r3895.
|
||||
|
||||
pause-resume.patch is applied to implement and fix issues
|
||||
with pausing and resuming audio streams.
|
||||
|
|
|
@ -0,0 +1,69 @@
|
|||
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);
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -5,3 +5,4 @@
|
|||
cp $1/include/sydney_audio.h include/sydney_audio.h
|
||||
cp $1/src/*.c src/
|
||||
cp $1/AUTHORS ./AUTHORS
|
||||
patch -p4 <pause-resume.patch
|
||||
|
|
Загрузка…
Ссылка в новой задаче