OSDN Git Service

AVRCP: Fix not checking for media_player_controller_create
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Fri, 28 Dec 2012 12:51:09 +0000 (14:51 +0200)
committerMarcel Holtmann <marcel@holtmann.org>
Sun, 30 Dec 2012 18:53:43 +0000 (10:53 -0800)
Now that the MediaPlayer1 interface is experimental the interface
registration may fail which return NULL, in that case there is no
point on register to any notifications.

profiles/audio/avrcp.c

index 4e3d31d..ce070cd 100644 (file)
@@ -1987,6 +1987,11 @@ static gboolean avrcp_get_capabilities_resp(struct avctp *conn,
 
        count = pdu->params[1];
 
+       path = device_get_path(session->dev->btd_dev);
+       mp = media_player_controller_create(path);
+       if (mp == NULL)
+               return FALSE;
+
        for (; count > 0; count--) {
                uint8_t event = pdu->params[1 + count];
 
@@ -2001,8 +2006,6 @@ static gboolean avrcp_get_capabilities_resp(struct avctp *conn,
                }
        }
 
-       path = device_get_path(session->dev->btd_dev);
-       mp = media_player_controller_create(path);
        media_player_set_callbacks(mp, &ct_cbs, player);
        player->user_data = mp;
        player->destroy = (GDestroyNotify) media_player_destroy;