Report when unable to execute alsactl
This commit is contained in:
parent
7072faf64e
commit
74d63f15ef
@ -63,7 +63,7 @@ PhonePlugin plugin =
|
|||||||
/* private */
|
/* private */
|
||||||
/* functions */
|
/* functions */
|
||||||
/* openmoko_event */
|
/* openmoko_event */
|
||||||
static int _event_mixer_set(char const * filename);
|
static int _event_mixer_set(PhonePlugin * plugin, char const * filename);
|
||||||
static int _event_vibrator(PhonePlugin * plugin, gboolean vibrate);
|
static int _event_vibrator(PhonePlugin * plugin, gboolean vibrate);
|
||||||
|
|
||||||
static int _openmoko_event(PhonePlugin * plugin, PhoneEvent event, ...)
|
static int _openmoko_event(PhonePlugin * plugin, PhoneEvent event, ...)
|
||||||
@ -72,22 +72,22 @@ static int _openmoko_event(PhonePlugin * plugin, PhoneEvent event, ...)
|
|||||||
{
|
{
|
||||||
case PHONE_EVENT_CALL_ESTABLISHED:
|
case PHONE_EVENT_CALL_ESTABLISHED:
|
||||||
/* let us hear the call */
|
/* let us hear the call */
|
||||||
_event_mixer_set("gsmhandset.state");
|
_event_mixer_set(plugin, "gsmhandset.state");
|
||||||
/* enable echo cancellation */
|
/* enable echo cancellation */
|
||||||
plugin->helper->queue(plugin->helper->phone,
|
plugin->helper->queue(plugin->helper->phone,
|
||||||
"AT%N0187");
|
"AT%N0187");
|
||||||
break;
|
break;
|
||||||
case PHONE_EVENT_CALL_INCOMING:
|
case PHONE_EVENT_CALL_INCOMING:
|
||||||
/* let us hear the ringtone */
|
/* let us hear the ringtone */
|
||||||
_event_mixer_set("stereoout.state");
|
_event_mixer_set(plugin, "stereoout.state");
|
||||||
break;
|
break;
|
||||||
case PHONE_EVENT_CALL_OUTGOING:
|
case PHONE_EVENT_CALL_OUTGOING:
|
||||||
/* let us hear the connection */
|
/* let us hear the connection */
|
||||||
_event_mixer_set("gsmhandset.state");
|
_event_mixer_set(plugin, "gsmhandset.state");
|
||||||
break;
|
break;
|
||||||
case PHONE_EVENT_CALL_TERMINATED:
|
case PHONE_EVENT_CALL_TERMINATED:
|
||||||
/* restore regular audio */
|
/* restore regular audio */
|
||||||
_event_mixer_set("stereoout.state");
|
_event_mixer_set(plugin, "stereoout.state");
|
||||||
break;
|
break;
|
||||||
case PHONE_EVENT_NOTIFICATION_OFF:
|
case PHONE_EVENT_NOTIFICATION_OFF:
|
||||||
/* FIXME implement */
|
/* FIXME implement */
|
||||||
@ -97,11 +97,11 @@ static int _openmoko_event(PhonePlugin * plugin, PhoneEvent event, ...)
|
|||||||
break;
|
break;
|
||||||
case PHONE_EVENT_SPEAKER_ON:
|
case PHONE_EVENT_SPEAKER_ON:
|
||||||
/* XXX assumes there's an ongoing call */
|
/* XXX assumes there's an ongoing call */
|
||||||
_event_mixer_set("gsmspeakerout.state");
|
_event_mixer_set(plugin, "gsmspeakerout.state");
|
||||||
break;
|
break;
|
||||||
case PHONE_EVENT_SPEAKER_OFF:
|
case PHONE_EVENT_SPEAKER_OFF:
|
||||||
/* XXX assumes there's an ongoing call */
|
/* XXX assumes there's an ongoing call */
|
||||||
_event_mixer_set("gsmhandset.state");
|
_event_mixer_set(plugin, "gsmhandset.state");
|
||||||
break;
|
break;
|
||||||
case PHONE_EVENT_VIBRATOR_OFF:
|
case PHONE_EVENT_VIBRATOR_OFF:
|
||||||
_event_vibrator(plugin, FALSE);
|
_event_vibrator(plugin, FALSE);
|
||||||
@ -120,26 +120,29 @@ static int _openmoko_event(PhonePlugin * plugin, PhoneEvent event, ...)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _event_mixer_set(char const * filename)
|
static int _event_mixer_set(PhonePlugin * plugin, char const * filename)
|
||||||
{
|
{
|
||||||
|
int ret = 0;
|
||||||
char const scenarios[] = DATADIR "/openmoko/scenarios";
|
char const scenarios[] = DATADIR "/openmoko/scenarios";
|
||||||
char * pathname;
|
char * pathname;
|
||||||
size_t len;
|
size_t len;
|
||||||
char * alsactl[] = { SBINDIR "/alsactl", "alsactl", "-f", NULL,
|
char * alsactl[] = { SBINDIR "/alsactl", "alsactl", "-f", NULL,
|
||||||
"restore", NULL };
|
"restore", NULL };
|
||||||
|
GError * error = NULL;
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr, "DEBUG: %s(\"%s\")\n", __func__, filename);
|
fprintf(stderr, "DEBUG: %s(\"%s\")\n", __func__, filename);
|
||||||
#endif
|
#endif
|
||||||
len = sizeof(scenarios) + 1 + strlen(filename);
|
len = sizeof(scenarios) + 1 + strlen(filename);
|
||||||
if((pathname = malloc(len)) == NULL)
|
if((pathname = malloc(len)) == NULL)
|
||||||
return error_set_code(1, "%s", strerror(errno));
|
return plugin->helper->error(NULL, strerror(errno), 1);
|
||||||
snprintf(pathname, len, "%s/%s", scenarios, filename);
|
snprintf(pathname, len, "%s/%s", scenarios, filename);
|
||||||
alsactl[3] = pathname;
|
alsactl[3] = pathname;
|
||||||
g_spawn_async(NULL, alsactl, NULL, G_SPAWN_FILE_AND_ARGV_ZERO,
|
if(g_spawn_async(NULL, alsactl, NULL, G_SPAWN_FILE_AND_ARGV_ZERO,
|
||||||
NULL, NULL, NULL, NULL);
|
NULL, NULL, NULL, &error) == FALSE)
|
||||||
|
ret = plugin->helper->error(NULL, error->message, 1);
|
||||||
free(pathname);
|
free(pathname);
|
||||||
return 0;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int _event_vibrator(PhonePlugin * plugin, gboolean vibrate)
|
static int _event_vibrator(PhonePlugin * plugin, gboolean vibrate)
|
||||||
|
Loading…
Reference in New Issue
Block a user