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

Function decoder_stream_decode

src/decoder/Thread.cxx:112–151  ·  view source on GitHub ↗

* Decode a stream with the given decoder plugin. * * Caller holds DecoderControl::mutex. */

Source from the content-addressed store, hash-verified

110 * Caller holds DecoderControl::mutex.
111 */
112static DecodeResult
113decoder_stream_decode(const DecoderPlugin &plugin,
114 DecoderBridge &bridge,
115 InputStream &input_stream,
116 std::unique_lock<Mutex> &lock)
117{
118 assert(plugin.stream_decode != nullptr);
119 assert(bridge.stream_tag == nullptr);
120 assert(bridge.decoder_tag == nullptr);
121 assert(input_stream.IsReady());
122 assert(bridge.dc.state == DecoderState::START);
123
124 FmtDebug(decoder_thread_domain, "probing plugin {}", plugin.name);
125
126 if (bridge.dc.command == DecoderCommand::STOP)
127 return DecodeResult::STOP;
128
129 /* rewind the stream, so each plugin gets a fresh start */
130 try {
131 input_stream.Rewind(lock);
132 } catch (...) {
133 }
134
135 {
136 const ScopeUnlock unlock{lock};
137
138 FmtThreadName("decoder:{}", plugin.name);
139
140 plugin.StreamDecode(bridge, input_stream);
141
142 SetThreadName("decoder");
143 }
144
145 assert(bridge.dc.state == DecoderState::START ||
146 bridge.dc.state == DecoderState::DECODE);
147
148 return bridge.dc.state == DecoderState::START
149 ? DecodeResult::UNRECOGNIZED_FILE
150 : DecodeResult::SUCCESS;
151}
152
153/**
154 * Decode a file with the given decoder plugin.

Callers 3

TryDecoderFileFunction · 0.85

Calls 1

RewindMethod · 0.80

Tested by

no test coverage detected