diff --git a/src/apps/soundrecorder/RecorderApp.cpp b/src/apps/soundrecorder/RecorderApp.cpp index 567fff2bed..6a3837be4a 100644 --- a/src/apps/soundrecorder/RecorderApp.cpp +++ b/src/apps/soundrecorder/RecorderApp.cpp @@ -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; -} \ No newline at end of file +} diff --git a/src/apps/soundrecorder/RecorderApp.h b/src/apps/soundrecorder/RecorderApp.h index f0ddebba04..953b585f65 100644 --- a/src/apps/soundrecorder/RecorderApp.h +++ b/src/apps/soundrecorder/RecorderApp.h @@ -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; }; diff --git a/src/apps/soundrecorder/RecorderWindow.cpp b/src/apps/soundrecorder/RecorderWindow.cpp index dcbaf8e3a4..3fcb03d669 100644 --- a/src/apps/soundrecorder/RecorderWindow.cpp +++ b/src/apps/soundrecorder/RecorderWindow.cpp @@ -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; ixCountTracks(); 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) } } -} \ No newline at end of file +} diff --git a/src/apps/soundrecorder/RecorderWindow.h b/src/apps/soundrecorder/RecorderWindow.h index 8e06528b47..143dd2d912 100644 --- a/src/apps/soundrecorder/RecorderWindow.h +++ b/src/apps/soundrecorder/RecorderWindow.h @@ -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(); diff --git a/src/apps/soundrecorder/SoundRecorder.rdef b/src/apps/soundrecorder/SoundRecorder.rdef index e5fa0cd7c5..6dd9af6a6f 100644 --- a/src/apps/soundrecorder/SoundRecorder.rdef +++ b/src/apps/soundrecorder/SoundRecorder.rdef @@ -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;