Changeset 2fbd49c in mainline for uspace/srv/audio/hound/audio_sink.c


Ignore:
Timestamp:
2022-09-22T09:01:32Z (19 months ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
2139676
Parents:
a76e76b
git-author:
Jiri Svoboda <jiri@…> (2022-09-21 18:01:20)
git-committer:
Jiri Svoboda <jiri@…> (2022-09-22 09:01:32)
Message:

Audio synk needs locking

Without locking the list of sink connections, we are exposed
to a race between removing a connection at the end of playback
(typically while destroying a hound context) and audio device
event PCM_EVENT_FRAMES_PLAYED which causes audio mixing to occur
via audio_sink_mix_inputs(), causing hound to crash often at
the end of playback.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/audio/hound/audio_sink.c

    ra76e76b r2fbd49c  
    3636#include <assert.h>
    3737#include <errno.h>
     38#include <fibril_synch.h>
    3839#include <stdlib.h>
    3940#include <str.h>
     
    6465                return EINVAL;
    6566        link_initialize(&sink->link);
     67        fibril_mutex_initialize(&sink->lock);
    6668        list_initialize(&sink->connections);
    6769        sink->name = str_dup(name);
     
    139141
    140142        pcm_format_silence(dest, size, &sink->format);
     143        fibril_mutex_lock(&sink->lock);
    141144        list_foreach(sink->connections, sink_link, connection_t, conn) {
    142145                const errno_t ret = connection_add_source_data(
     
    147150                }
    148151        }
     152        fibril_mutex_unlock(&sink->lock);
    149153}
    150154
Note: See TracChangeset for help on using the changeset viewer.