MCPcopy Create free account
hub / github.com/defold/defold / UpdateInternal

Function UpdateInternal

engine/sound/src/sound.cpp:1942–2091  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1940 }
1941
1942 static Result UpdateInternal(SoundSystem* sound)
1943 {
1944 DM_PROFILE(__FUNCTION__);
1945
1946 if (sound->m_DeviceResetPending)
1947 {
1948 Result reset_result = ResetDevice(sound);
1949 if (reset_result != RESULT_OK)
1950 {
1951 return reset_result;
1952 }
1953 sound->m_DeviceResetPending = false;
1954 }
1955
1956 if (!sound->m_Device)
1957 {
1958 return RESULT_OK;
1959 }
1960
1961 uint16_t active_instance_count;
1962 {
1963 DM_MUTEX_OPTIONAL_SCOPED_LOCK(g_SoundSystem->m_Mutex);
1964 active_instance_count = sound->m_InstancesPool.Size();
1965 }
1966
1967 bool currentIsAudioInterrupted = IsAudioInterrupted();
1968 if (!sound->m_IsAudioInterrupted && currentIsAudioInterrupted)
1969 {
1970 sound->m_IsAudioInterrupted = true;
1971 if (sound->m_IsDeviceStarted)
1972 {
1973 sound->m_DeviceType->m_DeviceStop(sound->m_Device);
1974 sound->m_IsDeviceStarted = false;
1975 }
1976 }
1977 else if (sound->m_IsAudioInterrupted && !currentIsAudioInterrupted)
1978 {
1979 sound->m_IsAudioInterrupted = false;
1980 if (active_instance_count == 0 && sound->m_IsDeviceStarted == false)
1981 {
1982 return RESULT_NOTHING_TO_PLAY;
1983 }
1984 }
1985
1986 if (sound->m_IsAudioInterrupted)
1987 {
1988 // We can't play sounds when Audio was interrupted by OS event (Phone call, Alarm etc)
1989 return RESULT_OK;
1990 }
1991
1992 if (active_instance_count == 0 && sound->m_IsDeviceStarted == false)
1993 {
1994 return RESULT_NOTHING_TO_PLAY;
1995 }
1996
1997 if (active_instance_count == 0)
1998 {
1999 #if defined(ANDROID)

Callers 2

SoundThreadFunction · 0.70
UpdateFunction · 0.70

Calls 9

ResetDeviceFunction · 0.85
StepGroupValuesFunction · 0.85
StepInstanceValuesFunction · 0.85
MinFunction · 0.85
MixInstancesFunction · 0.85
MasterFunction · 0.85
NotifyDeviceInvalidatedFunction · 0.85
IsAudioInterruptedFunction · 0.70
SizeMethod · 0.45

Tested by

no test coverage detected