rtsp-media: Fix race codition in finish_unprepare

The previous fix for race condition around finish_unprepare where the
function could be called twice assumed that the status wouldn't change
during execution of the function. This assumption is incorrect as the
state may change, for example if an error message arrives from the
pipeline bus.

Instead a flag keeping track on whether the finish_unprepare function
is currently executing is introduced and checked.

Fixes gstreamer/gst-rtsp-server#59

Change-Id: Ibcb3cc6bf413cf72e302335400792fb140bcc68c
8 jobs for master in 8 minutes and 29 seconds (queued for 2 seconds)
Status Job ID Name Coverage
  Preparation
passed #89428
gst indent

00:00:20

passed #89427
manifest

00:00:29

 
  Build
passed #89429
build fedora x86_64

00:03:24

 
  Test
passed #89430
check fedora

00:03:33

 
  Full Builds
failed #89431
build android arm64 api28

00:01:01

failed #89433
build cerbero cross win32

00:00:36

failed #89434
build cerbero cross win64

00:00:37

failed #89432
build cerbero fedora x86_64

00:00:35

 
Name Stage Failure
failed
build cerbero cross win64 Full Builds
                           [--self-update SELF_UPDATE]
{deps,genxcconfig,rdeps,shell,check,run,buildone,build-deps,build,checkpackage,fetch,fetch-package,fetch-cache,bootstrap,fetch-bootstrap,package,genvsprops,bundle-source,tag,gensdkshell,genlibfiles,cleanone,packageinfo,add-recipe,add-package,list,list-packages,show-config,debug-packages,wipe}
...
Uploading artifacts...
manifest.xml: found 1 matching files
cerbero-build/logs: found 3 matching files

WARNING: *.tar.bz2: no matching files
Uploading artifacts to coordinator... ok
id=89434 responseStatus=201 Created token=88r176b5
ERROR: Job failed: exit code 1
failed
build cerbero fedora x86_64 Full Builds
                           [--self-update SELF_UPDATE]
{deps,genxcconfig,rdeps,shell,check,run,buildone,build-deps,build,checkpackage,fetch,fetch-package,fetch-cache,bootstrap,fetch-bootstrap,package,genvsprops,bundle-source,tag,gensdkshell,genlibfiles,cleanone,packageinfo,add-recipe,add-package,list,list-packages,show-config,debug-packages,wipe}
...
Uploading artifacts...
manifest.xml: found 1 matching files
cerbero-build/logs: found 2 matching files

WARNING: *.tar.bz2: no matching files
Uploading artifacts to coordinator... ok
id=89432 responseStatus=201 Created token=wtEYAXjW
ERROR: Job failed: exit code 1
failed
build cerbero cross win32 Full Builds
                           [--self-update SELF_UPDATE]
{deps,genxcconfig,rdeps,shell,check,run,buildone,build-deps,build,checkpackage,fetch,fetch-package,fetch-cache,bootstrap,fetch-bootstrap,package,genvsprops,bundle-source,tag,gensdkshell,genlibfiles,cleanone,packageinfo,add-recipe,add-package,list,list-packages,show-config,debug-packages,wipe}
...
Uploading artifacts...
manifest.xml: found 1 matching files
cerbero-build/logs: found 3 matching files

WARNING: *.tar.bz2: no matching files
Uploading artifacts to coordinator... ok
id=89433 responseStatus=201 Created token=CzpPoPsX
ERROR: Job failed: exit code 1
failed
build android arm64 api28 Full Builds
$ cd gst-build/
$ test -d build && find build -name '*.[ao]' -delete
$ rm -rf subprojects/*/.git/
$ rm -rf build/subprojects/*/.git/
Uploading artifacts...
manifest.xml: found 1 matching files
gst-build/: found 21259 matching files

Uploading artifacts to coordinator... ok
id=89431 responseStatus=201 Created token=zfN1eqyA
ERROR: Job failed: exit code 1