Esempio n. 1
0
static gboolean
icon_clicked(GtkWidget *widget, GdkEventButton *event, volume_priv *c)
{
    int volume;

    ENTER;
    if (event->type == GDK_BUTTON_PRESS && event->button == 1) {
        if (c->slider_window == NULL) {
            c->slider_window = volume_create_slider(c);
            gtk_widget_show_all(c->slider_window);
            gtk_widget_set_tooltip_markup(((plugin_instance *)c)->pwid, NULL);
        } else {
            gtk_widget_destroy(c->slider_window);
            c->slider_window = NULL;
            if (c->leave_id) {
                g_source_remove(c->leave_id);
                c->leave_id = 0;
            }
        }
        RET(FALSE);
    }
    if (!(event->type == GDK_BUTTON_PRESS && event->button == 2))
        RET(FALSE);
    
    if (c->muted) {
        volume = c->muted_vol;
    } else {
        c->muted_vol = c->vol;
        volume = 0;
    }
    c->muted = !c->muted;
    oss_set_volume(c, volume);
    volume_update_gui(c);
    RET(FALSE);
}
Esempio n. 2
0
static void
slider_changed(GtkRange *range, volume_priv *c)
{
    int volume = (int) gtk_range_get_value(range);
    ENTER;
    DBG("value=%d\n", volume);
    oss_set_volume(c, volume);
    volume_update_gui(c);
    RET();
}
Esempio n. 3
0
static gboolean
icon_scrolled(GtkWidget *widget, GdkEventScroll *event, volume_priv *c)
{
    int volume;
    
    ENTER;
    volume = (c->muted) ? c->muted_vol : ((meter_priv *) c)->level;
    volume += 2 * ((event->direction == GDK_SCROLL_UP
            || event->direction == GDK_SCROLL_LEFT) ? 1 : -1);
    if (volume > 100)
        volume = 100;
    if (volume < 0)
        volume = 0;
    
    if (c->muted) 
        c->muted_vol = volume;
    else {
        oss_set_volume(c, volume);
        volume_update_gui(c);
    }
    RET(TRUE);
}
Esempio n. 4
0
int oss_open_audio(int aud_format, int rate, int channels)
{
    AUDDBG("Opening audio.\n");

    int format;
    int vol_left, vol_right;
    audio_buf_info buf_info;

    CHECK_NOISY(oss_data->fd = open_device);

    format = oss_convert_aud_format(aud_format);

    if (!set_format(format, rate, channels))
        goto FAILED;

    CHECK_NOISY(ioctl, oss_data->fd, SNDCTL_DSP_GETOSPACE, &buf_info);

    AUDDBG("Buffer information, fragstotal: %d, fragsize: %d, bytes: %d.\n",
        buf_info.fragstotal,
        buf_info.fragsize,
        buf_info.bytes);

    oss_time = 0;
    oss_paused = FALSE;
    oss_paused_time = 0;
    oss_delay = oss_bytes_to_frames(buf_info.fragstotal * buf_info.fragsize) * 1000 / oss_data->rate;
    oss_ioctl_vol = TRUE;

    AUDDBG("Internal OSS buffer size: %dms.\n", oss_delay);

    if (aud_get_bool("oss4", "save_volume"))
    {
        vol_right = (aud_get_int("oss4", "volume") & 0xFF00) >> 8;
        vol_left  = (aud_get_int("oss4", "volume") & 0x00FF);
        oss_set_volume(vol_left, vol_right);
    }
Esempio n. 5
0
void oss_set_mute(gboolean mute)
{
	assert(m_mixer_fd != -1);

	gboolean mute_found = FALSE;
	int parent = m_ext.parent;
	int control = m_ext.ctrl;

	// Check for mute in this group
	m_ext.ctrl = 0;
	while(ioctl(m_mixer_fd, SNDCTL_MIX_EXTINFO, &m_ext) >= 0)
	{
		if(m_ext.parent == parent && m_ext.type == MIXT_MUTE)
		{
			oss_mixer_value vr;
			vr.dev = m_ext.dev;
			vr.ctrl = m_ext.ctrl;
			vr.timestamp = m_ext.timestamp;
			vr.value = mute ? 1 : 0;
			ioctl(m_mixer_fd, SNDCTL_MIX_WRITE, &vr);
			mute_found = TRUE;
			break;
		}
		m_ext.ctrl++;
	}

	// Restore to previous control
	m_ext.ctrl = control;
	ioctl(m_mixer_fd, SNDCTL_MIX_EXTINFO, &m_ext);

	// If no mute control was found, revert to setting the volume to zero
	if(!mute_found && mute)
	{
		oss_set_volume(0);
	}
}