Commit Graph

61 Commits

Author SHA1 Message Date
Michal Labedzki
6e19272a42 media: Rename set_property to set_player_property
This is to avoid conflicts with DBus interface convention
used in BlueZ.
2012-07-04 16:35:26 +03:00
Daniel Wagner
b968b12927 audio: Move UUID string definition to lib 2012-06-02 09:06:32 +08:00
Anderson Lizardo
48d317102e Remove compatibility check for DBUS_TYPE_UNIX_FD
Since commit c89b589a58, D-Bus >= 1.4.0 is
required. This version already contains Unix FD passing support,
therefore code that checks for DBUS_TYPE_UNIX_FD definition is
unnecessary.
2012-05-31 11:29:58 +03:00
Luiz Augusto von Dentz
dbe02b8c00 audio: Fix updating volume property for non-A2DP transports
Volume property is A2DP only
2012-05-27 22:43:37 +03:00
Syam Sidhardhan
e03ca07559 media: Remove redundant D-Bus error initilization 2012-05-24 11:04:29 +03:00
Luiz Augusto von Dentz
bb846fcc33 audio: Fix media transport creation for gateway endpoints
The device maybe connected to another adapter other than the endpoint's
so the adapters must be first check.
2012-05-22 16:37:23 +03:00
Frédéric Danis
0d81fc7cf1 audio: Fix media transport creation
Prevents set_configuration() to be called on another adapter
than connecting one
2012-05-22 16:37:23 +03:00
Luiz Augusto von Dentz
a282fff97d AVRCP: Subscribe for VolumeChanged Notification
If the remote device support version 1.4 or latter send register command
for VolumeChanged event:

< AVCTP: Command : pt 0x00 transaction 0 pid 0x110e
    AV/C: Notify: address 0x48 opcode 0x00
      Subunit: Panel
      Opcode: Vendor Dependent
      Company ID: 0x001958
      AVRCP: RegisterNotification: pt Single len 0x0005
        EventID: 0x0d (EVENT_VOLUME_CHANGED)
        Interval: 0x00000000 (0 seconds)
> AVCTP: Response : pt 0x00 transaction 0 pid 0x110e
    AV/C: Interim: address 0x48 opcode 0x00
      Subunit: Panel
      Opcode: Vendor Dependent
      Company ID: 0x001958
      AVRCP: RegisterNotification: pt Single len 0x0002
        EventID: 0x0d (EVENT_VOLUME_CHANGED)
        Volume: 100.00% (127/127)
2012-05-18 20:48:12 +03:00
Lucas De Marchi
7eebe7fb41 Do not set signature and reply in GDBus tables
Use GDBUS_* macros, so signature and reply fields are not set in each
method/signal.
2012-05-17 20:32:21 -07:00
Lucas De Marchi
aa3b9016bf Convert GDBus methods to use macro helpers
With these macro helpers we can separate in/out arguments and use their
own vector.
2012-05-17 20:32:20 -07:00
Lucas De Marchi
665014ce89 Constify GDBus method tables
Constify method tables with the following command:

find . -name '*.[ch]' -exec \
	     sed -i 's/\(GDBusMethodTable .* =\)/const \1/g' {} \;
2012-05-17 20:32:20 -07:00
Mikel Astiz
9d21c7aada media: Enable parallel requests to endpoint
If endpoint is handling several devices, it should be able to handle
multiple requests, one per each.
2012-05-07 07:05:40 -07:00
Mikel Astiz
9ffc69cbfd media: Create multiple transports if needed
During endpoint registration one than one device might be connected.
Thus all matching devices should have one transport each.
2012-05-07 07:05:40 -07:00
Mikel Astiz
ee31522151 media: Split media_endpoint_create
This function is starting to be too long and needs to be split.

After this patch, the resulting code should be exactly equivalent as the
previous implementation.
2012-05-07 07:05:39 -07:00
Mikel Astiz
06da2b0228 media: Support multiple transports per endpoint
Several transports may exist for each endpoint, for example if several
HFGW are connected. This should be exposed to the endpoint as one
transport each.
2012-05-07 07:05:39 -07:00
Szymon Janc
1b44684fb0 Fix GLib assertion failure in media.c get_setting()
If get_setting is called before set_setting, mp->settings would be
NULL resulting in GLib assertion. Hashmap is now allocated in
media_player_create instead of on-demand allocation in set_setting.

