| 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 | { |
no test coverage detected