/**
 * \brief Method called when the frame is displayed.
 */
void ptb::frame_profiles::on_focus()
{
  frame::on_focus();

  const bear::gui::radio_button* selection(m_profiles->get_selection());

  if ( selection != NULL )
    {
      std::string profile(selection->get_text());
      if ( ( profile != gettext("Available") ) )
        {
          if ( m_msg_result & message_box::s_ok )
            {
              const bear::engine::game& g( bear::engine::game::get_instance() );

              boost::filesystem::path path
                ( g.get_game_filesystem().get_custom_config_file_name
                  ( PTB_PROFILES_FOLDER ) + profile );

              if ( boost::filesystem::exists(path) )
                {
                  boost::filesystem::remove_all( path );
                  update_controls();
                }
            }
          else
            m_msg_result = 0;
        }
    }

  update_controls();
} // frame_profiles::on_focus()
示例#2
0
/**
 * \brief Answer to a click on a mark menu entry.
 * \param event This event occured.
 */
void bf::mark_list_frame::on_new_mark(wxCommandEvent& WXUNUSED(event))
{
  if ( m_model_frame != NULL )
    if ( m_model_frame->get_model().has_active_action() )
      {
        const action& a = m_model_frame->get_model().get_active_action();
        mark_properties_frame dlg(this, &a, *m_workspace);

        if ( dlg.ShowModal() == wxID_OK )
          {
            mark* m = new mark();

            m->set_label(dlg.get_mark_name());
            m->set_animation(dlg.get_mark_animation());
            m->apply_angle_to_animation(dlg.apply_angle_to_animation());
            m->pause_animation_when_hidden(dlg.pause_animation_when_hidden());
            m->reset_animation_with_action(dlg.reset_animation_with_action());

            m_model_frame->do_action
              ( new action_add_mark(a.get_name(), m) );
            fill();

            select_mark(dlg.get_mark_name());
            update_controls();
          }
      }
} // mark_list_frame::on_new_mark()
示例#3
0
void app_render2(long ticj, int w, int h)
{
	glViewport(0, 0, w, h);
	glClearColor(0.3, 0.3, 0.3, 1.0);
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
//	glOrtho(-1.25, 1.25, -1.25, 1.25, 1., 20.);
	glFrustum(frc.l, frc.r, frc.b, frc.t, 1, 40);

	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
	glTranslatef(tran.x, tran.y, tran.z);
	glRotatef(rot.x, 1, 0, 0);
	glRotatef(rot.y, 0, 1, 0);
	glRotatef(rot.z, 0, 0, 1);
//	gluLookAt(0., 0., 10., 0., 0., 0., 0., 1., 0.);

	glColor3f(1.0, 1.0, 1.0);

	glBegin(GL_QUADS);
	glTexCoord2f(0.0, 0.0);
	glVertex3f(-1.0,  1.0, 0.0);
	glTexCoord2f(1.0, 0.0);
	glVertex3f(1.0,  1.0, 0.0);
	glTexCoord2f(1.0, 1.0);
	glVertex3f(1.0, -1.0, 0.0);
	glTexCoord2f(0.0, 1.0);
	glVertex3f(-1.0, -1.0, 0.0);
	glEnd();

	update_controls();
}
示例#4
0
/**
 * \brief Answer to a click on the button "delete".
 * \param event This event occured.
 */
