Lines Matching full:sink
45 #include "sink.h"
58 struct sink {
95 error("Invalid sink state %d", state);
102 struct sink *sink = dev->sink;
104 sink_state_t old_state = sink->state;
107 sink->state = new_state;
127 struct sink *sink = dev->sink;
129 if (sink == NULL)
134 if (sink->state != SINK_STATE_CONNECTING) {
142 if (sink->dc_id) {
144 sink->dc_id);
145 sink->dc_id = 0;
157 sink->session_state = new_state;
177 struct sink *sink = device->sink;
179 DBG("Sink: disconnect %s", device->path);
181 avdtp_close(sink->session, sink->stream, TRUE);
191 struct sink *sink = dev->sink;
199 if (sink->disconnect) {
203 p = sink->disconnect;
204 sink->disconnect = NULL;
211 if (sink->dc_id) {
213 sink->dc_id);
214 sink->dc_id = 0;
217 if (sink->session) {
218 avdtp_unref(sink->session);
219 sink->session = NULL;
221 sink->stream = NULL;
222 sink->cb_id = 0;
226 sink->state == SINK_STATE_CONNECTING) {
236 sink->dc_id = device_add_disconnect_watch(dev->btd_dev,
268 sink->stream_state = new_state;
279 struct sink *sink = user_data;
280 struct pending_request *pending = sink->connect;
282 sink->retry_id = 0;
284 if (sink->stream_state >= AVDTP_STATE_OPEN) {
297 sink->connect = NULL;
298 pending_request_free(sink->dev, pending);
307 struct sink *sink = user_data;
310 pending = sink->connect;
323 sink->connect = NULL;
324 pending_request_free(sink->dev, pending);
329 avdtp_unref(sink->session);
330 sink->session = NULL;
334 sink->retry_id = g_timeout_add_seconds(STREAM_SETUP_RETRY_TIMER,
336 sink);
340 sink->connect = NULL;
341 pending_request_free(sink->dev, pending);
491 struct sink *sink = user_data;
499 pending = sink->connect;
502 avdtp_unref(sink->session);
503 sink->session = NULL;
507 sink->retry_id =
510 sink);
535 id = a2dp_config(sink->session, sep, stream_setup_complete, caps, sink);
545 pending_request_free(sink->dev, pending);
546 sink->connect = NULL;
547 avdtp_unref(sink->session);
548 sink->session = NULL;
551 gboolean sink_setup_stream(struct sink *sink, struct avdtp *session)
553 if (sink->connect || sink->disconnect)
556 if (session && !sink->session)
557 sink->session = avdtp_ref(session);
559 if (!sink->session)
562 avdtp_set_auto_disconnect(sink->session, FALSE);
564 if (avdtp_discover(sink->session, discovery_complete, sink) < 0)
567 sink->connect = g_new0(struct pending_request, 1);
576 struct sink *sink = dev->sink;
579 if (!sink->session)
580 sink->session = avdtp_get(&dev->src, &dev->dst);
582 if (!sink->session)
586 if (sink->connect || sink->disconnect)
590 if (sink->stream_state >= AVDTP_STATE_OPEN)
595 if (!sink_setup_stream(sink, NULL))
601 pending = sink->connect;
615 struct sink *sink = device->sink;
619 if (!sink->session)
624 if (sink->connect || sink->disconnect)
628 if (sink->stream_state < AVDTP_STATE_OPEN) {
632 avdtp_unref(sink->session);
633 sink->session = NULL;
637 err = avdtp_close(sink->session, sink->stream, FALSE);
645 sink->disconnect = pending;
654 struct sink *sink = device->sink;
658 if (!sink->session)
663 if (sink->connect || sink->disconnect)
667 if (sink->state < AVDTP_STATE_OPEN) {
671 avdtp_unref(sink->session);
672 sink->session = NULL;
676 err = avdtp_suspend(sink->session, sink->stream);
688 struct sink *sink = device->sink;
692 if (!sink->session)
697 if (sink->connect || sink->disconnect)
701 if (sink->state < AVDTP_STATE_OPEN) {
705 avdtp_unref(sink->session);
706 sink->session = NULL;
710 err = avdtp_start(sink->session, sink->stream);
723 struct sink *sink = device->sink;
731 connected = (sink->stream_state >= AVDTP_STATE_CONFIGURED);
743 struct sink *sink = device->sink;
762 value = (sink->stream_state == AVDTP_STATE_STREAMING);
766 value = (sink->stream_state >= AVDTP_STATE_CONFIGURED);
770 state = state2str(sink->state);
805 struct sink *sink = dev->sink;
807 if (sink->cb_id)
808 avdtp_stream_remove_cb(sink->session, sink->stream,
809 sink->cb_id);
811 if (sink->dc_id)
812 device_remove_disconnect_watch(dev->btd_dev, sink->dc_id);
814 if (sink->session)
815 avdtp_unref(sink->session);
817 if (sink->connect)
818 pending_request_free(dev, sink->connect);
820 if (sink->disconnect)
821 pending_request_free(dev, sink->disconnect);
823 if (sink->retry_id)
824 g_source_remove(sink->retry_id);
826 g_free(sink);
827 dev->sink = NULL;
846 struct sink *sink_init(struct audio_device *dev)
848 struct sink *sink;
863 sink = g_new0(struct sink, 1);
865 sink->dev = dev;
867 return sink;
872 struct sink *sink = dev->sink;
874 if (sink->session)
882 struct sink *sink = dev->sink;
892 struct sink *sink = dev->sink;
894 return sink->stream_state;
900 struct sink *sink = dev->sink;
902 if (sink->stream)
905 if (!sink->session)
906 sink->session = avdtp_ref(session);
908 sink->stream = stream;
910 sink->cb_id = avdtp_stream_add_cb(session, stream,
916 gboolean sink_shutdown(struct sink *sink)
918 if (!sink->stream)
921 if (avdtp_close(sink->session, sink->stream, FALSE) < 0)