Media: Show alert while media services restart

This commit is contained in:
Dario Casalinuovo
2015-08-26 16:39:42 +02:00
parent 9a36e655d7
commit d9971ae7aa
2 changed files with 18 additions and 8 deletions
+16 -8
View File
@@ -12,7 +12,6 @@
#include <stdio.h>
#include <Alert.h>
#include <Application.h>
#include <Autolock.h>
#include <Button.h>
@@ -185,7 +184,8 @@ MediaWindow::MediaWindow(BRect frame)
fVideoInputs(5, true),
fVideoOutputs(5, true),
fInitCheck(B_OK),
fRestartThread(-1)
fRestartThread(-1),
fRestartAlert(NULL)
{
_InitWindow();
@@ -307,13 +307,16 @@ MediaWindow::UpdateOutputListItem(MediaListItem::media_type type,
bool
MediaWindow::QuitRequested()
{
status_t exit = B_OK;
if (fRestartThread > 0) {
wait_for_thread(fRestartThread, &exit);
if (exit != B_OK) {
fprintf(stderr, "MediaWindow::QuitRequested wait_for_thread"
" returned with an error: %s\n", strerror(exit));
}
BString text(B_TRANSLATE("Quitting Media now will stop"
"restarting the media services. Flaky or unavailable media"
"functionality is likely the result."));
fRestartAlert = new BAlert(B_TRANSLATE("Warning!"), text,
B_TRANSLATE("Quit anyway"), NULL, NULL,
B_WIDTH_AS_USUAL, B_OFFSET_SPACING, B_WARNING_ALERT);
fRestartAlert->Go();
}
// Stop watching the MediaRoster
fCurrentNode.SetTo(NULL);
@@ -658,6 +661,11 @@ MediaWindow::_RestartMediaServices(void* data)
shutdown_media_server();
launch_media_server();
if (window->fRestartAlert != NULL
&& window->fRestartAlert->Lock()) {
window->fRestartAlert->Quit();
}
return window->PostMessage(ML_RESTART_THREAD_FINISHED);
}
+2
View File
@@ -10,6 +10,7 @@
#define MEDIA_WINDOW_H
#include <Alert.h>
#include <ListView.h>
#include <MediaAddOn.h>
#include <ParameterWeb.h>
@@ -109,6 +110,7 @@ private:
status_t fInitCheck;
thread_id fRestartThread;
BAlert* fRestartAlert;
};