void bf::mark_list_frame::on_delete(wxCommandEvent& WXUNUSED(event))
{
  if ( m_model_frame != NULL )
    if ( m_model_frame->get_model().has_active_action() )
      {
        int index = m_mark_list->GetSelection();
        if ( index != wxNOT_FOUND )
          {
            action& a = m_model_frame->get_model().get_active_action();
            std::string selection =
              wx_to_std_string(m_mark_list->GetStringSelection());
            m_model_frame->clear_selection();

            m_model_frame->do_action
              ( new action_remove_mark
                ( m_model_frame->get_model().get_active_action().get_name(),
                  a.get_mark(selection)));

            fill();

            if ( a.mark_begin() != a.mark_end() )
              {
          if ( index < (int)m_mark_list->GetCount() )
            m_mark_list->Select(index);
          else
            m_mark_list->Select(index-1);

          select_mark
            (wx_to_std_string(m_mark_list->GetStringSelection()));
              }
          }
        update_controls();
      }
} // mark_list_frame::on_delete()
示例#5
0
BOOL Cdlg_profiles::OnInitDialog()
{
	ETSLayoutDialog::OnInitDialog();
	update_controls();
	CreateRoot(VERTICAL)
		<< item(IDC_LIST)
		<< (pane(HORIZONTAL, ABSOLUTE_VERT)
			<< itemGrowing(HORIZONTAL)
			<< item(IDC_ACTIVATE, NORESIZE)
			<< item(IDC_INSERT, NORESIZE)
			<< item(IDC_EDIT, NORESIZE)
			<< item(IDC_DELETE, NORESIZE)
			<< item(IDOK, NORESIZE)
			<< item(IDCANCEL, NORESIZE)
			)
		;
	UpdateLayout();

	m_list.InsertColumn(0, "Name");
	m_list.InsertColumn(1, "Seeding Ratio", LVCFMT_RIGHT);
	m_list.InsertColumn(2, "Upload Rate", LVCFMT_RIGHT);
	m_list.InsertColumn(3, "Upload Slots", LVCFMT_RIGHT);
	m_list.InsertColumn(4, "Peer Limit", LVCFMT_RIGHT);
	m_list.InsertColumn(5, "Torrent Limit", LVCFMT_RIGHT);
	m_list.InsertColumn(6, "");
	for (t_entries::const_iterator i = m_entries.begin(); i != m_entries.end(); i++)
		m_list.InsertItemData(i->first);
	m_list.auto_size();
	return true;
}
示例#6
0
/**
 * \brief Constructor.
 * \param parent The frame owning this one.
 * \param env The workspace environment to use.
 */
bf::mark_list_frame::mark_list_frame
( wxWindow* parent, workspace_environment* env )
  : wxPanel( parent ), m_model_frame(NULL), m_mark_list(NULL),
    m_new_mark_button(NULL), m_delete_mark_button(NULL),
    m_properties_mark_button(NULL), m_workspace(env)
{
  create_controls();
  update_controls();
} // mark_list_frame::mark_list_frame()
示例#7
0
/**
 * \brief Set the model on which we work.
 * \param f The model frame in which we take the actions.
 */
void bf::mark_list_frame::set_model_frame( model_frame* f )
{
  m_model_frame = f;
  if ( m_model_frame )
    m_workspace = &m_model_frame->get_workspace();

  fill();
  update_controls();
} // mark_list_frame::set_model_frame()
示例#8
0
void app_render(long ticj, int w, int h)
{
	GLfloat i;
	//glClear(GL_COLOR_BUFFER_BIT);

	glClearColor(0.0, 0.0, 0.0, 1.0);
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	//==
	glViewport(0, 0, w, h);
	glClearColor(0.3, 0.3, 0.3, 1.0);
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
//	glOrtho(-1.25, 1.25, -1.25, 1.25, 1., 20.);
	glFrustum(frc.l, frc.r, frc.b, frc.t, 1, 40);

	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
	glTranslatef(tran.x, tran.y, tran.z);
	glRotatef(rot.x, 1, 0, 0);
	glRotatef(rot.y, 0, 1, 0);
	glRotatef(rot.z, 0, 0, 1);
	//==

	// Draw a white grid "floor" for the tetrahedron to sit on.
	glColor3f(1.0, 1.0, 1.0);
	glBegin(GL_LINES);
	for (i = -2.5; i <= 2.5; i += 0.25) {
		glVertex3f(i, 0, 2.5);
		glVertex3f(i, 0, -2.5);
		glVertex3f(2.5, 0, i);
		glVertex3f(-2.5, 0, i);
	}
	glEnd();

	// Draw the tetrahedron.  It is a four sided figure, so when defining it
	// with a triangle strip we have to repeat the last two vertices.
	glBegin(GL_TRIANGLE_STRIP);
	glColor3f(1, 1, 1);
	glVertex3f(0, 2, 0);
	glColor3f(1, 0, 0);
	glVertex3f(-1, 0, 1);
	glColor3f(0, 1, 0);
	glVertex3f(1, 0, 1);
	glColor3f(0, 0, 1);
	glVertex3f(0, 0, -1.4f);
	glColor3f(1, 1, 1);
	glVertex3f(0, 2, 0);
	glColor3f(1, 0, 0);
	glVertex3f(-1, 0, 1);
	glEnd();

	update_controls();
}
示例#9
0
文件: movie.cpp 项目: bentley/lsnes
void movie_logic::new_frame_starting(bool dont_poll) throw(std::bad_alloc, std::runtime_error)
{
	mov->next_frame();
	portctrl::frame c = update_controls(false);
	if(!mov->readonly_mode()) {
		mov->set_controls(c);
		if(!dont_poll)
			mov->set_all_DRDY();
	} else if(!dont_poll)
		mov->set_all_DRDY();
}
/**
 * \brief Choose the next mini-game.
 */
