Skip to content

Commit 405a344

Browse files
committed
Merge branch 'fix/async-input-notification' of github.com:acts-1631/MPD into v0.24.x
2 parents c7bb706 + 6785a54 commit 405a344

6 files changed

Lines changed: 16 additions & 14 deletions

File tree

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
ver 0.24.15 (not yet released)
22
* protocol
33
- fix crash on "sticker delete"
4+
* input
5+
- alsa, curl, nfs: fix stalled transfers
46
* playlist
57
- asx, pls, rss, xspf: limit to 16 MB
68
- cue: fix problem playing CUE tracks in music directory root

src/input/AsyncInputStream.cxx

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,6 @@ AsyncInputStream::SeekDone() noexcept
141141
open = true;
142142

143143
seek_state = SeekState::NONE;
144-
caller_cond.notify_one();
145144
InvokeOnAvailable();
146145
}
147146

@@ -207,10 +206,8 @@ AsyncInputStream::CommitWriteBuffer(size_t nbytes) noexcept
207206

208207
if (!IsReady())
209208
SetReady();
210-
else {
211-
caller_cond.notify_one();
209+
else
212210
InvokeOnAvailable();
213-
}
214211
}
215212

216213
void
@@ -240,10 +237,8 @@ AsyncInputStream::AppendToBuffer(std::span<const std::byte> src) noexcept
240237

241238
if (!IsReady())
242239
SetReady();
243-
else {
244-
caller_cond.notify_one();
240+
else
245241
InvokeOnAvailable();
246-
}
247242
}
248243

249244
void
@@ -254,7 +249,6 @@ AsyncInputStream::DeferredResume() noexcept
254249
if (postponed_exception) [[unlikely]] {
255250
/* do not proceed, first the caller must handle the
256251
pending error */
257-
caller_cond.notify_one();
258252
InvokeOnAvailable();
259253
return;
260254
}
@@ -263,7 +257,6 @@ AsyncInputStream::DeferredResume() noexcept
263257
Resume();
264258
} catch (...) {
265259
postponed_exception = std::current_exception();
266-
caller_cond.notify_one();
267260
InvokeOnAvailable();
268261
}
269262
}
@@ -279,7 +272,6 @@ AsyncInputStream::DeferredSeek() noexcept
279272
/* do not proceed, first the caller must handle the
280273
pending error */
281274
seek_state = SeekState::NONE;
282-
caller_cond.notify_one();
283275
InvokeOnAvailable();
284276
return;
285277
}
@@ -295,7 +287,6 @@ AsyncInputStream::DeferredSeek() noexcept
295287
} catch (...) {
296288
seek_state = SeekState::NONE;
297289
postponed_exception = std::current_exception();
298-
caller_cond.notify_one();
299290
InvokeOnAvailable();
300291
}
301292
}

src/input/AsyncInputStream.hxx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,14 @@ class AsyncInputStream : public InputStream {
5656
protected:
5757
std::exception_ptr postponed_exception;
5858

59+
/**
60+
* Notify both the synchronous caller and the InputStream handler.
61+
*/
62+
void InvokeOnAvailable() noexcept {
63+
caller_cond.notify_one();
64+
InputStream::InvokeOnAvailable();
65+
}
66+
5967
public:
6068
AsyncInputStream(EventLoop &event_loop, std::string_view _url,
6169
Mutex &_mutex,

src/input/plugins/AlsaInputPlugin.cxx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ try {
244244
CommitWriteBuffer(nbytes);
245245
}
246246
catch (...) {
247+
const std::lock_guard protect{mutex};
247248
postponed_exception = std::current_exception();
248249
InvokeOnAvailable();
249250
}

src/playlist/Length.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ static void
2828
playlist_provider_length(Response &r,
2929
const SongLoader &loader,
3030
const char *uri,
31-
SongEnumerator &e) noexcept
31+
SongEnumerator &e)
3232
{
3333
const auto base_uri = uri != nullptr
3434
? PathTraitsUTF8::GetParent(uri)

src/playlist/Print.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ playlist_provider_print(Response &r,
2727
SongEnumerator &e,
2828
unsigned start_index,
2929
unsigned end_index,
30-
bool detail) noexcept
30+
bool detail)
3131
{
3232
const auto base_uri = uri != nullptr
3333
? PathTraitsUTF8::GetParent(uri)
@@ -61,7 +61,7 @@ playlist_provider_search_print(Response &r,
6161
SongEnumerator &e,
6262
unsigned start_index,
6363
unsigned end_index,
64-
SongFilter *filter) noexcept
64+
SongFilter *filter)
6565
{
6666
const auto base_uri = uri != nullptr
6767
? PathTraitsUTF8::GetParent(uri)

0 commit comments

Comments
 (0)