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

Function NewDecoder

engine/sound/src/sound_codec.cpp:67–91  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

65 }
66
67 Result NewDecoder(HCodecContext context, Format format, dmSound::HSoundData sound_data, HDecoder* decoder)
68 {
69 if (context->m_DecodersPool.Remaining() == 0) {
70 return RESULT_OUT_OF_RESOURCES;
71 }
72
73 const DecoderInfo* decoderImpl = FindBestDecoder(format);
74 if (!decoderImpl) {
75 return RESULT_UNSUPPORTED;
76 }
77
78 uint16_t index = context->m_DecodersPool.Pop();
79 Decoder* d = &context->m_Decoders[index];
80 d->m_Index = index;
81 d->m_DecoderInfo = decoderImpl;
82
83 Result r = decoderImpl->m_OpenStream(sound_data, &d->m_Stream);
84 if (r != RESULT_OK) {
85 context->m_DecodersPool.Push(index);
86 return r;
87 }
88
89 *decoder = d;
90 return RESULT_OK;
91 }
92
93 void GetInfo(HCodecContext context, HDecoder decoder, Info* info)
94 {

Callers 2

NewSoundInstanceFunction · 0.85
NewSoundInstanceFunction · 0.85

Calls 4

FindBestDecoderFunction · 0.85
RemainingMethod · 0.45
PopMethod · 0.45
PushMethod · 0.45

Tested by

no test coverage detected