void ptb::frame_play_story::on_next()
{
  if ( m_levels.size() > 1 )
    {
      ++m_index;

      if ( m_index == m_levels.size() )
        m_index = 0;

      update_controls();
    }
} // frame_play_story::on_next()
/**
 * \brief Choose the previous mini-game.
 */
void ptb::frame_play_story::on_previous()
{
  if ( m_levels.size() > 1 )
    {
      if ( m_index == 0 )
        m_index = m_levels.size() - 1;
      else
        --m_index;

      update_controls();
    }
} // frame_play_story::on_previous()
示例#12
0
/**
 * Update the application title when switching tabs, closing or opening
 * or opening new tabs or opening new files.
 */
void update_app_title(MainWindow *main_window, Documentable *document)
{
  gphpedit_debug(DEBUG_MAIN_WINDOW);
  gchar *title = NULL;
  if (document) g_object_get(document, "title", &title, NULL);
  update_status_combobox(main_window, document);
  update_zoom_level(main_window, document);
  update_controls(main_window, document);
  //If there is no file opened set the name as gPHPEdit
  if (!title) title = g_strdup(_("gPHPEdit"));
  gtk_window_set_title(GTK_WINDOW(main_window->window), title);
  g_free(title);
}
示例#13
0
文件: movie.cpp 项目: bentley/lsnes
short movie_logic::input_poll(unsigned port, unsigned dev, unsigned id) throw(std::bad_alloc, std::runtime_error)
{
	if(!mov)
		return 0;
	//If this is for something else than 0-0-x, drop out of poll advance if any.
	bool force = false;
	if(port || dev) force = notify_user_poll();
	if(!mov->get_DRDY(port, dev, id) || force) {
		mov->set_controls(update_controls(true, force));
		mov->set_all_DRDY();
	}
	return mov->next_input(port, dev, id);
}
/**
 * \brief Constructor.
 * \param owning_layer The layer onwing the window.
 */
ptb::frame_play_story::frame_play_story
( windows_layer* owning_layer )
  : frame(owning_layer, gettext("Level selection")), m_index(0)
{
  load_and_sort_level_names();
  create_controls();

  for ( unsigned int i=0; i != m_levels.size(); ++i)
    CLAW_PRECOND( m_levels[i].is_valid() );

  m_index = m_levels.size() - 1;

  update_controls();
} // frame_play_story::frame_play_story()
示例#15
0
/**
 * \brief Create the static text components.
 */
