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

Function NewSoundDataInternal

engine/sound/src/sound.cpp:770–811  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

768 }
769
770 static Result NewSoundDataInternal(const void* sound_buffer, uint32_t sound_buffer_size,
771 FSoundDataGetData cbk, void* cbk_ctx,
772 SoundDataType type, HSoundData* sound_data, dmhash_t name)
773 {
774 SoundSystem* sound = g_SoundSystem;
775
776 uint16_t index;
777 {
778 DM_MUTEX_OPTIONAL_SCOPED_LOCK(g_SoundSystem->m_Mutex);
779 if (sound->m_SoundDataPool.Remaining() == 0)
780 {
781 *sound_data = 0;
782 dmLogError("Out of sound data slots (%u). Increase the project setting 'sound.max_sound_data'", sound->m_SoundDataPool.Capacity());
783 return RESULT_OUT_OF_INSTANCES;
784 }
785
786 index = sound->m_SoundDataPool.Pop();
787 DM_PROPERTY_SET_U32(rmtp_SoundDataCount, sound->m_SoundDataPool.Size());
788 }
789
790 SoundData* sd = &sound->m_SoundData[index];
791 sd->m_NameHash = name;
792 sd->m_Type = type;
793 sd->m_Index = index;
794 sd->m_Data = 0;
795 sd->m_Size = 0;
796 sd->m_DataCallbacks.m_Context = cbk_ctx;
797 sd->m_DataCallbacks.m_GetData = cbk;
798 sd->m_RefCount = 1;
799 DM_PROPERTY_ADD_U32(rmtp_SoundDataSize, sizeof(SoundData));
800
801 Result result = RESULT_OK;
802 if (sound_buffer != 0)
803 {
804 result = SetSoundDataNoLock(sd, sound_buffer, sound_buffer_size);
805 }
806 if (RESULT_OK == result)
807 *sound_data = sd;
808 else
809 DeleteSoundData(sd);
810 return result;
811 }
812
813 Result NewSoundData(const void* sound_buffer, uint32_t sound_buffer_size, SoundDataType type, HSoundData* sound_data, dmhash_t name)
814 {

Callers 2

NewSoundDataFunction · 0.70
NewSoundDataStreamingFunction · 0.70

Calls 6

SetSoundDataNoLockFunction · 0.85
DeleteSoundDataFunction · 0.70
RemainingMethod · 0.45
CapacityMethod · 0.45
PopMethod · 0.45
SizeMethod · 0.45

Tested by

no test coverage detected