* Refactored storing the playlist archive in the quit message.
* Added looping all windows on quit and store the current playlist if applicable. Fixes #5061. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35253 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
fa8101b56e
commit
312ca935ab
@ -106,6 +106,26 @@ MainApp::~MainApp()
|
||||
bool
|
||||
MainApp::QuitRequested()
|
||||
{
|
||||
// Make sure we store the current playlist, if applicable.
|
||||
for (int32 i = 0; BWindow* window = WindowAt(i); i++) {
|
||||
MainWin* playerWindow = dynamic_cast<MainWin*>(window);
|
||||
if (playerWindow == NULL)
|
||||
continue;
|
||||
|
||||
BAutolock _(playerWindow);
|
||||
|
||||
BMessage quitMessage;
|
||||
playerWindow->GetQuitMessage(&quitMessage);
|
||||
|
||||
// Store the playlist if there is one. If the user has multiple
|
||||
// instances playing audio at the this time, the first instance wins.
|
||||
BMessage playlistArchive;
|
||||
if (quitMessage.FindMessage("playlist", &playlistArchive) == B_OK) {
|
||||
_StoreCurrentPlaylist(&playlistArchive);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Note: This needs to be done here, SettingsWindow::QuitRequested()
|
||||
// returns "false" always. (Standard BApplication quit procedure will
|
||||
// hang otherwise.)
|
||||
|
@ -737,26 +737,7 @@ bool
|
||||
MainWin::QuitRequested()
|
||||
{
|
||||
BMessage message(M_PLAYER_QUIT);
|
||||
message.AddPointer("instance", this);
|
||||
message.AddRect("window frame", Frame());
|
||||
message.AddBool("audio only", !fHasVideo);
|
||||
message.AddInt64("creation time", fCreationTime);
|
||||
if (!fHasVideo && fHasAudio) {
|
||||
// store playlist, current index and position if this is audio
|
||||
BMessage playlistArchive;
|
||||
|
||||
BAutolock controllerLocker(fController);
|
||||
playlistArchive.AddInt64("position", fController->TimePosition());
|
||||
controllerLocker.Unlock();
|
||||
|
||||
BAutolock playlistLocker(fPlaylist);
|
||||
if (fPlaylist->Archive(&playlistArchive) != B_OK
|
||||
|| playlistArchive.AddInt32("index",
|
||||
fPlaylist->CurrentItemIndex()) != B_OK
|
||||
|| message.AddMessage("playlist", &playlistArchive) != B_OK) {
|
||||
fprintf(stderr, "Failed to store current playlist.\n");
|
||||
}
|
||||
}
|
||||
GetQuitMessage(&message);
|
||||
be_app->PostMessage(&message);
|
||||
return true;
|
||||
}
|
||||
@ -927,6 +908,32 @@ MainWin::VideoFormatChange(int width, int height, int widthAspect,
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
MainWin::GetQuitMessage(BMessage* message)
|
||||
{
|
||||
message->AddPointer("instance", this);
|
||||
message->AddRect("window frame", Frame());
|
||||
message->AddBool("audio only", !fHasVideo);
|
||||
message->AddInt64("creation time", fCreationTime);
|
||||
if (!fHasVideo && fHasAudio) {
|
||||
// store playlist, current index and position if this is audio
|
||||
BMessage playlistArchive;
|
||||
|
||||
BAutolock controllerLocker(fController);
|
||||
playlistArchive.AddInt64("position", fController->TimePosition());
|
||||
controllerLocker.Unlock();
|
||||
|
||||
BAutolock playlistLocker(fPlaylist);
|
||||
if (fPlaylist->Archive(&playlistArchive) != B_OK
|
||||
|| playlistArchive.AddInt32("index",
|
||||
fPlaylist->CurrentItemIndex()) != B_OK
|
||||
|| message->AddMessage("playlist", &playlistArchive) != B_OK) {
|
||||
fprintf(stderr, "Failed to store current playlist.\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
|
@ -72,6 +72,8 @@ public:
|
||||
void VideoFormatChange(int width, int height,
|
||||
int widthAspect, int heightAspect);
|
||||
|
||||
void GetQuitMessage(BMessage* message);
|
||||
|
||||
private:
|
||||
void _RefsReceived(BMessage* message);
|
||||
void _PlaylistItemOpened(
|
||||
|
Loading…
Reference in New Issue
Block a user