33
33
if ((error = ca_context_play (mCanberraContext, 0,
34
CA_PROP_EVENT_ID, "bell",
35
CA_PROP_MEDIA_FILENAME, mFilename.c_str (),
36
CA_PROP_CANBERRA_CACHE_CONTROL, "permanent",
34
CA_PROP_EVENT_ID, "bell",
35
CA_PROP_CANBERRA_CACHE_CONTROL, "permanent",
39
compLogMessage ("bell", CompLogLevelWarn, "couldn't play sound %s - %s",
40
mFilename.c_str (), ca_strerror (error));
38
compLogMessage ("bell", CompLogLevelWarn, "couldn't play bell - %s",
43
42
/* Allow other plugins to handle bell event */
48
AudibleBell::filenameChange(CompOption *option,
53
mFilename = optionGetFilename();
55
if ((error = ca_context_change_props (mCanberraContext,
56
CA_PROP_APPLICATION_NAME, "Compiz bell",
57
CA_PROP_APPLICATION_ID, "org.freedesktop.compiz.Bell",
58
CA_PROP_WINDOW_X11_SCREEN, screen->displayString(),
61
compLogMessage ("bell", CompLogLevelWarn, "couldn't change context properties - %s",
65
if ((error = ca_context_cache (mCanberraContext,
66
CA_PROP_EVENT_ID, "bell",
67
CA_PROP_MEDIA_FILENAME, mFilename.c_str (),
68
CA_PROP_CANBERRA_CACHE_CONTROL, "permanent",
71
compLogMessage ("bell", CompLogLevelWarn, "couldn't change context cache - %s",
77
46
AudibleBell::AudibleBell (CompScreen *screen) :
78
47
PluginClassHandler <AudibleBell, CompScreen> (screen),
79
mCanberraContext (NULL),
80
mFilename (optionGetFilename ())
48
mCanberraContext (NULL)
83
boost::function <void (CompOption *, Options)> fileNameChangedCallback;
84
51
boost::function <bool (CompAction *, CompAction::State, CompOption::Vector &)> bellCallback;
86
53
if ((error = ca_context_create (&mCanberraContext)) < 0)
118
fileNameChangedCallback =
119
boost::bind (&AudibleBell::filenameChange, this, _1, _2);
121
boost::bind (&AudibleBell::bell, this);
86
boost::bind (&AudibleBell::bell, this);
123
optionSetFilenameNotify (fileNameChangedCallback);
124
88
optionSetBellInitiate (bellCallback);