MCPcopy Create free account
hub / github.com/MusicPlayerDaemon/MPD / mod_decode

Function mod_decode

src/decoder/plugins/ModplugDecoderPlugin.cxx:68–115  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

66}
67
68static void
69mod_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
117static bool
118modplug_scan_stream(InputStream &is, TagHandler &handler) noexcept

Callers

nothing calls this directly

Calls 6

LoadModPlugFileFunction · 0.85
IsValidMethod · 0.45
ReadyMethod · 0.45
SubmitAudioMethod · 0.45
GetSeekTimeMethod · 0.45
CommandFinishedMethod · 0.45

Tested by

no test coverage detected