diff options
| -rw-r--r-- | audio/headset.c | 31 | ||||
| -rw-r--r-- | audio/headset.h | 4 | ||||
| -rw-r--r-- | audio/unix.c | 24 | 
3 files changed, 58 insertions, 1 deletions
| diff --git a/audio/headset.c b/audio/headset.c index 75affd37..27580c5d 100644 --- a/audio/headset.c +++ b/audio/headset.c @@ -2144,6 +2144,37 @@ unsigned int headset_request_stream(struct audio_device *dev,  	return id;  } +unsigned int headset_suspend_stream(struct audio_device *dev, +					headset_stream_cb_t cb, +					headset_lock_t lock, +					void *user_data) +{ +	struct headset *hs = dev->headset; +	unsigned int id; + +	if (hs->lock & ~lock) +		return 0; + +	if (!hs->rfcomm) +		return 0; + +	if (hs->dc_timer) { +		g_source_remove(hs->dc_timer); +		hs->dc_timer = 0; +	} + +	if (hs->state == HEADSET_STATE_CONNECT_IN_PROGRESS || +			hs->state == HEADSET_STATE_PLAY_IN_PROGRESS) +		return connect_cb_new(hs, HEADSET_STATE_CONNECTED, cb, +					user_data); + +	close_sco(dev); +	id = connect_cb_new(hs, HEADSET_STATE_CONNECTED, cb, user_data); +	g_idle_add((GSourceFunc) dummy_connect_complete, dev); + +	return id; +} +  gboolean get_hfp_active(struct audio_device *dev)  {  	struct headset *hs = dev->headset; diff --git a/audio/headset.h b/audio/headset.h index 18205c4d..25c7acf2 100644 --- a/audio/headset.h +++ b/audio/headset.h @@ -56,6 +56,10 @@ unsigned int headset_request_stream(struct audio_device *dev,  					headset_stream_cb_t cb,  					headset_lock_t lock,  					void *user_data); +unsigned int headset_suspend_stream(struct audio_device *dev, +					headset_stream_cb_t cb, +					headset_lock_t lock, +					void *user_data);  gboolean headset_cancel_stream(struct audio_device *dev, unsigned int id);  gboolean get_hfp_active(struct audio_device *dev); diff --git a/audio/unix.c b/audio/unix.c index e40aa418..ea5e3b8a 100644 --- a/audio/unix.c +++ b/audio/unix.c @@ -320,6 +320,28 @@ failed:  	client->dev = NULL;  } +static void headset_suspend_complete(struct audio_device *dev, void *user_data) +{ +	struct unix_client *client = user_data; +	char buf[BT_AUDIO_IPC_PACKET_SIZE]; +	struct bt_streamstart_rsp *rsp = (void *) buf; + +	if (!dev) +		goto failed; + +	memset(buf, 0, sizeof(buf)); +	rsp->rsp_h.msg_h.msg_type = BT_STREAMSTOP_RSP; +	rsp->rsp_h.posix_errno = 0; +	unix_ipc_sendmsg(client, &rsp->rsp_h.msg_h); + +	return; + +failed: +	error("suspend failed"); +	unix_ipc_error(client, BT_STREAMSTOP_RSP, EIO); +	client->dev = NULL; +} +  static void a2dp_discovery_complete(struct avdtp *session, GSList *seps,  					struct avdtp_error *err,  					void *user_data) @@ -735,7 +757,7 @@ static void start_suspend(struct audio_device *dev, struct unix_client *client)  	case TYPE_HEADSET:  		hs = &client->d.hs; -		id = headset_request_stream(dev, headset_setup_complete, +		id = headset_suspend_stream(dev, headset_suspend_complete,  					hs->lock, client);  		client->cancel = headset_cancel_stream;  		break; | 
