Process Crash When Calling AudioPlayback.Unprepare in Tizen Low-Level Audio API

Original Created Mar 04, 2019 | Regeneration Apr 22, 2026

I'm using Tizen's low-level audio capabilities, and while most functionality works correctly, my application crashes when attempting to call Unprepare on an AudioPlayback instance. Here's the relevant code snippet:

playback.Prepare();
var finishedNormally = await tcs.Task;
Log.D("Unpreparing");
_audioPlaybacks[channel].Unprepare();
Log.D("Unprepared");

The crash occurs specifically during the Unprepare call, as shown in the error log:

E/PULSEAUDIO( 5535): thread-mainloop.c: pa_threaded_mainloop_stop(160) > Assertion '!in_worker(m)' failed at pulse/thread-mainloop.c:160, function pa_threaded_mainloop_stop(). Aborting.
I/DOTNET_LAUNCHER( 5535): onSigabrt called

Has anyone successfully used the Unprepare method in low-level audio operations without encountering this crash?

Problem Understanding

The crash occurs due to a thread synchronization issue in PulseAudio when attempting to unprepare an audio playback. The error suggests that the Unprepare operation is being called from an incorrect thread context.

Solution Methods

  1. Thread-Safe Unprepare Operation: The most effective solution is to execute the Unprepare call within a separate Task to ensure proper thread synchronization.

Code Examples

Here's the modified code that resolves the crash:

playback.Prepare();
if(DebugLog) Log.D("Prepared");
var finishedNormally = await tcs.Task;
if (DebugLog) Log.D($"TCS set .. finished normally {finishedNormally}");
var audioPlayback = _audioPlaybacks[channel];

await Task.Run(() => {
    try {
        Log.D("Unpreparing");
        audioPlayback.Unprepare();
        Log.D("Unprepared");
    } catch (Exception ex) {
        Log.E(ex);
    }
});

_audioPlaybacks[channel] = null;
return finishedNormally;

Additional Tips

  • Always handle exceptions when working with audio operations
  • Consider adding debug logging to track the audio playback state
  • Ensure proper cleanup of audio resources to prevent memory leaks

Customize your cookie preferences

You can enable or disable non-essential cookies. Essential cookies are always on to ensure the site works properly and to keep you signed in.

Necessary

These cookies are necessary for the website to function properly and cannot be switched off. They help with things like logging in and setting your privacy preferences.

Always on

Analytics

These cookies help us improve the site by tracking which pages are most popular and how visitors move around the site.

Enable analytics cookies
Public Forum Public Forum
Employees only. Please sign in with your company account.