Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change #3

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions client/media_uv.c
Original file line number Diff line number Diff line change
Expand Up @@ -256,10 +256,13 @@ static void media_uv_close_cb(uv_handle_t* handle)
MediaProxyPriv* proxy = pipe->proxy;

MEDIA_DEBUG_PROXY(proxy);
if (pipe == proxy->cpipe)
if (pipe == proxy->cpipe) {
MEDIA_INFO("close cpipe:%p proxy:%p\n", pipe, proxy);
proxy->cpipe = NULL;
else if (pipe == proxy->epipe)
} else if (pipe == proxy->epipe) {
MEDIA_INFO("close epipe:%p proxy:%p\n", pipe, proxy);
proxy->epipe = NULL;
}

media_uv_free_pipe(pipe);
media_uv_free_proxy(proxy);
Expand Down Expand Up @@ -401,6 +404,7 @@ static int media_uv_connect_one(MediaProxyPriv* proxy)
#endif
}

MEDIA_INFO("connect cpipe:%p proxy:%p\n", proxy->cpipe, proxy);
MEDIA_DEBUG_PROXY(proxy);
return 0;

Expand Down Expand Up @@ -649,6 +653,7 @@ static void media_uv_listen_one_cb(uv_stream_t* stream, int ret)
if (ret < 0)
goto err2;

MEDIA_INFO("connect epipe:%p proxy:%p\n", proxy->epipe, proxy);
media_uv_close(server);
MEDIA_DEBUG_PROXY(proxy);
if (proxy->on_listen)
Expand Down
34 changes: 18 additions & 16 deletions client/media_uv_graph.c
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,8 @@ static int media_uv_stream_send(void* stream, const char* target,
if (ret < 0)
return ret;

MEDIA_INFO("%s %p %s %s %s",
priv->name, priv->proxy, target ? target : "_", cmd, arg ? arg : "_");
MEDIA_INFO("%s:%p %p %s %s %s",
priv->name, priv, priv->proxy, target ? target : "_", cmd, arg ? arg : "_");

ret = media_uv_send(priv->proxy, parser, cb, cookie, &parcel);
media_parcel_deinit(&parcel);
Expand Down Expand Up @@ -406,6 +406,7 @@ static void media_uv_stream_close_pipe_cb(uv_handle_t* handle)
static void media_uv_stream_close_pipe(MediaStreamPriv* priv)
{
if (priv->pipe) {
MEDIA_INFO("%s:%p close pipe:%p\n", priv->name, priv, priv->pipe);
uv_close((uv_handle_t*)priv->pipe, media_uv_stream_close_pipe_cb);
priv->pipe = NULL;
}
Expand Down Expand Up @@ -450,7 +451,7 @@ static void media_uv_stream_listen_connection_cb(uv_stream_t* stream, int ret)
return;
}

MEDIA_DEBUG("listener:%p accept:%p\n", listener, priv->pipe);
MEDIA_INFO("%s:%p listener:%p accept:%p\n", priv->name, priv, listener, priv->pipe);
media_uv_stream_listen_clear(priv, listener); /* Clear redundant listeners. */
if (!priv->on_connection) {
media_uv_stream_close_pipe(priv);
Expand Down Expand Up @@ -555,6 +556,7 @@ static int media_uv_stream_request_focus(MediaStreamPriv* stream,
}

stream->focus = priv;
MEDIA_INFO("%s:%p %s:%p %p\n", stream->name, priv->stream, scenario, priv, priv->handle);
return 0;
}

Expand Down Expand Up @@ -646,11 +648,11 @@ static void media_uv_player_suggest_cb(int suggest, void* cookie)
bool suggest_active = false;

if (!player) {
MEDIA_INFO("suggest:%d canceled\n", suggest);
goto out;
MEDIA_INFO("focus:%p suggest:%d canceled\n", priv, suggest);
return;
}

MEDIA_INFO("%s:%p suggest:%d\n", player->name, player, suggest);
MEDIA_INFO("%s:%p focus:%p %p suggest:%d\n", player->name, player, priv, priv->handle, suggest);

switch (suggest) {
case MEDIA_FOCUS_PLAY:
Expand Down Expand Up @@ -685,7 +687,6 @@ static void media_uv_player_suggest_cb(int suggest, void* cookie)
break;
}

out:
if (priv->on_play) {
if (!suggest_active) /* Notify user if focus request failed. */
priv->on_play(priv->on_play_cookie, -EPERM);
Expand Down Expand Up @@ -740,13 +741,14 @@ int media_uv_player_close(void* handle, int pending, media_uv_callback on_close)
snprintf(tmp, sizeof(tmp), "%d", pending);
ret = media_uv_stream_send(priv, NULL, "close", tmp, 0,
media_uv_stream_receive_cb, media_uv_stream_close_cb, priv);
if (ret < 0)
media_uv_stream_close_cb(priv, ret);

media_uv_stream_close_pipe(handle);
media_uv_stream_listen_clear(handle, NULL);
media_uv_stream_abandon_focus(handle);

if (ret < 0)
media_uv_stream_close_cb(priv, ret);

return ret;
}

Expand Down Expand Up @@ -825,7 +827,7 @@ int media_uv_player_start_auto(void* handle, const char* scenario,
return -EINVAL;

if (priv->focus) {
MEDIA_WARN("%s:%p force start\n", priv->name, priv);
MEDIA_WARN("%s:%p %p force start\n", priv->name, priv, priv->focus);
return media_uv_player_start(priv, cb, cookie);
}

Expand Down Expand Up @@ -1024,11 +1026,11 @@ static void media_uv_recorder_suggest_cb(int suggest, void* cookie)
bool suggest_active = false;

if (!recorder) {
MEDIA_INFO("suggest:%d canceled\n", suggest);
goto out;
MEDIA_INFO("focus:%p suggest:%d canceled\n", priv, suggest);
return;
}

MEDIA_INFO("%s:%p suggest:%d\n", recorder->name, recorder, suggest);
MEDIA_INFO("%s:%p focus:%p %p suggest:%d\n", recorder->name, recorder, priv, priv->handle, suggest);

switch (suggest) {
case MEDIA_FOCUS_PLAY:
Expand All @@ -1052,7 +1054,6 @@ static void media_uv_recorder_suggest_cb(int suggest, void* cookie)
break;
}

out:
if (priv->on_play) {
if (!suggest_active) /* Notify user if focus request failed. */
priv->on_play(priv->on_play_cookie, -EPERM);
Expand Down Expand Up @@ -1105,13 +1106,14 @@ int media_uv_recorder_close(void* handle, media_uv_callback on_close)
priv->on_close = on_close;
ret = media_uv_stream_send(priv, NULL, "close", "0", 0,
media_uv_stream_receive_cb, media_uv_stream_close_cb, priv);
if (ret < 0)
media_uv_stream_close_cb(priv, ret);

media_uv_stream_close_pipe(handle);
media_uv_stream_listen_clear(handle, NULL);
media_uv_stream_abandon_focus(handle);

if (ret < 0)
media_uv_stream_close_cb(priv, ret);

return ret;
}

Expand Down
Loading
Loading