diff options
| -rw-r--r-- | audio/headset.c | 28 | ||||
| -rw-r--r-- | audio/unix.c | 27 | 
2 files changed, 34 insertions, 21 deletions
| diff --git a/audio/headset.c b/audio/headset.c index 27580c5d..a7a0a969 100644 --- a/audio/headset.c +++ b/audio/headset.c @@ -2113,9 +2113,6 @@ unsigned int headset_request_stream(struct audio_device *dev,  	struct headset *hs = dev->headset;  	unsigned int id; -	if (hs->lock & lock) -		return 0; -  	if (hs->rfcomm && hs->sco) {  		id = connect_cb_new(hs, HEADSET_STATE_PLAYING, cb, user_data);  		g_idle_add((GSourceFunc) dummy_connect_complete, dev); @@ -2152,10 +2149,7 @@ unsigned int headset_suspend_stream(struct audio_device *dev,  	struct headset *hs = dev->headset;  	unsigned int id; -	if (hs->lock & ~lock) -		return 0; - -	if (!hs->rfcomm) +	if (hs->lock & lock)  		return 0;  	if (hs->dc_timer) { @@ -2163,15 +2157,27 @@ unsigned int headset_suspend_stream(struct audio_device *dev,  		hs->dc_timer = 0;  	} -	if (hs->state == HEADSET_STATE_CONNECT_IN_PROGRESS || -			hs->state == HEADSET_STATE_PLAY_IN_PROGRESS) +	if (hs->state == HEADSET_STATE_CONNECT_IN_PROGRESS)  		return connect_cb_new(hs, HEADSET_STATE_CONNECTED, cb,  					user_data); -	close_sco(dev); +	if (hs->sco) { +		close_sco(dev); +		goto done; +	} else if (hs->rfcomm) +		goto done; + +	if (rfcomm_connect(dev, cb, user_data, &id) < 0) +		return 0; + +	hs->auto_dc = TRUE; +	hs->pending->target_state = HEADSET_STATE_CONNECTED; + +	return id; + +done:  	id = connect_cb_new(hs, HEADSET_STATE_CONNECTED, cb, user_data);  	g_idle_add((GSourceFunc) dummy_connect_complete, dev); -  	return id;  } diff --git a/audio/unix.c b/audio/unix.c index a82d10ff..c6187ac8 100644 --- a/audio/unix.c +++ b/audio/unix.c @@ -315,7 +315,7 @@ static void headset_resume_complete(struct audio_device *dev, void *user_data)  	return;  failed: -	error("resume failed"); +	error("headset_resume_complete: resume failed");  	unix_ipc_error(client, BT_STREAMSTART_RSP, EIO);  } @@ -611,8 +611,8 @@ failed:  static void start_config(struct audio_device *dev, struct unix_client *client)  {  	struct a2dp_data *a2dp; -	unsigned int id;  	struct headset_data *hs; +	unsigned int id;  	client->type = select_service(dev, client->interface); @@ -635,6 +635,7 @@ static void start_config(struct audio_device *dev, struct unix_client *client)  	case TYPE_HEADSET:  		hs = &client->d.hs; +  		switch (client->access_mode) {  		case BT_CAPABILITIES_ACCESS_MODE_READ:  			hs->lock = HEADSET_LOCK_READ; @@ -649,7 +650,8 @@ static void start_config(struct audio_device *dev, struct unix_client *client)  			hs->lock = 0;  			break;  		} -		id = headset_request_stream(dev, headset_setup_complete, + +		id = headset_suspend_stream(dev, headset_setup_complete,  					hs->lock, client);  		client->cancel = headset_cancel_stream;  		break; @@ -676,6 +678,7 @@ failed:  static void start_resume(struct audio_device *dev, struct unix_client *client)  {  	struct a2dp_data *a2dp; +	struct headset_data *hs;  	unsigned int id;  	client->type = select_service(dev, client->interface); @@ -701,15 +704,14 @@ static void start_resume(struct audio_device *dev, struct unix_client *client)  					a2dp_resume_complete, client);  		client->cancel = a2dp_source_cancel; -		if (id == 0) { -			error("resume failed"); -			goto failed; -		} -  		break;  	case TYPE_HEADSET: -		headset_resume_complete(dev, client); +		hs = &client->d.hs; + +		id = headset_request_stream(dev, headset_resume_complete, +					hs->lock, client); +		client->cancel = headset_cancel_stream;  		break;  	default: @@ -717,6 +719,11 @@ static void start_resume(struct audio_device *dev, struct unix_client *client)  		goto failed;  	} +	if (id == 0) { +		error("start_resume: resume failed"); +		goto failed; +	} +  	return;  failed: @@ -757,7 +764,7 @@ static void start_suspend(struct audio_device *dev, struct unix_client *client)  		hs = &client->d.hs;  		id = headset_suspend_stream(dev, headset_suspend_complete, -					hs->lock, client); +					~hs->lock, client);  		client->cancel = headset_cancel_stream;  		break; | 