void ptb::frame_profiles::create_controls()
{
  bear::visual::font font = get_font();

  m_profiles = create_profiles_radio_buttons( font );
  bear::gui::visual_component* ok_button = create_ok_button( font );
  bear::gui::visual_component* cancel_button = create_back_button( font );
  bear::gui::visual_component* remove_button = create_remove_button( font );

  ok_button->set_top( m_profiles->bottom() - get_margin() );

  cancel_button->set_top( ok_button->top() );
  cancel_button->set_left( ok_button->right() + get_margin() );

  remove_button->set_top( ok_button->top() );
  remove_button->set_left( cancel_button->right() + get_margin() );

  ok_button->set_focus();
  update_controls();

  fit( get_margin() );
} // frame_profiles::create_controls()
示例#16
0
void Cdlg_profiles::OnItemchangedList(NMHDR* pNMHDR, LRESULT* pResult)
{
	update_controls();
	*pResult = 0;
}
示例#17
0
static gboolean
noise_synth_dialog(NoiseSynthArgs *args,
                 GwyDimensionArgs *dimsargs,
                 GwyContainer *data,
                 GwyDataField *dfield_template,
                 gint id)
{
    GtkWidget *dialog, *table, *vbox, *hbox, *notebook, *label;
    NoiseSynthControls controls;
    GwyDataField *dfield;
    GwyPixmapLayer *layer;
    gboolean finished;
    gint response;
    gint row;

    gwy_clear(&controls, 1);
    controls.in_init = TRUE;
    controls.args = args;
    dialog = gtk_dialog_new_with_buttons(_("Random Noise"),
                                         NULL, 0,
                                         _("_Reset"), RESPONSE_RESET,
                                         GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
                                         GTK_STOCK_OK, GTK_RESPONSE_OK,
                                         NULL);
    gtk_dialog_set_default_response(GTK_DIALOG(dialog), GTK_RESPONSE_OK);
    gwy_help_add_to_proc_dialog(GTK_DIALOG(dialog), GWY_HELP_DEFAULT);
    controls.dialog = dialog;

    hbox = gtk_hbox_new(FALSE, 2);
    gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), hbox,
                       FALSE, FALSE, 4);

    vbox = gtk_vbox_new(FALSE, 4);
    gtk_box_pack_start(GTK_BOX(hbox), vbox, FALSE, FALSE, 4);

    controls.mydata = gwy_container_new();
    dfield = gwy_data_field_new(PREVIEW_SIZE, PREVIEW_SIZE,
                                dimsargs->measure*PREVIEW_SIZE,
                                dimsargs->measure*PREVIEW_SIZE,
                                TRUE);
    gwy_container_set_object_by_name(controls.mydata, "/0/data", dfield);
    controls.noise = gwy_data_field_new_alike(dfield, FALSE);
    if (dfield_template) {
        gwy_app_sync_data_items(data, controls.mydata, id, 0, FALSE,
                                GWY_DATA_ITEM_PALETTE,
                                0);
        controls.surface = gwy_synth_surface_for_preview(dfield_template,
                                                         PREVIEW_SIZE);
        controls.zscale = gwy_data_field_get_rms(dfield_template);
    }
    controls.view = gwy_data_view_new(controls.mydata);
    layer = gwy_layer_basic_new();
    g_object_set(layer,
                 "data-key", "/0/data",
                 "gradient-key", "/0/base/palette",
                 NULL);
    gwy_data_view_set_base_layer(GWY_DATA_VIEW(controls.view), layer);

    gtk_box_pack_start(GTK_BOX(vbox), controls.view, FALSE, FALSE, 0);

    gtk_box_pack_start(GTK_BOX(vbox),
                       gwy_synth_instant_updates_new(&controls,
                                                     &controls.update_now,
                                                     &controls.update,
                                                     &args->update),
                       FALSE, FALSE, 0);
    g_signal_connect_swapped(controls.update_now, "clicked",
                             G_CALLBACK(preview), &controls);

    gtk_box_pack_start(GTK_BOX(vbox),
                       gwy_synth_random_seed_new(&controls,
                                                 &controls.seed, &args->seed),
                       FALSE, FALSE, 0);

    controls.randomize = gwy_synth_randomize_new(&args->randomize);
    gtk_box_pack_start(GTK_BOX(vbox), controls.randomize, FALSE, FALSE, 0);

    notebook = gtk_notebook_new();
    gtk_box_pack_start(GTK_BOX(hbox), notebook, TRUE, TRUE, 4);
    g_signal_connect_swapped(notebook, "switch-page",
                             G_CALLBACK(page_switched), &controls);

    controls.dims = gwy_dimensions_new(dimsargs, dfield_template);
    gtk_notebook_append_page(GTK_NOTEBOOK(notebook),
                             gwy_dimensions_get_widget(controls.dims),
                             gtk_label_new(_("Dimensions")));
    if (controls.dims->add)
        g_signal_connect_swapped(controls.dims->add, "toggled",
                                 G_CALLBACK(noise_synth_invalidate), &controls);

    table = gtk_table_new(6 + (dfield_template ? 1 : 0), 4, FALSE);
    controls.table = GTK_TABLE(table);
    gtk_table_set_row_spacings(controls.table, 2);
    gtk_table_set_col_spacings(controls.table, 6);
    gtk_container_set_border_width(GTK_CONTAINER(table), 4);
    gtk_notebook_append_page(GTK_NOTEBOOK(notebook), table,
                             gtk_label_new(_("Generator")));
    row = 0;

    controls.distribution = distribution_selector_new(&controls);
    gwy_table_attach_hscale(table, row, _("_Distribution:"), NULL,
                            GTK_OBJECT(controls.distribution),
                            GWY_HSCALE_WIDGET);
    row++;

    label = gtk_label_new(_("Direction:"));
    gtk_misc_set_alignment(GTK_MISC(label), 0.0, 0.5);
    gtk_table_attach(GTK_TABLE(table), label, 0, 1, row, row+1,
                     GTK_FILL, 0, 0, 0);
    row++;

    controls.direction
        = gwy_radio_buttons_createl(G_CALLBACK(direction_type_changed),
                                    &controls, args->direction,
                                    _("S_ymmetrical"), NOISE_DIRECTION_BOTH,
                                    _("One-sided _positive"), NOISE_DIRECTION_UP,
                                    _("One-sided _negative"), NOISE_DIRECTION_DOWN,
                                    NULL);
    row = gwy_radio_buttons_attach_to_table(controls.direction,
                                            GTK_TABLE(table), 3, row);
    gtk_table_set_row_spacing(GTK_TABLE(table), row-1, 8);

    row = gwy_synth_attach_height(&controls, row,
                                  &controls.sigma, &args->sigma,
                                  _("_RMS:"), NULL, &controls.sigma_units);

    if (dfield_template) {
        controls.sigma_init
            = gtk_button_new_with_mnemonic(_("_Like Current Channel"));
        g_signal_connect_swapped(controls.sigma_init, "clicked",
                                 G_CALLBACK(sigma_init_clicked), &controls);
        gtk_table_attach(GTK_TABLE(table), controls.sigma_init,
                         1, 3, row, row+1, GTK_FILL, 0, 0, 0);
        row++;
    }

    gtk_widget_show_all(dialog);
    controls.in_init = FALSE;
    /* Must be done when widgets are shown, see GtkNotebook docs */
    gtk_notebook_set_current_page(GTK_NOTEBOOK(notebook), args->active_page);
    update_values(&controls);
    noise_synth_invalidate(&controls);

    finished = FALSE;
    while (!finished) {
        response = gtk_dialog_run(GTK_DIALOG(dialog));
        switch (response) {
            case GTK_RESPONSE_CANCEL:
            case GTK_RESPONSE_DELETE_EVENT:
            case GTK_RESPONSE_OK:
            gtk_widget_destroy(dialog);
            case GTK_RESPONSE_NONE:
            finished = TRUE;
            break;

            case RESPONSE_RESET:
            {
                gboolean temp = args->update;
                gint temp2 = args->active_page;
                *args = noise_synth_defaults;
                args->active_page = temp2;
                args->update = temp;
            }
            controls.in_init = TRUE;
            update_controls(&controls, args);
            controls.in_init = FALSE;
            if (args->update)
                preview(&controls);
            break;

            default:
            g_assert_not_reached();
            break;
        }
    }

    if (controls.sid) {
        g_source_remove(controls.sid);
        controls.sid = 0;
    }
    g_object_unref(controls.mydata);
    gwy_object_unref(controls.surface);
    gwy_object_unref(controls.noise);
    gwy_dimensions_free(controls.dims);

    return response == GTK_RESPONSE_OK;
}
/**
 * \brief Method called when the frame is displayed.
 */
