diff options
author | Szymon Janc <szymon.janc@tieto.com> | 2013-03-05 15:59:52 +0100 |
---|---|---|
committer | Luiz Augusto von Dentz <luiz.von.dentz@intel.com> | 2013-03-06 11:50:34 +0200 |
commit | c80e3120f896a820f9e8e3e58acc1a99015a2993 (patch) | |
tree | 2e85579258a06737214ec9362343b7870c71cb2e /profiles/audio/control.c | |
parent | e7d3fbceb74c00baafe44cbe1bd9de93f660b045 (diff) | |
download | bluez-c80e3120f896a820f9e8e3e58acc1a99015a2993.tar.gz |
avctp: Allow to register state callback for specified audio device
State callback can now be registered and called for specified device
only (or all devices if NULL is passed). This will allow for more
cleaner callback register/unregister in roles code.
Fix following valgrind reports:
16 bytes in 1 blocks are still reachable in loss record 43 of 223
at 0x4C2B6CD: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
by 0x4E7FA78: g_malloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3)
by 0x4E92CA2: g_slice_alloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3)
by 0x4E93FC2: g_slist_append (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3)
by 0x419ABD: avctp_add_state_cb (avctp.c:1652)
by 0x41DD87: audio_device_register (device.c:320)
by 0x416ECA: manager_get_audio_device (manager.c:491)
by 0x4171A8: a2dp_sink_probe (manager.c:131)
by 0x46A821: dev_probe (device.c:2347)
by 0x468CBE: btd_profile_foreach (profile.c:599)
by 0x46BBB5: device_probe_profiles (device.c:2423)
by 0x461458: load_devices (adapter.c:2549)
16 bytes in 1 blocks are still reachable in loss record 44 of 223
at 0x4C2B6CD: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
by 0x4E7FA78: g_malloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3)
by 0x4E92CA2: g_slice_alloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3)
by 0x4E93FC2: g_slist_append (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3)
by 0x419ABD: avctp_add_state_cb (avctp.c:1652)
by 0x417791: control_init (control.c:290)
by 0x417097: avrcp_probe (manager.c:156)
by 0x46A821: dev_probe (device.c:2347)
by 0x468CBE: btd_profile_foreach (profile.c:599)
by 0x46BBB5: device_probe_profiles (device.c:2423)
by 0x461458: load_devices (adapter.c:2549)
by 0x465086: read_info_complete (adapter.c:5514)
24 bytes in 1 blocks are still reachable in loss record 59 of 223
at 0x4C2B6CD: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
by 0x4E7FA78: g_malloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3)
by 0x419A92: avctp_add_state_cb (avctp.c:1647)
by 0x41DD87: audio_device_register (device.c:320)
by 0x416ECA: manager_get_audio_device (manager.c:491)
by 0x4171A8: a2dp_sink_probe (manager.c:131)
by 0x46A821: dev_probe (device.c:2347)
by 0x468CBE: btd_profile_foreach (profile.c:599)
by 0x46BBB5: device_probe_profiles (device.c:2423)
by 0x461458: load_devices (adapter.c:2549)
by 0x465086: read_info_complete (adapter.c:5514)
by 0x4713A1: request_complete (mgmt.c:221)
24 bytes in 1 blocks are still reachable in loss record 60 of 223
at 0x4C2B6CD: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
by 0x4E7FA78: g_malloc (in /lib/x86_64-linux-gnu/libglib-2.0.so.0.3200.3)
by 0x419A92: avctp_add_state_cb (avctp.c:1647)
by 0x417791: control_init (control.c:290)
by 0x417097: avrcp_probe (manager.c:156)
by 0x46A821: dev_probe (device.c:2347)
by 0x468CBE: btd_profile_foreach (profile.c:599)
by 0x46BBB5: device_probe_profiles (device.c:2423)
by 0x461458: load_devices (adapter.c:2549)
by 0x465086: read_info_complete (adapter.c:5514)
by 0x4713A1: request_complete (mgmt.c:221)
by 0x47175B: received_data (mgmt.c:319)
Diffstat (limited to 'profiles/audio/control.c')
-rw-r--r-- | profiles/audio/control.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/profiles/audio/control.c b/profiles/audio/control.c index 18c8478ba..b50e890b6 100644 --- a/profiles/audio/control.c +++ b/profiles/audio/control.c @@ -59,11 +59,10 @@ #include "glib-helper.h" #include "dbus-common.h" -static unsigned int avctp_id = 0; - struct control { struct avctp *session; gboolean target; + unsigned int avctp_id; }; static void state_changed(struct audio_device *dev, avctp_state_t old_state, @@ -250,6 +249,8 @@ static void path_unregister(void *data) if (control->session) avctp_disconnect(control->session); + avctp_remove_state_cb(control->avctp_id); + g_free(control); dev->control = NULL; } @@ -286,8 +287,7 @@ struct control *control_init(struct audio_device *dev, GSList *uuids) control_update(control, uuids); - if (!avctp_id) - avctp_id = avctp_add_state_cb(state_changed, NULL); + control->avctp_id = avctp_add_state_cb(dev, state_changed, NULL); return control; } |