external/bluetooth/bluez/audio/media.c:get_setting() Equalizer
CRITICAL **: g_hash_table_lookup: assertion `hash_table != NULL' failed
2012-02-02 15:56:42 -08:00
Radoslaw Jablonski
df62dbb69b audio: Use headset_shutdown in headset_setconf_cb
If pending connection will stay after state has been changed to
HEADSET_STATE_DISCONNECTED, then crash may happen (e.g. when hs_connect
will be called quickly again after that) To avoid that kind of problems
using headset_shutdown, which does necessary cleanup first (finalizes
pending connections) and after that changes state to
HEADSET_STATE_DISCONNECTED.
2011-12-27 12:06:15 +02:00
Mikel Astiz
053a3f62f9 media: update copyright statement 2011-11-21 12:57:59 +02:00
Mikel Astiz
fbcaf3f77a a2dp: avoid conversion between guint and pointers
These conversions might cause a segmentation fault in 64 bit machines.
2011-11-21 12:49:06 +02:00
Mikel Astiz
bfdcd55901 media: sep registration fix 2011-11-21 12:49:03 +02:00
Lucas De Marchi
3adcd9ed77 AVRCP: implement TRACK-REACHED-END event 2011-11-04 15:38:33 +02:00
Luiz Augusto von Dentz
4ed6c1c2a4 Add MediaPlayer.Release method
This is similar to MediaEndpoint.Release which is useful to notify the
player that it is no longer registered/active.
2011-10-28 15:15:48 +03:00
Lucas De Marchi
fd8dda80fc Fix leak of GTimer 2011-10-22 12:18:24 +02:00
Lucas De Marchi
ce8cd61098 Add missing TRACK-REACHED-START event
When track is changed, we automatically start to play it, therefore we
need to notify CT regarding this event.
2011-10-22 12:18:18 +02:00
Lucas De Marchi
2c920f6d68 AVRCP: implement TRACK-REACHED-START event 2011-10-18 10:25:43 +03:00
Lucas De Marchi
9ab125a8ec AVRCP: Use track's UID in event notification
When registering for TRACK_CHANGED event, CT expects the track's UID in
the INTERIM and CHANGED responses. According to AVRCP 1.3 spec, there
are only 2 possible values:
	1) 0: there's a track selected
	2) UINT32_MAX: there's no track selected

AVRCP 1.4 reserves the value UINT64_MAX for the second case. Since this
later value is the one used in certification process for best IOP
we return UINT64_MAX instead of the former.

This implementation allows to pass PTS test TP/NFY/BV-05-C.
2011-10-18 10:25:40 +03:00
Lucas De Marchi
239a0f68bb Make title always available in metadata 2011-10-13 16:09:52 +03:00
Lucas De Marchi
cd25bc2b76 Don't overwrite metadata when changing track
If we use the same hash table to set the new metadata, we have 2
undesired behaviors:

1) New track may contain fields from previous track if it didn't set all
the fields
2) If we fail on parsing the signal, we will still change some of the
fields
2011-10-13 16:08:29 +03:00
Lucas De Marchi
c684389188 Add callback to list available metadata IDs 2011-10-13 13:08:46 +03:00
Johan Hedberg
e34836262b Fix compilation error on 32-bit systems
This fixes the following compilation error with GLib on 32-bit sytems:

audio/media.c: In function 'get_setting':
audio/media.c:1109:44: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
audio/media.c: In function 'set_setting':
audio/media.c:1132:41: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
2011-10-12 00:28:51 +03:00
Luiz Augusto von Dentz
911f1b1be0 Fix crash while registering player
Crash is caused by not removed freed player from the list:

Invalid read of size 8
   at 0x13E7B5: media_adapter_find_player (media.c:861)
   by 0x13FEBC: register_player (media.c:1561)
   by 0x120DFE: process_message (object.c:224)
   by 0x4F6E9A0: ??? (in /lib64/libdbus-1.so.3.5.6)
   by 0x4F6092F: dbus_connection_dispatch (in /lib64/libdbus-1.so.3.5.6)
   by 0x11F787: message_dispatch (mainloop.c:80)
   by 0x4C762CA: ??? (in /lib64/libglib-2.0.so.0.3000.0)
   by 0x4C74ADC: g_main_context_dispatch (in /lib64/libglib-2.0.so.0.3000.0)
   by 0x4C752D7: ??? (in /lib64/libglib-2.0.so.0.3000.0)
   by 0x4C75824: g_main_loop_run (in /lib64/libglib-2.0.so.0.3000.0)
   by 0x11EE4B: main (main.c:485)
 Address 0x642ef30 is 16 bytes inside a block of size 80 free'd
   at 0x4A0662E: free (vg_replace_malloc.c:366)
   by 0x4C7B7F2: g_free (in /lib64/libglib-2.0.so.0.3000.0)
   by 0x12D292: player_destroy (avrcp.c:1099)
   by 0x120C38: service_filter (watch.c:477)
   by 0x120950: message_filter (watch.c:527)
   by 0x4F608E5: dbus_connection_dispatch (in /lib64/libdbus-1.so.3.5.6)
   by 0x11F787: message_dispatch (mainloop.c:80)
   by 0x4C762CA: ??? (in /lib64/libglib-2.0.so.0.3000.0)
   by 0x4C74ADC: g_main_context_dispatch (in /lib64/libglib-2.0.so.0.3000.0)
   by 0x4C752D7: ??? (in /lib64/libglib-2.0.so.0.3000.0)
   by 0x4C75824: g_main_loop_run (in /lib64/libglib-2.0.so.0.3000.0)
   by 0x11EE4B: main (main.c:485)
2011-10-06 18:46:54 +03:00
Luiz Augusto von Dentz
9cf1a84ef7 Fix not being able to unregister player via UnregisterPlayer 2011-10-06 18:46:49 +03:00
Lucas De Marchi
c7f32491a8 AVRCP: do not allow CT to set a property not supported
If player never set a property, it means it doesn't support it. Doesn't
allow the remote side to set it and send a REJECTED response.
2011-10-06 15:36:36 +03:00
Luiz Augusto von Dentz
14ae307458 AVRCP: move MediaPlayer to adapter object
This move the MediaPlayer registration to adapter object on Media
interface so we can track players properly.
2011-10-06 11:13:28 +03:00
Frédéric Dalleau
d3f534025c Update g_strcmp0 to strcasecmp 2011-08-24 14:21:07 +03:00
Frédéric Dalleau
9a0bab4796 Use state change callback from media interface
When a HFPHS endpoint is created, media will start to watch for
HandsfreeGateway state changes. media call SetConfiguration upon
connection and ClearConfiguration upon disconnection.
2011-08-24 14:21:03 +03:00
Frédéric Dalleau
a471827d1f Fix double free in error case in endpoint_reply
If SetConfiguration call fails, the headset or gateway for which
SetConfiguration is called is disconnected. This will free any
pending request, but this does not prevent the request to
terminate (endpoint_reply) and try to free itself once again.
Note that a copy of the freed pointer is tested which has not
been updated.
2011-08-24 14:20:55 +03:00
Luiz Augusto von Dentz
bd3ca4fdf4 Fix possible invalid read/free on media.c
This also fix the circular dependency of media.c and a2dp.c

 Invalid read of size 8
    at 0x4EA8CC2: g_slice_free_chain_with_offset (in /lib64/libglib-2.0.so.0.2908.0)
    by 0x13AF33: path_free (media.c:417)
    by 0x11EB39: remove_interface (object.c:563)
    by 0x11F360: g_dbus_unregister_interface (object.c:715)
    by 0x120C49: media_server_remove (manager.c:1098)
    by 0x4EA9826: g_slist_foreach (in /lib64/libglib-2.0.so.0.2908.0)
    by 0x178915: adapter_remove (adapter.c:2326)
    by 0x17535F: btd_manager_unregister_adapter (manager.c:293)
    by 0x154081: device_event (hciops.c:2643)
    by 0x1543C1: io_stack_event (hciops.c:2763)
    by 0x4E8C88C: g_main_context_dispatch (in /lib64/libglib-2.0.so.0.2908.0)
    by 0x4E8D087: ??? (in /lib64/libglib-2.0.so.0.2908.0)
  Address 0x63f6638 is 8 bytes inside a block of size 16 free'd
    at 0x4A055FE: free (vg_replace_malloc.c:366)
    by 0x4E938F2: g_free (in /lib64/libglib-2.0.so.0.2908.0)
    by 0x4EA854E: g_slice_free1 (in /lib64/libglib-2.0.so.0.2908.0)
    by 0x4EA930C: g_slist_remove (in /lib64/libglib-2.0.so.0.2908.0)
    by 0x13AE53: media_endpoint_remove (media.c:118)
    by 0x4EA9826: g_slist_foreach (in /lib64/libglib-2.0.so.0.2908.0)
    by 0x4EA984A: g_slist_free_full (in /lib64/libglib-2.0.so.0.2908.0)
    by 0x13AF33: path_free (media.c:417)
    by 0x11EB39: remove_interface (object.c:563)
    by 0x11F360: g_dbus_unregister_interface (object.c:715)
    by 0x120C49: media_server_remove (manager.c:1098)
    by 0x4EA9826: g_slist_foreach (in /lib64/libglib-2.0.so.0.2908.0)
2011-08-08 16:47:02 +03:00
Lukasz Rymanowski
c34e795644 Fix headset state callback in Media API
Headset watch is not registered per device. Therefore, when headset
disconnects, there is need to check for which audio device it is called.
2011-07-10 10:57:17 +03:00
Marcel Holtmann
3f553a30ad Allow building with GLib 2.16 for now 2011-07-04 11:09:55 +02:00
Luiz Augusto von Dentz
8306448148 Make use of g_slist_free_full on audio plugin 2011-06-30 14:38:59 +03:00
Rafal Michalski
a2d3f2d5c5 Fix invalid write to memory issue in media module
Under some circumstances (such as terminating bluetoothd during music is
streamed) endpoint object may be destroyed (memory for endpoint object is
internally freed, directly by "media_endpoint_remove") after invoking
"media_transport_destroy" (in "media_endpoint_clear_configuration") to
destroy transport object (memory for transport object is directly freed by
"media_transport_free"). It leads to invalid write issue (reported by
valgrind) after assignment "endpoint->transport = NULL", since "endpoint"
is "alias" pointer to endpoint object which is already out of date
(memory for endpoint object has been already freed).

This patch prevents from this issue by ensuring that assignment
"endpoint->transport = NULL" would be executed when endpoint object
certainly exists.
2011-06-14 12:07:18 +03:00
Lukasz Pawlik
7fec07d69c Fix type in conditional expression
Function media_endpoint_create returns pointer to structure. In
conditional expression it is safer to compare returned value with NULL
and not with gboolean as it is done in register_endpoint function.
2011-06-06 18:40:04 +09:00
Luiz Augusto von Dentz
dac323ffbd Rework adding/removing owners to a transport
Instead of directly add/remove and owner to transport list do it in a
separate function.
2011-03-27 22:50:59 +03:00
Luiz Augusto von Dentz
8095805736 Fix crash when unregistering a2dp driver before media driver
Since media driver uses a2dp to register its sep and store a pointer,
this pointer may be invalid/freed when media driver is unregistered.

To fix this now a2dp will also release any sep registered using media
API.

It also protect from future changes on the order of drivers removal by
checking if pointers (sep or endpoint) are still available in the list
before removing them.
2011-03-22 12:36:23 +02:00
Dmitriy Paliy
2da716f340 Add 'Protocol not supported' error in a2dp_add_sep
'Protocol not supported' error code is added to the registration of A2DP
end-points. Error response org.bluez.Error.NotSupported instead of
org.bluez.Error.InvalidArguments is used when SEP registration fails due
to disabled corresponding interface in audio.conf.
2011-03-17 14:35:55 +02:00
Luiz Augusto von Dentz
1a004cf882 Fix crash while parsering of endpoint properties
When parsing endpoint properties application my not have set some of the
mandatory properties, also the size of capability is now initialized with
0 so if the codec doesn't have any capabilities (e.g. pcm) the variable
won't be used uninitialized.
2011-02-02 13:56:12 +02:00
Luiz Augusto von Dentz
980481b0bf Fix memory leak when calling endpoint method
The pending call must be unrefed in those cases
2011-01-11 14:32:43 +02:00
Luiz Augusto von Dentz
ba801b05d9 Configure HFP/HSP endpoints if headset interface is already connected
HFP/HSP can be connected when registering an endpoint which is different
than on a2dp where the sep cannot be configured already since it wasn't
available before.
2010-12-22 00:18:35 +02:00
Luiz Augusto von Dentz
b417615911 Fix not calling SetConfiguration on hfp/hsp endpoints before connected
This cause some clients like PulseAudio to fail to find a proper
transport since connected state is send before transport configuration
is set.

To fix this now SetConfiguration is called early on when headset is still
in connecting phase, this matches sink/source where SetConfiguration is
also called before connected.
2010-12-16 16:31:55 +02:00