|
|
@@ -229,12 +229,10 @@ bool resource_construct(
|
|
|
DC_ERR("DC: failed to create audio!\n");
|
|
|
return false;
|
|
|
}
|
|
|
-
|
|
|
if (!aud->funcs->endpoint_valid(aud)) {
|
|
|
aud->funcs->destroy(&aud);
|
|
|
break;
|
|
|
}
|
|
|
-
|
|
|
pool->audios[i] = aud;
|
|
|
pool->audio_count++;
|
|
|
}
|
|
|
@@ -1703,24 +1701,25 @@ static struct audio *find_first_free_audio(
|
|
|
const struct resource_pool *pool,
|
|
|
enum engine_id id)
|
|
|
{
|
|
|
- int i;
|
|
|
- for (i = 0; i < pool->audio_count; i++) {
|
|
|
+ int i, available_audio_count;
|
|
|
+
|
|
|
+ available_audio_count = pool->audio_count;
|
|
|
+
|
|
|
+ for (i = 0; i < available_audio_count; i++) {
|
|
|
if ((res_ctx->is_audio_acquired[i] == false) && (res_ctx->is_stream_enc_acquired[i] == true)) {
|
|
|
/*we have enough audio endpoint, find the matching inst*/
|
|
|
if (id != i)
|
|
|
continue;
|
|
|
-
|
|
|
return pool->audios[i];
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /* use engine id to find free audio */
|
|
|
- if ((id < pool->audio_count) && (res_ctx->is_audio_acquired[id] == false)) {
|
|
|
+ /* use engine id to find free audio */
|
|
|
+ if ((id < available_audio_count) && (res_ctx->is_audio_acquired[id] == false)) {
|
|
|
return pool->audios[id];
|
|
|
}
|
|
|
-
|
|
|
/*not found the matching one, first come first serve*/
|
|
|
- for (i = 0; i < pool->audio_count; i++) {
|
|
|
+ for (i = 0; i < available_audio_count; i++) {
|
|
|
if (res_ctx->is_audio_acquired[i] == false) {
|
|
|
return pool->audios[i];
|
|
|
}
|