void ptb::frame_play_story::on_focus()
{
  frame::on_focus();

  update_controls();
} // frame_play_story::on_focus()
static void
device_test (GtkWidget *w, alsa_driver *d)
{
    guint chmin, chmax, i;
    gint err;
    gchar *new_device;

    d->can8 = FALSE;
    d->can16 = FALSE;
    d->canmono = FALSE;
    d->canstereo = FALSE;
    d->signedness8 = FALSE;
    d->signedness16 = FALSE;

    new_device = gtk_combo_box_get_active_text(GTK_COMBO_BOX(d->alsa_device));
    if(g_ascii_strcasecmp(d->device, new_device)) {
	g_free(d->device);
	d->device = g_strdup(new_device);
	gui_hlp_combo_box_prepend_text_or_set_active(GTK_COMBO_BOX(d->alsa_device), d->device, FALSE);
    }

    for(i = 0; i < NUM_FORMATS; i++){
	d->devcap[i].minfreq = 8000;
	d->devcap[i].maxfreq = 44100;
	d->devcap[i].minbufsize = 256;
    }
    d->devcap[MONO8].maxbufsize = 65536;
    d->devcap[STEREO8].maxbufsize = 32768;
    d->devcap[MONO16].maxbufsize = 32768;
    d->devcap[STEREO16].maxbufsize = 16384;

    if(pcm_open_and_load_hwparams(d) < 0)
	return;

    if(!snd_pcm_hw_params_test_format(d->soundfd, d->hwparams, SND_PCM_FORMAT_U8)) {
	d->can8 = TRUE;
    }
    if(!snd_pcm_hw_params_test_format(d->soundfd, d->hwparams, SND_PCM_FORMAT_S8)) {
	d->can8 = TRUE;
	d->signedness8 = TRUE;
    }
    if(!snd_pcm_hw_params_test_format(d->soundfd, d->hwparams, SND_PCM_FORMAT_U16)) {
	d->can16 = TRUE;
    }
    if(!snd_pcm_hw_params_test_format(d->soundfd, d->hwparams, SND_PCM_FORMAT_S16)) {
	d->can16 = TRUE;
	d->signedness16 = TRUE;
    }

    if((err = snd_pcm_hw_params_get_channels_min(d->hwparams, &chmin)) < 0) {
	alsa_error(N_("Unable to get minimal channels number"), err);
	snd_pcm_close(d->soundfd);
	return;
    }
    if((err = snd_pcm_hw_params_get_channels_max(d->hwparams, &chmax)) < 0) {
	alsa_error(N_("Unable to get maximal channels number"), err);
	snd_pcm_close(d->soundfd);
	return;
    }
    if(chmin > 2) {
	error_error("Both mono and stereo are not supported by ALSA device!!!");
	snd_pcm_close(d->soundfd);
	return;
    }
    if(chmin == 1)
	d->canmono = TRUE;
    if(chmax >= 2)
	d->canstereo = TRUE;

    if(d->can8) {
	if((err = snd_pcm_hw_params_set_format(d->soundfd, d->hwparams,
					d->signedness8 ? SND_PCM_FORMAT_S8 : SND_PCM_FORMAT_U8)) < 0) {
	    alsa_error(N_("Unable to set audio format"), err);
	    snd_pcm_close(d->soundfd);
	    return;
	}
	if(d->canmono) {
	    if(set_rates(d, 1, MONO8) < 0) {
		snd_pcm_close(d->soundfd);
		return;
	    }
	}

	if(d->canstereo) {
	    snd_pcm_close(d->soundfd);
	    if(pcm_open_and_load_hwparams(d) < 0)
		return;
	    if(set_rates(d, 2, STEREO8) < 0) {
		snd_pcm_close(d->soundfd);
		return;
	    }
	}
    }

    if(d->can16) {
	snd_pcm_close(d->soundfd);
	if(pcm_open_and_load_hwparams(d) < 0)
	    return;
	if((err = snd_pcm_hw_params_set_format(d->soundfd, d->hwparams,
					d->signedness16 ? SND_PCM_FORMAT_S16 : SND_PCM_FORMAT_U16)) < 0) {
	    alsa_error(N_("Unable to set audio format"), err);
	    snd_pcm_close(d->soundfd);
	    return;
	}
	if(d->canmono) {
	    if(set_rates(d, 1, MONO16) < 0) {
		snd_pcm_close(d->soundfd);
		return;
	    }
	}
	if(d->canstereo) {
	    snd_pcm_close(d->soundfd);
	    if(pcm_open_and_load_hwparams(d) < 0)
		return;
	    if(set_rates(d, 2, STEREO16) < 0) {
		snd_pcm_close(d->soundfd);
		return;
	    }
	}
    }

    snd_pcm_close(d->soundfd);
    update_controls(d);
}