[vlc-commits] coreaudio: a valid timebase is now mandatory
Thomas Guillem
git at videolan.org
Wed Aug 21 09:57:49 CEST 2019
vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Fri Aug 16 09:01:20 2019 +0200| [b625ef0b02004c530ab835157a955a060fdedd07] | committer: Thomas Guillem
coreaudio: a valid timebase is now mandatory
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=b625ef0b02004c530ab835157a955a060fdedd07
---
modules/audio_output/audiounit_ios.m | 11 ++++++++---
modules/audio_output/auhal.c | 11 ++++++++---
modules/audio_output/coreaudio_common.c | 21 ++++++++-------------
modules/audio_output/coreaudio_common.h | 2 +-
4 files changed, 25 insertions(+), 20 deletions(-)
diff --git a/modules/audio_output/audiounit_ios.m b/modules/audio_output/audiounit_ios.m
index cbac04c2b1..1c0f8528b9 100644
--- a/modules/audio_output/audiounit_ios.m
+++ b/modules/audio_output/audiounit_ios.m
@@ -612,17 +612,24 @@ static int
Open(vlc_object_t *obj)
{
audio_output_t *aout = (audio_output_t *)obj;
- aout_sys_t *sys = calloc(1, sizeof (*sys));
+ aout_sys_t *sys = p_aout->sys = calloc(1, sizeof (*sys));
if (unlikely(sys == NULL))
return VLC_ENOMEM;
+ if (ca_Open(aout) != VLC_SUCCESS)
+ {
+ free(sys);
+ return VLC_EGENERIC;
+ }
+
sys->avInstance = [AVAudioSession sharedInstance];
assert(sys->avInstance != NULL);
sys->aoutWrapper = [[AoutWrapper alloc] initWithAout:aout];
if (sys->aoutWrapper == NULL)
{
+ ca_Close(aout);
free(sys);
return VLC_ENOMEM;
}
@@ -630,7 +637,6 @@ Open(vlc_object_t *obj)
sys->b_muted = false;
sys->b_preferred_channels_set = false;
sys->au_dev = var_InheritBool(aout, "spdif") ? AU_DEV_ENCODED : AU_DEV_PCM;
- aout->sys = sys;
aout->start = Start;
aout->stop = Stop;
aout->device_select = DeviceSelect;
@@ -640,7 +646,6 @@ Open(vlc_object_t *obj)
for (unsigned int i = 0; i< sizeof(au_devs) / sizeof(au_devs[0]); ++i)
aout_HotplugReport(aout, au_devs[i].psz_id, au_devs[i].psz_name);
- ca_Open(aout);
return VLC_SUCCESS;
}
diff --git a/modules/audio_output/auhal.c b/modules/audio_output/auhal.c
index 6ba2765754..b56e609bc3 100644
--- a/modules/audio_output/auhal.c
+++ b/modules/audio_output/auhal.c
@@ -1694,10 +1694,17 @@ static void Close(vlc_object_t *obj)
static int Open(vlc_object_t *obj)
{
audio_output_t *p_aout = (audio_output_t *)obj;
- aout_sys_t *p_sys = calloc(1, sizeof (*p_sys));
+
+ aout_sys_t *p_sys = p_aout->sys = calloc(1, sizeof (*p_sys));
if (unlikely(p_sys == NULL))
return VLC_ENOMEM;
+ if (ca_Open(p_aout) != VLC_SUCCESS)
+ {
+ free(p_sys);
+ return VLC_EGENERIC;
+ }
+
vlc_mutex_init(&p_sys->device_list_lock);
vlc_mutex_init(&p_sys->selected_device_lock);
p_sys->b_digital = false;
@@ -1706,7 +1713,6 @@ static int Open(vlc_object_t *obj)
memset(&p_sys->sfmt_revert, 0, sizeof(p_sys->sfmt_revert));
p_sys->i_stream_id = 0;
- p_aout->sys = p_sys;
p_aout->start = Start;
p_aout->stop = Stop;
p_aout->volume_set = VolumeSet;
@@ -1764,6 +1770,5 @@ static int Open(vlc_object_t *obj)
p_sys->b_mute = var_InheritBool(p_aout, "mute");
aout_MuteReport(p_aout, p_sys->b_mute);
- ca_Open(p_aout);
return VLC_SUCCESS;
}
diff --git a/modules/audio_output/coreaudio_common.c b/modules/audio_output/coreaudio_common.c
index d605c4cdf9..0b55e86d56 100644
--- a/modules/audio_output/coreaudio_common.c
+++ b/modules/audio_output/coreaudio_common.c
@@ -54,13 +54,6 @@ ca_ClearOutBuffers(audio_output_t *p_aout)
p_sys->i_out_size = 0;
}
-static void
-ca_init_once(void)
-{
- if (mach_timebase_info(&tinfo) != KERN_SUCCESS)
- tinfo.numer = tinfo.denom = 0;
-}
-
static inline void
lock_init(struct aout_sys_common *p_sys)
{
@@ -95,13 +88,16 @@ lock_unlock(struct aout_sys_common *p_sys)
vlc_mutex_unlock(&p_sys->lock.mutex);
}
-void
+int
ca_Open(audio_output_t *p_aout)
{
struct aout_sys_common *p_sys = (struct aout_sys_common *) p_aout->sys;
- static pthread_once_t once = PTHREAD_ONCE_INIT;
- pthread_once(&once, ca_init_once);
+ if (mach_timebase_info(&tinfo) != KERN_SUCCESS)
+ {
+ tinfo.numer = tinfo.denom = 0;
+ return VLC_EGENERIC;
+ }
vlc_sem_init(&p_sys->flush_sem, 0);
lock_init(p_sys);
@@ -111,6 +107,8 @@ ca_Open(audio_output_t *p_aout)
p_aout->pause = ca_Pause;
p_aout->flush = ca_Flush;
p_aout->time_get = ca_TimeGet;
+
+ return VLC_SUCCESS;
}
void
@@ -193,9 +191,6 @@ ca_TimeGet(audio_output_t *p_aout, vlc_tick_t *delay)
{
struct aout_sys_common *p_sys = (struct aout_sys_common *) p_aout->sys;
- if (unlikely(tinfo.denom == 0))
- return -1;
-
lock_lock(p_sys);
if (p_sys->i_render_host_time == 0)
diff --git a/modules/audio_output/coreaudio_common.h b/modules/audio_output/coreaudio_common.h
index 11c73b31e4..0df65c2aaa 100644
--- a/modules/audio_output/coreaudio_common.h
+++ b/modules/audio_output/coreaudio_common.h
@@ -81,7 +81,7 @@ struct aout_sys_common
vlc_tick_t i_dev_latency_us;
};
-void ca_Open(audio_output_t *p_aout);
+int ca_Open(audio_output_t *p_aout);
void ca_Close(audio_output_t *p_aout);
More information about the vlc-commits
mailing list