Skip to content

Commit

Permalink
Automatically reload sound system when alsa channel is skewed
Browse files Browse the repository at this point in the history
Fixes #182
  • Loading branch information
hasufell committed Jun 20, 2018
1 parent 06beb62 commit ce1d1a3
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/alsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -699,9 +699,9 @@ poll_watch_cb(GIOChannel *source, GIOCondition condition, AlsaCard *card)

case G_IO_STATUS_NORMAL:
/* Actually bad, alsa failed to clear channel */
ERROR("Alsa failed to clear the channel");
WARN("Alsa failed to clear the channel");
if (callback)
callback(ALSA_CARD_ERROR, data);
callback(ALSA_CARD_RELOAD, data);
break;

case G_IO_STATUS_ERROR:
Expand Down
3 changes: 2 additions & 1 deletion src/alsa.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ void alsa_card_free(AlsaCard *card);
enum alsa_event {
ALSA_CARD_ERROR,
ALSA_CARD_DISCONNECTED,
ALSA_CARD_VALUES_CHANGED
ALSA_CARD_VALUES_CHANGED,
ALSA_CARD_RELOAD,
};

typedef void (*AlsaCb) (enum alsa_event event, gpointer data);
Expand Down
5 changes: 5 additions & 0 deletions src/audio.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ audio_signal_to_str(AudioSignal signal)
return "card disconnected";
case AUDIO_CARD_ERROR:
return "card error";
case AUDIO_CARD_RELOAD:
return "card to be reloaded";
case AUDIO_VALUES_CHANGED:
return "values changed";
default:
Expand Down Expand Up @@ -305,6 +307,9 @@ on_alsa_event(enum alsa_event event, gpointer data)
case ALSA_CARD_VALUES_CHANGED:
invoke_handlers(audio, AUDIO_VALUES_CHANGED, AUDIO_USER_UNKNOWN);
break;
case ALSA_CARD_RELOAD:
invoke_handlers(audio, AUDIO_CARD_RELOAD, AUDIO_USER_UNKNOWN);
break;
default:
WARN("Unhandled alsa event: %d", event);
}
Expand Down
1 change: 1 addition & 0 deletions src/audio.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ enum audio_signal {
AUDIO_CARD_DISCONNECTED,
AUDIO_CARD_ERROR,
AUDIO_VALUES_CHANGED,
AUDIO_CARD_RELOAD,
};

typedef enum audio_signal AudioSignal;
Expand Down
2 changes: 2 additions & 0 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,8 @@ on_audio_changed(Audio *audio, AudioEvent *event, G_GNUC_UNUSED gpointer data)
if (run_audio_error_dialog() == GTK_RESPONSE_YES)
audio_reload(audio);
break;
case AUDIO_CARD_RELOAD:
audio_reload(audio);
default:
break;
}
Expand Down

0 comments on commit ce1d1a3

Please sign in to comment.