[vlc-devel] commit: mtime: Use mach_absolute_time on Mac OS X instead of gettimeofday. (Pierre d'Herbemont )

Pierre d'Herbemont pdherbemont at free.fr
Sat Feb 14 17:38:18 CET 2009


On Sat, Feb 14, 2009 at 5:31 PM, Rémi Denis-Courmont <rem at videolan.org> wrote:
> Le dimanche 8 février 2009 02:03:05 git version control, vous avez écrit :
>> vlc | branch: 0.9-bugfix | Pierre d'Herbemont <pdherbemont at videolan.org> |
>> Sun Feb  8 00:31:33 2009 +0100| [5ead92ffd58088828ed802173d963b2571f0cd69]
>> | committer: Pierre d'Herbemont
>>
>> mtime: Use mach_absolute_time on Mac OS X instead of gettimeofday.
>>
>> mach_absolute_time() is a monotic clock, whereas gettimeofday() is not. For
>> that reason setting your computer time while playing a movie won't halt
>> playback anymore.
>>
>> Seems to fix the dropped frame issue on Mac OS X.
>>
>> > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=5ead92ffd58088828e
>> >d802173d963b2571f0cd69
>>
>> ---
>>
>>  include/vlc_threads.h |   14 ++++++++++++++
>>  src/misc/mtime.c      |   34 ++++++++++++++++++++++++++++++++++
>>  2 files changed, 48 insertions(+), 0 deletions(-)
>>
>> diff --git a/include/vlc_threads.h b/include/vlc_threads.h
>> index e2810e9..8a21f84 100644
>> --- a/include/vlc_threads.h
>> +++ b/include/vlc_threads.h
>> @@ -359,12 +359,26 @@ static inline void __vlc_cond_wait( const char *
>> psz_file, int i_line, #define vlc_cond_timedwait( P_COND, P_MUTEX, DEADLINE
>> )                      \ __vlc_cond_timedwait( __FILE__, __LINE__, P_COND,
>> P_MUTEX, DEADLINE  )
>>
>> +#ifdef __APPLE__
>> +# include <sys/time.h> /* gettimeofday in vlc_cond_timedwait */
>> +#endif
>> +
>>  static inline int __vlc_cond_timedwait( const char * psz_file, int i_line,
>>                                          vlc_cond_t *p_condvar,
>>                                          vlc_mutex_t *p_mutex,
>>                                          mtime_t deadline )
>>  {
>>  #if defined(LIBVLC_USE_PTHREAD)
>> +#ifdef __APPLE__
>> +    /* mdate() is mac_absolute_time on osx, which we must convert to do
>> +     * the same base than gettimeofday() on which pthread_cond_timedwait
>> +     * counts on. */
>
> I wonder why bother use monotonic time if vlc_cond_timedwait still breaks.

vlc_cond_timedwait is rarely used on vlc-0.9. So where we have no
choice but to switch back to the wall clock, the impact is limited.

During playback the code paths we take are only relying on our monotonic clock.

Pierre.



More information about the vlc-devel mailing list