24
24
_xvd_xfconf_reinit_card(XvdInstance *Inst)
26
xvd_clean_card_name(Inst);
27
Inst->card_name = xvd_get_xfconf_card (Inst);
28
if (NULL == Inst->card_name) {
29
g_warning ("The new active card defined in the xfce mixer seems to be wrong.\n");
30
Inst->xvd_init_error = TRUE;
34
xvd_get_xfconf_card_from_mixer (Inst);
36
g_print ("New card : %s \n", Inst->card_name);
26
gchar *previous_card = NULL;
28
if (!xvd_xfconf_get_card (Inst)) {
29
// If we fail to get an xfconf card, we save the current one in xfconf
30
if (Inst->card_name != NULL) {
31
xvd_xfconf_set_card (Inst, Inst->card_name);
32
Inst->xfconf_card_name = g_strdup (Inst->card_name);
34
// If the current card is NULL too, we do nothing
38
// If the card set in xfconf is the same as the currently used one, we do nothing
39
if ((Inst->card_name != NULL) && (g_strcmp0 (Inst->xfconf_card_name, Inst->card_name) == 0)) {
43
// We now try to replace it with the one set in xfconf
44
previous_card = g_strdup (Inst->card_name);
45
xvd_get_card_from_mixer (Inst, Inst->xfconf_card_name, previous_card);
47
// At this stage the track grabbed is wrong, but we expect the user to also update the track key
49
// We check if the card has been correctly set
50
if ((Inst->card_name == NULL) || (g_strcmp0 (Inst->xfconf_card_name, Inst->card_name) != 0)) {
51
g_debug ("The card chosen in xfconf could not be set, another one was set instead\nChosen: %s\nSet: %s\n",
52
Inst->xfconf_card_name,
54
// If not, we save the valid card in xfconf instead of the user chosen
55
// TODO we should actually refresh the mixers prior to finding the new card
56
xvd_xfconf_set_card (Inst, Inst->card_name);
57
g_free (Inst->xfconf_card_name);
58
Inst->xfconf_card_name = g_strdup (Inst->card_name);
61
g_debug ("The card change succeeded with the new xfconf card %s.\n", Inst->xfconf_card_name);
64
g_free (previous_card);
66
// If an xfconf track has failed to be applied before, it's probably that the user chosed his new track before the card to which it belongs.
67
// So we check if the track belongs to our new card.
68
if (Inst->previously_set_track_label) {
69
xvd_get_track_from_mixer (Inst, Inst->previously_set_track_label, Inst->track_label);
70
if (g_strcmp0 (Inst->previously_set_track_label, Inst->track_label) == 0) {
71
xvd_xfconf_set_track (Inst, Inst->previously_set_track_label);
72
g_free (Inst->previously_set_track_label);
73
g_debug ("The previously set xfconf track was a track from the newly set sound card.\n");
76
// Else, we can still try to see if the current track applies
78
xvd_get_track_from_mixer (Inst, Inst->track_label, NULL);
81
xvd_mixer_init_volume (Inst);
83
g_debug ("Xfconf reinit: the card is now %s, the track is %s and the volume is %d\n", Inst->card_name, Inst->track_label, Inst->current_vol);
42
87
_xvd_xfconf_reinit_track(XvdInstance *Inst)
44
xvd_clean_track (Inst);
46
gchar *tmp_track = xvd_get_xfconf_track (Inst);
47
xvd_get_xfconf_track_from_mixer (Inst, tmp_track);
89
gchar *previous_track = NULL;
91
if (!xvd_xfconf_get_track (Inst)) {
92
// If we fail to get an xfconf track, we save the current one in xfconf
93
if (Inst->track_label != NULL) {
94
xvd_xfconf_set_track (Inst, Inst->track_label);
95
Inst->xfconf_track_label = g_strdup (Inst->track_label);
97
// If the current track is NULL too, we do nothing
101
// If the track set in xfconf is the same as the currently used one, we do nothing
102
if ((Inst->track_label != NULL) && (g_strcmp0 (Inst->xfconf_track_label, Inst->track_label) == 0)) {
106
// We now try to replace it with the one set in xfconf
107
previous_track = g_strdup (Inst->track_label);
108
xvd_get_track_from_mixer (Inst, Inst->xfconf_track_label, previous_track);
110
// We check if the track has been correctly set
111
if ((Inst->track_label == NULL) || (g_strcmp0 (Inst->xfconf_track_label, Inst->track_label) != 0)) {
112
// If not, we save the valid track in xfconf instead of the user chosen
113
Inst->previously_set_track_label = g_strdup (Inst->xfconf_track_label);
114
g_debug ("The track chosen in xfconf (%s) doesn't exist in the current card. It'll be tried again after a sound card change.\nNow using %s.\n",
115
Inst->xfconf_track_label,
117
xvd_xfconf_set_track (Inst, Inst->track_label);
118
g_free (Inst->xfconf_track_label);
119
Inst->xfconf_track_label = g_strdup (Inst->track_label);
122
g_free (Inst->previously_set_track_label);
50
125
xvd_mixer_init_volume (Inst);
52
g_print ("New track : %s with volume %d\n", Inst->track_label, Inst->current_vol);
126
g_free (previous_track);
128
g_debug ("Xfconf reinit: the track is now %s and the volume is %d\n", Inst->track_label, Inst->current_vol);
58
133
_xvd_xfconf_reinit_vol_step(XvdInstance *Inst)
60
xvd_load_xfconf_vol_step (Inst);
62
g_print ("New volume step : %u\n", Inst->vol_step);
135
xvd_xfconf_get_vol_step (Inst);
136
g_debug ("Xfconf reinit: volume step is now %u\n", Inst->vol_step);
99
170
g_signal_connect (G_OBJECT (Inst->chan), "property-changed", G_CALLBACK (_xvd_xfconf_handle_changes), Inst);
103
xvd_get_xfconf_card(XvdInstance *Inst)
174
xvd_xfconf_get_card(XvdInstance *Inst)
176
if (Inst->xfconf_card_name) {
177
g_debug ("%s\n", "Cleaning the current card name stored in xfconf");
178
g_free (Inst->xfconf_card_name);
105
181
if (FALSE == xfconf_channel_has_property (Inst->chan, XFCONF_MIXER_ACTIVECARD)) {
106
182
// Transition purpose - we dont watch changes on the legacy property afterwards
107
183
if (FALSE == xfconf_channel_has_property (Inst->chan, XFCONF_MIXER_ACTIVECARD_LEGACY)) {
108
g_warning ("%s\n", "Error while trying to retrieve the mixer channel's active card");
184
g_debug ("%s\n", "There is no card name stored in xfconf");
112
g_warning ("%s\n", "Using the legacy xfconf property for the active card");
113
gchar *legacy_value = xfconf_channel_get_string (Inst->chan, XFCONF_MIXER_ACTIVECARD_LEGACY, NULL);
114
xvd_xfconf_set_card (Inst, legacy_value);
188
g_debug ("%s\n", "Using the legacy xfconf property for the card name, and saving its value into the new xfconf property");
189
Inst->xfconf_card_name = xfconf_channel_get_string (Inst->chan, XFCONF_MIXER_ACTIVECARD_LEGACY, NULL);
190
xvd_xfconf_set_card (Inst, Inst->xfconf_card_name);
191
g_debug ("%s %s\n", "Xfconf card name:", Inst->xfconf_card_name);
192
return Inst->xfconf_card_name != NULL;
119
return xfconf_channel_get_string (Inst->chan, XFCONF_MIXER_ACTIVECARD, NULL);
123
xvd_get_xfconf_track(XvdInstance *Inst)
125
return xfconf_channel_get_string (Inst->chan, XFCONF_MIXER_ACTIVETRACK, NULL);
129
xvd_load_xfconf_vol_step(XvdInstance *Inst)
196
Inst->xfconf_card_name = xfconf_channel_get_string (Inst->chan, XFCONF_MIXER_ACTIVECARD, NULL);
197
return Inst->xfconf_card_name != NULL;
201
xvd_xfconf_set_card(XvdInstance *Inst, gchar *value)
203
g_debug ("%s %s\n", "Setting the xfconf card name to", value);
204
xfconf_channel_set_string (Inst->chan, XFCONF_MIXER_ACTIVECARD, value);
208
xvd_xfconf_get_track(XvdInstance *Inst)
210
if (Inst->xfconf_track_label) {
211
g_debug ("%s\n", "Cleaning the current track label stored in xfconf");
212
g_free (Inst->xfconf_track_label);
215
Inst->xfconf_track_label = xfconf_channel_get_string (Inst->chan, XFCONF_MIXER_ACTIVETRACK, NULL);
216
if (Inst->xfconf_track_label != NULL) {
217
g_debug ("%s %s\n", "Xfconf track label:", Inst->xfconf_track_label);
221
g_debug ("%s\n", "There is no track label stored in xfconf");
227
xvd_xfconf_set_track(XvdInstance *Inst, gchar *value)
229
g_debug("%s %s\n", "Setting the xfconf card name to", value);
230
xfconf_channel_set_string (Inst->chan, XFCONF_MIXER_ACTIVETRACK, value);
234
xvd_xfconf_get_vol_step(XvdInstance *Inst)
131
236
Inst->vol_step = xfconf_channel_get_uint (Inst->chan, XFCONF_MIXER_VOL_STEP, -1);
132
237
if ((Inst->vol_step < 0) || (Inst->vol_step > 100)) {
238
g_debug ("%s\n", "The volume step xfconf property is out of range, setting back to default");
133
239
Inst->vol_step = VOL_STEP_DEFAULT_VAL;
134
240
xfconf_channel_set_uint (Inst->chan, XFCONF_MIXER_VOL_STEP, VOL_STEP_DEFAULT_VAL);
242
g_debug("%s %u\n", "Xfconf volume step:", Inst->vol_step);