diff options
author | Max Kellermann <max@duempel.org> | 2011-08-28 17:29:09 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2011-08-29 11:23:51 +0200 |
commit | 9ccaa904393ddf2189f7d7815cef29a3e3393cbc (patch) | |
tree | ec6e7a2bba829b6cbc8607ef304eecb279408465 /src/output | |
parent | 4733c5fef00abacfbca414d96114bd7a5427ca12 (diff) | |
download | mpd-9ccaa904393ddf2189f7d7815cef29a3e3393cbc.tar.gz mpd-9ccaa904393ddf2189f7d7815cef29a3e3393cbc.tar.xz mpd-9ccaa904393ddf2189f7d7815cef29a3e3393cbc.zip |
ntp_server: use the I/O thread
Diffstat (limited to 'src/output')
-rw-r--r-- | src/output/raop_output_plugin.c | 32 |
1 files changed, 9 insertions, 23 deletions
diff --git a/src/output/raop_output_plugin.c b/src/output/raop_output_plugin.c index a498ca670..912048007 100644 --- a/src/output/raop_output_plugin.c +++ b/src/output/raop_output_plugin.c @@ -535,15 +535,11 @@ exec_request(struct rtspcl_data *rtspcld, const char *cmd, while (true) { FD_ZERO(&rdfds); FD_SET(rtspcld->fd, &rdfds); - FD_SET(raop_session->ntp.fd, &rdfds); - fdmax = raop_session->ntp.fd > rtspcld->fd ? raop_session->ntp.fd : rtspcld->fd;; + fdmax = rtspcld->fd; select(fdmax + 1, &rdfds, NULL, NULL, &tout); if (FD_ISSET(rtspcld->fd, &rdfds)) { break; } - if (FD_ISSET(raop_session->ntp.fd, &rdfds)) { - ntp_server_handle(&raop_session->ntp); - } } if (read_line(rtspcld->fd, line, sizeof(line), timeout, 0) <= 0) { @@ -1068,20 +1064,14 @@ static bool send_audio_data(int fd, GError **error_r) { int i = 0; - struct timeval current_time, tout, rtp_time; + struct timeval current_time, rtp_time; struct raop_data *rd = raop_session->raop_list; get_time_for_rtp(&raop_session->play_state, &rtp_time); gettimeofday(¤t_time, NULL); int diff = difference(¤t_time, &rtp_time); + g_usleep(-diff); - while (diff < -10000) { - tout.tv_sec = 0; - tout.tv_usec = -diff; - ntp_server_check(&raop_session->ntp, &tout); - gettimeofday(¤t_time, NULL); - diff = difference(¤t_time, &rtp_time); - } gettimeofday(&raop_session->play_state.last_send, NULL); while (rd) { if (rd->started) { @@ -1214,10 +1204,8 @@ raop_output_cancel(void *data) static bool raop_output_pause(void *data) { - struct timeval tout = {.tv_sec = 0, .tv_usec = 0}; struct raop_data *rd = (struct raop_data *) data; - ntp_server_check(&raop_session->ntp, &tout); rd->paused = true; return true; } @@ -1284,17 +1272,18 @@ raop_output_open(void *data, struct audio_format *audio_format, GError **error_r if (raop_session->data_fd < 0) return false; - raop_session->ntp.fd = - open_udp_socket(NULL, &raop_session->ntp.port, - error_r); - if (raop_session->ntp.fd < 0) + int fd = open_udp_socket(NULL, &raop_session->ntp.port, + error_r); + if (fd < 0) return false; + ntp_server_open(&raop_session->ntp, fd); + raop_session->ctrl.fd = open_udp_socket(NULL, &raop_session->ctrl.port, error_r); if (raop_session->ctrl.fd < 0) { - close(raop_session->ntp.fd); + ntp_server_close(&raop_session->ntp); raop_session->ctrl.fd = -1; g_mutex_unlock(raop_session->list_mutex); return false; @@ -1324,7 +1313,6 @@ raop_output_play(void *data, const void *chunk, size_t size, { //raopcl_send_sample struct raop_data *rd = data; - struct timeval tout = {.tv_sec = 0, .tv_usec = 0}; size_t rval = 0, orig_size = size; rd->paused = false; @@ -1335,8 +1323,6 @@ raop_output_play(void *data, const void *chunk, size_t size, g_mutex_lock(raop_session->data_mutex); - ntp_server_check(&raop_session->ntp, &tout); - if (raop_session->play_state.rtptime <= NUMSAMPLES) { // looped over, need new reference point to calculate correct times raop_session->play_state.playing = false; |