| 66 | } |
| 67 | |
| 68 | static void |
| 69 | mod_decode(DecoderClient &client, InputStream &is) |
| 70 | { |
| 71 | ModPlug_Settings settings; |
| 72 | int ret; |
| 73 | char audio_buffer[MODPLUG_FRAME_SIZE]; |
| 74 | |
| 75 | ModPlug_GetSettings(&settings); |
| 76 | /* alter setting */ |
| 77 | settings.mResamplingMode = modplug_resampling_mode; |
| 78 | settings.mChannels = 2; |
| 79 | settings.mBits = 16; |
| 80 | settings.mFrequency = 44100; |
| 81 | settings.mLoopCount = modplug_loop_count; |
| 82 | /* insert more setting changes here */ |
| 83 | ModPlug_SetSettings(&settings); |
| 84 | |
| 85 | ModPlugFile *f = LoadModPlugFile(&client, is); |
| 86 | if (f == nullptr) { |
| 87 | LogWarning(modplug_domain, "could not decode stream"); |
| 88 | return; |
| 89 | } |
| 90 | |
| 91 | static constexpr AudioFormat audio_format(44100, SampleFormat::S16, 2); |
| 92 | assert(audio_format.IsValid()); |
| 93 | |
| 94 | client.Ready(audio_format, is.IsSeekable(), |
| 95 | SongTime::FromMS(ModPlug_GetLength(f))); |
| 96 | |
| 97 | DecoderCommand cmd; |
| 98 | do { |
| 99 | ret = ModPlug_Read(f, audio_buffer, MODPLUG_FRAME_SIZE); |
| 100 | if (ret <= 0) |
| 101 | break; |
| 102 | |
| 103 | cmd = client.SubmitAudio(nullptr, |
| 104 | std::span{audio_buffer, std::size_t(ret)}, |
| 105 | 0); |
| 106 | |
| 107 | if (cmd == DecoderCommand::SEEK) { |
| 108 | ModPlug_Seek(f, client.GetSeekTime().ToMS()); |
| 109 | client.CommandFinished(); |
| 110 | } |
| 111 | |
| 112 | } while (cmd != DecoderCommand::STOP); |
| 113 | |
| 114 | ModPlug_Unload(f); |
| 115 | } |
| 116 | |
| 117 | static bool |
| 118 | modplug_scan_stream(InputStream &is, TagHandler &handler) noexcept |
nothing calls this directly
no test coverage detected