Esempio n. 1
0
void ZaMp3::mute()
{
	audiomixer_set_output_level(AUDIOMIXER_OUTPUT_SPEAKER, volume / 2.0);
	if (rc == BPS_SUCCESS) {
		fprintf(stderr, "Successfully decreased the volume.\n");
	} else {
		fprintf(stderr, "Failed to decrease the volume.\n");
	}

}
Esempio n. 2
0
static void handle_dialog_response_events(bps_event_t *event) {
    if (NULL == event) {
        return;
    }

    if (NULL == dialog_event_get_selected_context(event)) {
        return ;
    }

    float volume;
    int rc;

    if (0 == strcmp("query", dialog_event_get_selected_context(event))) {
        rc = audiomixer_get_output_level(AUDIOMIXER_OUTPUT_SPEAKER, &volume);
        if (BPS_SUCCESS == rc) {
            snprintf(msg, MSG_SIZE, "Successfully queried the output level.\ncurrent volume is %f\n", volume);
            show_dialog_message(msg);
        } else {
            show_dialog_message("Failed to query the output level.\n");
        }
    } else if (0 == strcmp("half", dialog_event_get_selected_context(event))) {
        rc = audiomixer_get_output_level(AUDIOMIXER_OUTPUT_SPEAKER, &volume);
        if (BPS_SUCCESS != rc) {
            show_dialog_message("Failed to query the output level.\n");
            return;
        }

        volume /= 2.0;

        rc = audiomixer_set_output_level(AUDIOMIXER_OUTPUT_SPEAKER, volume);
        if (BPS_SUCCESS == rc) {
            show_dialog_message("Successfully decreased the volume by half.\n");
        } else {
            show_dialog_message("Failed to decrease the volume.\n");
        }
    } else if (0 == strcmp("double", dialog_event_get_selected_context(event))) {
        rc = audiomixer_get_output_level(AUDIOMIXER_OUTPUT_SPEAKER, &volume);
        if (BPS_SUCCESS != rc) {
            show_dialog_message("Failed to query the output level.\n");
            return;
        }
        
        if (volume == 0.0) {
            volume = 2.0;
        } else {
            volume *= 2.0;
        }

        rc = audiomixer_set_output_level(AUDIOMIXER_OUTPUT_SPEAKER, volume);
        if (BPS_SUCCESS == rc) {
            show_dialog_message("Successfully doubled the volume.\n");
        } else {
            show_dialog_message("Failed to double the volume.\n");
        }
    } else if (0 == strcmp("toggle", dialog_event_get_selected_context(event))) {
        rc = audiomixer_toggle_output_mute(AUDIOMIXER_OUTPUT_SPEAKER);
        if (BPS_SUCCESS == rc) {
            show_dialog_message("Successfully toggled the mute setting.\n");
        } else {
            show_dialog_message("Failed to toggle the mute setting.\n");
        }
    }
}