| 372 | } |
| 373 | |
| 374 | void SamplingBar::update_sample_rate_selector() |
| 375 | { |
| 376 | GVariant *gvar_dict, *gvar_list; |
| 377 | const uint64_t *elements = NULL; |
| 378 | gsize num_elements; |
| 379 | |
| 380 | dsv_info("Update rate list."); |
| 381 | |
| 382 | if (_updating_sample_rate) |
| 383 | { |
| 384 | dsv_err("Error! The rate list is updating."); |
| 385 | return; |
| 386 | } |
| 387 | |
| 388 | disconnect(&_sample_rate, SIGNAL(currentIndexChanged(int)), |
| 389 | this, SLOT(on_samplerate_sel(int))); |
| 390 | |
| 391 | if (_device_agent->have_instance() == false) |
| 392 | { |
| 393 | dsv_info("SamplingBar::update_sample_rate_selector, have no device."); |
| 394 | return; |
| 395 | } |
| 396 | |
| 397 | _updating_sample_rate = true; |
| 398 | |
| 399 | gvar_dict = _device_agent->get_config_list(NULL, SR_CONF_SAMPLERATE); |
| 400 | if (gvar_dict == NULL) |
| 401 | { |
| 402 | _sample_rate.clear(); |
| 403 | _sample_rate.show(); |
| 404 | _updating_sample_rate = false; |
| 405 | return; |
| 406 | } |
| 407 | |
| 408 | if ((gvar_list = g_variant_lookup_value(gvar_dict, |
| 409 | "samplerates", G_VARIANT_TYPE("at")))) |
| 410 | { |
| 411 | elements = (const uint64_t *)g_variant_get_fixed_array( |
| 412 | gvar_list, &num_elements, sizeof(uint64_t)); |
| 413 | _sample_rate.clear(); |
| 414 | |
| 415 | for (unsigned int i = 0; i < num_elements; i++) |
| 416 | { |
| 417 | char *const s = sr_samplerate_string(elements[i]); |
| 418 | _sample_rate.addItem(QString(s), |
| 419 | QVariant::fromValue(elements[i])); |
| 420 | g_free(s); |
| 421 | } |
| 422 | |
| 423 | _sample_rate.show(); |
| 424 | g_variant_unref(gvar_list); |
| 425 | } |
| 426 | |
| 427 | _sample_rate.setMinimumWidth(_sample_rate.sizeHint().width() + 15); |
| 428 | _sample_rate.view()->setMinimumWidth(_sample_rate.sizeHint().width() + 30); |
| 429 | |
| 430 | _updating_sample_rate = false; |
| 431 | g_variant_unref(gvar_dict); |
nothing calls this directly
no test coverage detected