signature fix
now quits gracefully when no media roster is available git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13094 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
98f5c76b8f
commit
5fa7753230
@ -12,6 +12,7 @@
|
||||
RecorderApp::RecorderApp(const char * signature) :
|
||||
BApplication(signature), fRecorderWin(NULL)
|
||||
{
|
||||
fRecorderWin = new RecorderWindow();
|
||||
}
|
||||
|
||||
RecorderApp::~RecorderApp()
|
||||
@ -19,12 +20,12 @@ RecorderApp::~RecorderApp()
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
RecorderApp::ReadyToRun()
|
||||
status_t
|
||||
RecorderApp::InitCheck()
|
||||
{
|
||||
BApplication::ReadyToRun();
|
||||
fRecorderWin = new RecorderWindow();
|
||||
fRecorderWin->Show();
|
||||
if (fRecorderWin)
|
||||
return fRecorderWin->InitCheck();
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
@ -32,6 +33,7 @@ int
|
||||
main()
|
||||
{
|
||||
RecorderApp app("application/x-vnd.Haiku-SoundRecorder");
|
||||
app.Run();
|
||||
if (app.InitCheck() == B_OK)
|
||||
app.Run();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -14,11 +14,9 @@ class RecorderWindow;
|
||||
|
||||
class RecorderApp : public BApplication {
|
||||
public:
|
||||
RecorderApp(const char * signature);
|
||||
virtual ~RecorderApp();
|
||||
|
||||
virtual void ReadyToRun();
|
||||
|
||||
RecorderApp(const char * signature);
|
||||
virtual ~RecorderApp();
|
||||
status_t InitCheck();
|
||||
private:
|
||||
RecorderWindow* fRecorderWin;
|
||||
};
|
||||
|
@ -101,9 +101,11 @@ RecorderWindow::RecorderWindow() :
|
||||
BWindow(BRect(XPOS,YPOS,XPOS+MIN_WIDTH,YPOS+MIN_HEIGHT), "Sound Recorder", B_TITLED_WINDOW,
|
||||
B_ASYNCHRONOUS_CONTROLS | B_NOT_V_RESIZABLE),
|
||||
fPlayer(NULL),
|
||||
fSoundList(NULL),
|
||||
fPlayFile(NULL),
|
||||
fPlayTrack(NULL),
|
||||
fSavePanel(B_SAVE_PANEL)
|
||||
fSavePanel(NULL),
|
||||
fInitCheck(B_OK)
|
||||
{
|
||||
fRoster = NULL;
|
||||
fRecordButton = NULL;
|
||||
@ -119,12 +121,16 @@ RecorderWindow::RecorderWindow() :
|
||||
|
||||
CalcSizes(MIN_WIDTH, MIN_HEIGHT);
|
||||
|
||||
InitWindow();
|
||||
fInitCheck = InitWindow();
|
||||
if (fInitCheck != B_OK) {
|
||||
ErrorAlert("connect to media server", fInitCheck);
|
||||
PostMessage(B_QUIT_REQUESTED);
|
||||
} else
|
||||
Show();
|
||||
}
|
||||
|
||||
RecorderWindow::~RecorderWindow()
|
||||
{
|
||||
DEATH((stderr, "RecorderWindow::~RecorderWindow()\n"));
|
||||
// The sound consumer and producer are Nodes; it has to be Release()d and the Roster
|
||||
// will reap it when it's done.
|
||||
if (fRecordNode) {
|
||||
@ -154,6 +160,13 @@ RecorderWindow::~RecorderWindow()
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
RecorderWindow::InitCheck()
|
||||
{
|
||||
return fInitCheck;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
RecorderWindow::CalcSizes(float min_wid, float min_hei)
|
||||
{
|
||||
@ -441,7 +454,8 @@ RecorderWindow::InitWindow()
|
||||
popup->Superitem()->SetLabel(selected_name);
|
||||
|
||||
// Make sure the save panel is happy.
|
||||
fSavePanel.SetTarget(this);
|
||||
fSavePanel = new BFilePanel(B_SAVE_PANEL);
|
||||
fSavePanel->SetTarget(this);
|
||||
}
|
||||
catch (...) {
|
||||
goto bad_mojo;
|
||||
@ -713,9 +727,9 @@ RecorderWindow::Save(BMessage * message)
|
||||
pItem->Entry().GetRef(&ref);
|
||||
|
||||
saveMsg.AddPointer("sound list item", pItem);
|
||||
fSavePanel.SetSaveText(filename);
|
||||
fSavePanel.SetMessage(&saveMsg);
|
||||
fSavePanel.Show();
|
||||
fSavePanel->SetSaveText(filename);
|
||||
fSavePanel->SetMessage(&saveMsg);
|
||||
fSavePanel->Show();
|
||||
}
|
||||
|
||||
void
|
||||
@ -1009,6 +1023,9 @@ RecorderWindow::UpdateButtons()
|
||||
fInputField->SetEnabled(fButtonState != btnRecording);
|
||||
}
|
||||
|
||||
#ifndef __HAIKU__
|
||||
extern "C" status_t DecodedFormat__11BMediaTrackP12media_format(BMediaTrack *self, media_format *inout_format);
|
||||
#endif
|
||||
|
||||
void
|
||||
RecorderWindow::UpdatePlayFile()
|
||||
@ -1036,7 +1053,12 @@ RecorderWindow::UpdatePlayFile()
|
||||
for (int ix=0; ix<fPlayFile->CountTracks(); ix++) {
|
||||
BMediaTrack * track = fPlayFile->TrackAt(ix);
|
||||
fPlayFormat.type = B_MEDIA_RAW_AUDIO;
|
||||
if ((track->DecodedFormat(&fPlayFormat) == B_OK) && (fPlayFormat.type == B_MEDIA_RAW_AUDIO)) {
|
||||
#ifdef __HAIKU__
|
||||
if ((track->DecodedFormat(&fPlayFormat) == B_OK)
|
||||
#else
|
||||
if ((DecodedFormat__11BMediaTrackP12media_format(track, &fPlayFormat) == B_OK)
|
||||
#endif
|
||||
&& (fPlayFormat.type == B_MEDIA_RAW_AUDIO)) {
|
||||
fPlayTrack = track;
|
||||
break;
|
||||
}
|
||||
@ -1096,7 +1118,7 @@ void
|
||||
RecorderWindow::ErrorAlert(const char * action, status_t err)
|
||||
{
|
||||
char msg[300];
|
||||
sprintf(msg, "Cannot %s: %s.\n[%lx]", action, strerror(err), (int32) err);
|
||||
sprintf(msg, "Cannot %s: %s. [%lx]", action, strerror(err), (int32) err);
|
||||
(new BAlert("", msg, "Stop"))->Go();
|
||||
}
|
||||
|
||||
@ -1230,4 +1252,4 @@ RecorderWindow::RefsReceived(BMessage *msg)
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -40,11 +40,12 @@ class BStringView;
|
||||
class RecorderWindow : public BWindow {
|
||||
public:
|
||||
RecorderWindow();
|
||||
virtual ~RecorderWindow();
|
||||
virtual ~RecorderWindow();
|
||||
status_t InitCheck();
|
||||
|
||||
|
||||
virtual bool QuitRequested();
|
||||
virtual void MessageReceived(BMessage * message);
|
||||
virtual bool QuitRequested();
|
||||
virtual void MessageReceived(BMessage * message);
|
||||
|
||||
enum {
|
||||
RECORD = 'cw00', // command messages
|
||||
@ -123,7 +124,8 @@ private:
|
||||
|
||||
media_node fAudioMixerNode;
|
||||
|
||||
BFilePanel fSavePanel;
|
||||
BFilePanel *fSavePanel;
|
||||
status_t fInitCheck;
|
||||
|
||||
status_t InitWindow();
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
|
||||
resource app_signature "application/x-vnd.haiku.SoundRecorder";
|
||||
resource app_signature "application/x-vnd.Haiku-SoundRecorder";
|
||||
|
||||
resource app_flags B_SINGLE_LAUNCH;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user