mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-10-31 22:25:33 -04:00
Add a new callback structure to propigate when the RTSP connection dies
git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/coling@2402 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
parent
5eecfa2e3f
commit
899492c315
4 changed files with 33 additions and 5 deletions
|
|
@ -89,8 +89,11 @@ struct pa_raop_client {
|
|||
|
||||
pa_socket_client *sc;
|
||||
int fd;
|
||||
|
||||
pa_raop_client_cb_t callback;
|
||||
void* userdata;
|
||||
pa_raop_client_closed_cb_t closed_callback;
|
||||
void* closed_userdata;
|
||||
|
||||
uint8_t *buffer;
|
||||
uint32_t buffer_length;
|
||||
|
|
@ -339,6 +342,19 @@ static void rtsp_cb(pa_rtsp_client *rtsp, pa_rtsp_state state, pa_headerlist* he
|
|||
case STATE_SET_PARAMETER:
|
||||
case STATE_FLUSH:
|
||||
break;
|
||||
case STATE_DISCONNECTED:
|
||||
pa_assert(c->closed_callback);
|
||||
pa_log_debug("RTSP channel closed");
|
||||
if (c->fd > 0) {
|
||||
pa_close(c->fd);
|
||||
c->fd = -1;
|
||||
}
|
||||
if (c->sc) {
|
||||
pa_socket_client_unref(c->sc);
|
||||
c->sc = NULL;
|
||||
}
|
||||
c->closed_callback(c->closed_userdata);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -437,7 +453,6 @@ pa_memchunk pa_raop_client_encode_sample(pa_raop_client* c, pa_mempool* mempool,
|
|||
|
||||
c->buffer = pa_xrealloc(c->buffer, bufmax);
|
||||
c->buffer_length = bufmax;
|
||||
pa_log_debug("Creating new memblock");
|
||||
c->memchunk.memblock = pa_memblock_new_user(mempool, c->buffer, bufmax, noop, 0);
|
||||
}
|
||||
c->memchunk.index = 0;
|
||||
|
|
@ -499,3 +514,11 @@ void pa_raop_client_set_callback(pa_raop_client* c, pa_raop_client_cb_t callback
|
|||
c->callback = callback;
|
||||
c->userdata = userdata;
|
||||
}
|
||||
|
||||
void pa_raop_client_set_closed_callback(pa_raop_client* c, pa_raop_client_closed_cb_t callback, void *userdata)
|
||||
{
|
||||
pa_assert(c);
|
||||
|
||||
c->closed_callback = callback;
|
||||
c->closed_userdata = userdata;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,4 +38,7 @@ pa_memchunk pa_raop_client_encode_sample(pa_raop_client* c, pa_mempool* mempool,
|
|||
typedef void (*pa_raop_client_cb_t)(int fd, void *userdata);
|
||||
void pa_raop_client_set_callback(pa_raop_client* c, pa_raop_client_cb_t callback, void *userdata);
|
||||
|
||||
typedef void (*pa_raop_client_closed_cb_t)(void *userdata);
|
||||
void pa_raop_client_set_closed_callback(pa_raop_client* c, pa_raop_client_closed_cb_t callback, void *userdata);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -173,6 +173,7 @@ static void headers_read(pa_rtsp_client *c) {
|
|||
|
||||
pa_assert(c);
|
||||
pa_assert(c->response_headers);
|
||||
pa_assert(c->callback);
|
||||
|
||||
/* Deal with a SETUP response */
|
||||
if (STATE_SETUP == c->state) {
|
||||
|
|
@ -209,8 +210,7 @@ static void headers_read(pa_rtsp_client *c) {
|
|||
}
|
||||
|
||||
/* Call our callback */
|
||||
if (c->callback)
|
||||
c->callback(c, c->state, c->response_headers, c->userdata);
|
||||
c->callback(c, c->state, c->response_headers, c->userdata);
|
||||
|
||||
pa_headerlist_free(c->response_headers);
|
||||
c->response_headers = NULL;
|
||||
|
|
@ -224,12 +224,13 @@ static void line_callback(pa_ioline *line, const char *s, void *userdata) {
|
|||
pa_rtsp_client *c = userdata;
|
||||
pa_assert(line);
|
||||
pa_assert(c);
|
||||
pa_assert(c->callback);
|
||||
|
||||
if (!s) {
|
||||
pa_log_warn("Connection closed");
|
||||
pa_ioline_unref(c->ioline);
|
||||
c->ioline = NULL;
|
||||
pa_rtsp_disconnect(c);
|
||||
c->callback(c, STATE_DISCONNECTED, NULL, c->userdata);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -44,7 +44,8 @@ typedef enum {
|
|||
STATE_RECORD,
|
||||
STATE_TEARDOWN,
|
||||
STATE_SET_PARAMETER,
|
||||
STATE_FLUSH
|
||||
STATE_FLUSH,
|
||||
STATE_DISCONNECTED
|
||||
} pa_rtsp_state;
|
||||
typedef void (*pa_rtsp_cb_t)(pa_rtsp_client *c, pa_rtsp_state state, pa_headerlist* hl, void *userdata);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue