Skip to content

Change output device due to race condition  #512

@francescoc93

Description

@francescoc93

Description

When there are a lot of output device, sometimes when answer the call, the output device change randomly. This problem is due to a race condition in Devices class (package org.jitsi.impl.neomedia.device) method getSelectedDevice(List activeDevices).
When some threads reload the list of devices preference (method loadDevicePreferences) , they empty the list of preferences and, when a thread try to get the device where to send the stream, it find an empty list of preferences and then pick up the first active device detected

Current behavior

sometimes when answer the call, the output device change randomly

Expected Behavior

always send the stream to the first first detected device in the list of preferences

Possible Solution

include the block of code from line 174 to line 217 in the synchronized block at the line 221

Steps to reproduce

it's hard reproduce this bug. To facilitate the reproduce of this bug, it's possibile insert a semaphore in loadDevicePreferences' method (acquire the resource at the begginin and release at the end of method) and a semaphore in getSelectedDevice method (acquire resource at line 173 and release at line 175)

Environment details


Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions