553
// Handle a network sink => a portless/cardless device
554
if (gvc_mixer_ui_device_get_port (output) == NULL){
555
g_print ("Did we try to move to a network sink ? \n");
554
// Handle a network sink => a portless or cardless device
555
if (gvc_mixer_ui_device_is_software (output) || gvc_mixer_ui_device_is_bluetooth (output)){
556
g_print ("Did we try to move to a software/bluetooth sink ? \n");
556
557
if (gvc_mixer_control_set_default_sink (control, stream)) {
557
558
// sink change successfull => update the UI.
558
559
g_signal_emit (G_OBJECT (control),
641
642
// Handle a network sink => a portless/cardless device
642
if (gvc_mixer_ui_device_get_port (input) == NULL){
643
g_print ("Did we try to move to a network source ? \n");
643
if (gvc_mixer_ui_device_is_software (input) || gvc_mixer_ui_device_is_bluetooth (input)){
644
g_print ("\n Did we try to move to a software/bluetooth source ? \n");
644
645
if (gvc_mixer_control_set_default_source (control, stream)) {
645
// source change successfull => update the UI.
646
646
g_signal_emit (G_OBJECT (control),
647
647
signals[ACTIVE_INPUT_UPDATE],
649
gvc_mixer_ui_device_get_id (input));
649
gvc_mixer_ui_device_get_id (input));
652
652
g_warning ("Failed to set default source with stream from input %s \n",
1236
1236
sync_devices (GvcMixerControl *control,
1237
1237
GvcMixerStream* stream, int is_output)
1240
1239
// Go through ports to see what outputs can be created.
1241
1240
const GList *stream_ports = NULL;
1242
1241
const GList *n = NULL;
1244
1244
stream_ports = gvc_mixer_stream_get_ports (stream);
1245
1245
gint stream_port_count = 0;
1247
1247
if (g_list_length (stream_ports) == 0){
1248
g_print (" \n \n !!! Just found a %s without ports - creating a UI device \n", is_output ? "sink" : "source");
1251
object = g_object_new (GVC_TYPE_MIXER_UI_DEVICE,
1252
"stream-id", (gint)gvc_mixer_stream_get_id (stream),
1253
"description", gvc_mixer_stream_get_description (stream),
1254
"origin", "", /*Leave it empty for these special cases*/
1256
"port-available", TRUE,
1258
GvcMixerUIDevice* out = GVC_MIXER_UI_DEVICE (object);
1248
GvcMixerUIDevice* device;
1260
1250
if (gvc_mixer_stream_get_card_index (stream) != PA_INVALID_INDEX) {
1261
// Detecting bluetooth device !
1262
g_object_set ( object,
1264
gvc_mixer_stream_get_card_index (stream), NULL);
1251
g_print ("\n \n Bluetooth device \n \n");
1255
if (GVC_IS_MIXER_SOURCE (stream)){
1256
devices = g_hash_table_get_values (control->priv->ui_inputs);
1259
devices = g_hash_table_get_values (control->priv->ui_outputs);
1262
gboolean in_possession = FALSE;
1264
for (d = devices; d != NULL; d = d->next) {
1267
g_object_get (G_OBJECT (device),
1268
"card-id", &card_id,
1270
if (card_id == gvc_mixer_stream_get_card_index (stream)){
1271
in_possession = TRUE;
1275
if (!in_possession){
1276
g_warning ("\n \n Couldn't match the bluetooth stream \n \n");
1265
1280
GvcMixerCard* card = NULL;
1266
1281
card = gvc_mixer_control_lookup_card_id (control,
1267
1282
gvc_mixer_stream_get_card_index (stream));
1268
const GList *profiles = NULL;
1269
profiles = gvc_mixer_card_get_profiles (card);
1270
if (profiles == NULL){
1271
g_warning ("Card has no profiles");
1274
g_print ("\n Is this a bluetooth device, portless yet a card with profiles \n");
1275
gvc_mixer_ui_device_set_profiles (out, profiles);
1279
g_hash_table_insert (is_output ? control->priv->ui_outputs : control->priv->ui_inputs,
1280
GUINT_TO_POINTER (gvc_mixer_ui_device_get_id (out)),
1281
g_object_ref (out));
1283
g_object_set (G_OBJECT (device),
1284
"stream-id", (gint)gvc_mixer_stream_get_id (stream),
1285
"description", gvc_mixer_stream_get_description (stream),
1286
"origin", "", /*Leave it empty for these special cases*/
1288
"port-available", TRUE,
1292
g_print ("\n \n software device \n");
1295
object = g_object_new (GVC_TYPE_MIXER_UI_DEVICE,
1296
"stream-id", (gint)gvc_mixer_stream_get_id (stream),
1297
"description", gvc_mixer_stream_get_description (stream),
1298
"origin", "", /*Leave it empty for these special cases*/
1300
"port-available", TRUE,
1302
device = GVC_MIXER_UI_DEVICE (object);
1304
g_hash_table_insert (is_output ? control->priv->ui_outputs : control->priv->ui_inputs,
1305
GUINT_TO_POINTER (gvc_mixer_ui_device_get_id (device)),
1306
g_object_ref (device));
1283
1309
g_signal_emit (G_OBJECT (control),
1284
1310
signals[is_output ? OUTPUT_ADDED : INPUT_ADDED],
1286
gvc_mixer_ui_device_get_id (out));
1312
gvc_mixer_ui_device_get_id (device));
2066
2090
card_ports = gvc_mixer_card_get_ports (card);
2093
port_count = g_list_length (card_ports);
2095
if (port_count == 0 && is_new){
2096
// TODO : move to its own method.
2097
g_print ("\n Bluetooth card just registered \n");
2098
// For now just create two devices and presume this device is multi directional
2099
// Ensure to remove both on card removal (available to false by default)
2100
const GList *profiles = NULL;
2101
profiles = gvc_mixer_card_get_profiles (card);
2104
object = g_object_new (GVC_TYPE_MIXER_UI_DEVICE,
2106
"description", gvc_mixer_card_get_name (card),
2107
"origin", "", /*Leave it empty for these special cases*/
2109
"port-available", FALSE,
2110
"card-id", gvc_mixer_card_get_index (card),
2112
GvcMixerUIDevice* in = GVC_MIXER_UI_DEVICE (object);
2113
gvc_mixer_ui_device_set_profiles (in, profiles);
2115
g_hash_table_insert (control->priv->ui_inputs,
2116
GUINT_TO_POINTER (gvc_mixer_ui_device_get_id (in)),
2118
object = g_object_new (GVC_TYPE_MIXER_UI_DEVICE,
2120
"description", gvc_mixer_card_get_name (card),
2121
"origin", "", /*Leave it empty for these special cases*/
2123
"port-available", FALSE,
2124
"card-id", gvc_mixer_card_get_index (card),
2126
GvcMixerUIDevice* out = GVC_MIXER_UI_DEVICE (object);
2127
gvc_mixer_ui_device_set_profiles (out, profiles);
2129
g_hash_table_insert (control->priv->ui_outputs,
2130
GUINT_TO_POINTER (gvc_mixer_ui_device_get_id (out)),
2131
g_object_ref (out));
2068
2134
for (m = card_ports; m != NULL; m = m->next) {
2069
2135
GvcMixerCardPort *card_port;
2070
2136
card_port = m->data;