mirror of
https://github.com/owntone/owntone-server.git
synced 2025-04-16 09:08:04 -04:00
hi-res timer commit broke FreeBSD. This attempts to go back to the
old code for FreeBSD.
This commit is contained in:
parent
01f290cc2a
commit
258163e6ce
@ -750,11 +750,11 @@ murmur_hash64(const void *key, int len, uint32_t seed)
|
||||
|
||||
return h;
|
||||
}
|
||||
|
||||
#else
|
||||
# error Platform not supported
|
||||
#endif
|
||||
|
||||
#if defined(__linux__)
|
||||
int
|
||||
clock_gettime_with_res(clockid_t clock_id, struct timespec *tp, struct timespec *res)
|
||||
{
|
||||
@ -805,3 +805,4 @@ timespec_cmp(struct timespec time1, struct timespec time2)
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
#endif /* __linux__ */
|
||||
|
@ -3,7 +3,9 @@
|
||||
#define __MISC_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#if defined(__linux__)
|
||||
# include <time.h>
|
||||
#endif
|
||||
|
||||
struct onekeyval {
|
||||
char *name;
|
||||
@ -72,7 +74,8 @@ b64_encode(uint8_t *in, size_t len);
|
||||
uint64_t
|
||||
murmur_hash64(const void *key, int len, uint32_t seed);
|
||||
|
||||
/* timer functions */
|
||||
#if defined(__linux__)
|
||||
/* Timer functions for platforms without hi-res timers */
|
||||
int
|
||||
clock_gettime_with_res(clockid_t clock_id, struct timespec *tp, struct timespec *res);
|
||||
|
||||
@ -81,6 +84,6 @@ timespec_add(struct timespec time1, struct timespec time2);
|
||||
|
||||
int
|
||||
timespec_cmp(struct timespec time1, struct timespec time2);
|
||||
|
||||
#endif /* __linux__ */
|
||||
|
||||
#endif /* !__MISC_H__ */
|
||||
|
21
src/player.c
21
src/player.c
@ -366,7 +366,11 @@ player_get_current_pos_clock(uint64_t *pos, struct timespec *ts, int commit)
|
||||
uint64_t delta;
|
||||
int ret;
|
||||
|
||||
#if defined(__linux__)
|
||||
ret = clock_gettime_with_res(CLOCK_MONOTONIC, ts, &timer_res);
|
||||
#else
|
||||
ret = clock_gettime(CLOCK_MONOTONIC, ts);
|
||||
#endif
|
||||
if (ret < 0)
|
||||
{
|
||||
DPRINTF(E_LOG, L_PLAYER, "Couldn't get clock: %s\n", strerror(errno));
|
||||
@ -410,7 +414,11 @@ player_get_current_pos_laudio(uint64_t *pos, struct timespec *ts, int commit)
|
||||
|
||||
*pos = laudio_get_pos();
|
||||
|
||||
#if defined(__linux__)
|
||||
ret = clock_gettime_with_res(CLOCK_MONOTONIC, ts, &timer_res);
|
||||
#else
|
||||
ret = clock_gettime(CLOCK_MONOTONIC, ts);
|
||||
#endif
|
||||
if (ret < 0)
|
||||
{
|
||||
DPRINTF(E_LOG, L_PLAYER, "Couldn't get clock: %s\n", strerror(errno));
|
||||
@ -1423,10 +1431,12 @@ player_playback_cb(int fd, short what, void *arg)
|
||||
if (packet_send_count > 126)
|
||||
{
|
||||
DPRINTF(E_LOG, L_PLAYER, "Timing error detected during playback! Aborting.\n");
|
||||
|
||||
playback_abort();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
while(timespec_cmp(packet_timer_last, next_tick) < 0);
|
||||
|
||||
/* Make sure playback is still running */
|
||||
@ -1857,7 +1867,11 @@ device_activate_cb(struct raop_device *dev, struct raop_session *rs, enum raop_s
|
||||
|
||||
if ((player_state == PLAY_PLAYING) && (raop_sessions == 1))
|
||||
{
|
||||
#if defined(__linux__)
|
||||
ret = clock_gettime_with_res(CLOCK_MONOTONIC, &ts, &timer_res);
|
||||
#else
|
||||
ret = clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||
#endif
|
||||
if (ret < 0)
|
||||
{
|
||||
DPRINTF(E_LOG, L_PLAYER, "Could not get current time: %s\n", strerror(errno));
|
||||
@ -2183,7 +2197,11 @@ playback_start_bh(struct player_command *cmd)
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(__linux__)
|
||||
ret = clock_gettime_with_res(CLOCK_MONOTONIC, &pb_pos_stamp, &timer_res);
|
||||
#else
|
||||
ret = clock_gettime(CLOCK_MONOTONIC, &pb_pos_stamp);
|
||||
#endif
|
||||
if (ret < 0)
|
||||
{
|
||||
DPRINTF(E_LOG, L_PLAYER, "Couldn't get current clock: %s\n", strerror(errno));
|
||||
@ -4054,6 +4072,7 @@ player_init(void)
|
||||
|
||||
update_handler = NULL;
|
||||
|
||||
#if defined(__linux__)
|
||||
/*
|
||||
* Determine if the resolution of the system timer is > or < the size
|
||||
* of an audio packet. NOTE: this assumes the system clock resolution
|
||||
@ -4062,9 +4081,11 @@ player_init(void)
|
||||
if (clock_getres(CLOCK_MONOTONIC, &timer_res) < 0)
|
||||
{
|
||||
DPRINTF(E_LOG, L_PLAYER, "Could not get the system timer resolution.\n");
|
||||
|
||||
return -1;
|
||||
}
|
||||
MINIMUM_STREAM_PERIOD = MAX(timer_res.tv_nsec, AIRTUNES_V2_STREAM_PERIOD);
|
||||
#endif
|
||||
|
||||
/* Random RTP time start */
|
||||
gcry_randomize(&rnd, sizeof(rnd), GCRY_STRONG_RANDOM);
|
||||
|
Loading…
x
Reference in New Issue
Block a user