Fix S_GetRawSamplesLength and its sister function being not thread-safe