} else {
/* If the request is for a different device type,
* check the previous device role and move streams to default role if needed. */
- prev_device = pa_device_manager_get_device(m->dm, prev_device_type);
- new_device = pa_hashmap_first((direction == STREAM_DIRECTION_OUT) ?
- prev_device->playback_devices : prev_device->capture_devices);
- device_props = (direction == STREAM_DIRECTION_OUT) ? PA_SINK(new_device)->proplist : PA_SOURCE(new_device)->proplist;
- pa_log_debug("may move stream[%u] to default role: [%s][%s -> %s]",
- stream_index, prev_device_type, prev_device_role, pa_proplist_gets(device_props, PA_PROP_DEVICE_ROLE));
+ if ((prev_device = pa_device_manager_get_device(m->dm, prev_device_type)))
+ new_device = pa_hashmap_first((direction == STREAM_DIRECTION_OUT) ?
+ prev_device->playback_devices : prev_device->capture_devices);
+ if (new_device) {
+ device_props = (direction == STREAM_DIRECTION_OUT) ? PA_SINK(new_device)->proplist : PA_SOURCE(new_device)->proplist;
+ pa_log_debug("may move stream[%u] to default role: [%s][%s -> %s]",
+ stream_index, prev_device_type, prev_device_role, pa_proplist_gets(device_props, PA_PROP_DEVICE_ROLE));
+ }
}
if (new_device) {
if (direction == STREAM_DIRECTION_OUT)