pa_log_error("SBC decoding error (%li)", (long) decoded);
pa_memblock_release(memchunk.memblock);
pa_memblock_unref(memchunk.memblock);
- return -1;
+ return 0;
}
/* Reset frame length, it can be changed due to bitpool change */
if (n_read < 0)
goto io_fail;
- /* We just read something, so we are supposed to write something, too */
- pending_read_bytes += n_read;
- do_write += pending_read_bytes / u->write_block_size;
- pending_read_bytes = pending_read_bytes % u->write_block_size;
+ if (n_read > 0) {
+ /* We just read something, so we are supposed to write something, too */
+ pending_read_bytes += n_read;
+ do_write += pending_read_bytes / u->write_block_size;
+ pending_read_bytes = pending_read_bytes % u->write_block_size;
+ }
}
}
off:
stop_thread(u);
- pa_assert_se(pa_card_set_profile(u->card, "off", false) >= 0);
+ pa_assert_se(pa_card_set_profile(u->card, pa_hashmap_get(u->card->profiles, "off"), false) >= 0);
return -PA_ERR_IO;
}
if (acquire && transport_acquire(u, true) >= 0) {
if (u->source) {
pa_log_debug("Resuming source %s because its transport state changed to playing", u->source->name);
+
+ /* We remove the IDLE suspend cause, because otherwise
+ * module-loopback doesn't uncork its streams. FIXME: Messing with
+ * the IDLE suspend cause here is wrong, the correct way to handle
+ * this would probably be to uncork the loopback streams not only
+ * when the other end is unsuspended, but also when the other end's
+ * suspend cause changes to IDLE only (currently there's no
+ * notification mechanism for suspend cause changes, though). */
pa_source_suspend(u->source, false, PA_SUSPEND_IDLE|PA_SUSPEND_USER);
}
if (u->sink) {
pa_log_debug("Resuming sink %s because its transport state changed to playing", u->sink->name);
+
+ /* FIXME: See the previous comment. */
pa_sink_suspend(u->sink, false, PA_SUSPEND_IDLE|PA_SUSPEND_USER);
}
}
pa_assert(u);
if (t == u->transport && t->state <= PA_BLUETOOTH_TRANSPORT_STATE_DISCONNECTED)
- pa_assert_se(pa_card_set_profile(u->card, "off", false) >= 0);
+ pa_assert_se(pa_card_set_profile(u->card, pa_hashmap_get(u->card->profiles, "off"), false) >= 0);
if (t->device == u->device)
handle_transport_state_change(u, t);
break;
pa_log_debug("Switching the profile to off due to IO thread failure.");
- pa_assert_se(pa_card_set_profile(u->card, "off", false) >= 0);
+ pa_assert_se(pa_card_set_profile(u->card, pa_hashmap_get(u->card->profiles, "off"), false) >= 0);
break;
}
off:
stop_thread(u);
- pa_assert_se(pa_card_set_profile(u->card, "off", false) >= 0);
+ pa_assert_se(pa_card_set_profile(u->card, pa_hashmap_get(u->card->profiles, "off"), false) >= 0);
return 0;