Fixed GCC4 build and added handling of allocation failures in
some places. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32068 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -10,6 +10,6 @@ Application MediaConverter :
|
||||
MediaFileListView.cpp
|
||||
StatusView.cpp
|
||||
|
||||
: be media tracker
|
||||
: be media tracker $(TARGET_LIBSTDC++)
|
||||
: MediaConverter.rdef
|
||||
;
|
||||
|
||||
@@ -23,17 +23,16 @@
|
||||
#include "Strings.h"
|
||||
|
||||
|
||||
using std::nothrow;
|
||||
|
||||
const char APP_SIGNATURE[] = "application/x-vnd.Haiku-MediaConverter";
|
||||
|
||||
|
||||
MediaConverterApp::MediaConverterApp()
|
||||
: BApplication(APP_SIGNATURE)
|
||||
, fWin(NULL)
|
||||
, fConvertThreadID(-1)
|
||||
, fConverting(false)
|
||||
, fCancel(false)
|
||||
:
|
||||
BApplication(APP_SIGNATURE),
|
||||
fWin(NULL),
|
||||
fConvertThreadID(-1),
|
||||
fConverting(false),
|
||||
fCancel(false)
|
||||
{
|
||||
// TODO: implement settings for window pos
|
||||
fWin = new MediaConverterWindow(BRect(50, 50, 520, 555));
|
||||
@@ -99,22 +98,23 @@ MediaConverterApp::RefsReceived(BMessage *msg)
|
||||
{
|
||||
entry_ref ref;
|
||||
int32 i = 0;
|
||||
BMediaFile *f;
|
||||
BString errorFiles;
|
||||
int32 errors = 0;
|
||||
|
||||
// from Open dialog or drag & drop
|
||||
|
||||
while (msg->FindRef("refs", i++, &ref) == B_OK) {
|
||||
f = new BMediaFile(&ref/*, B_MEDIA_FILE_NO_READ_AHEAD*/);
|
||||
if (f->InitCheck() != B_OK) {
|
||||
uint32 flags = 0; // B_MEDIA_FILE_NO_READ_AHEAD
|
||||
BMediaFile* file = new(std::nothrow) BMediaFile(&ref, flags);
|
||||
if (file == NULL || file->InitCheck() != B_OK) {
|
||||
errorFiles << ref.name << "\n";
|
||||
errors++;
|
||||
delete f;
|
||||
delete file;
|
||||
continue;
|
||||
}
|
||||
if (fWin->Lock()) {
|
||||
fWin->AddSourceFile(f, ref);
|
||||
if (!fWin->AddSourceFile(file, ref))
|
||||
delete file;
|
||||
fWin->Unlock();
|
||||
}
|
||||
}
|
||||
@@ -408,7 +408,8 @@ MediaConverterApp::_ConvertFile(BMediaFile* inFile, BMediaFile* outFile,
|
||||
= inFormat.u.raw_video.pixel_height_aspect;
|
||||
}
|
||||
|
||||
videoBuffer = new (nothrow) uint8[height * rvf->display.bytes_per_row];
|
||||
videoBuffer = new (std::nothrow) uint8[height
|
||||
* rvf->display.bytes_per_row];
|
||||
outVidTrack = outFile->CreateTrack(&outVidFormat, videoCodec);
|
||||
|
||||
if (outVidTrack != NULL) {
|
||||
@@ -417,7 +418,8 @@ MediaConverterApp::_ConvertFile(BMediaFile* inFile, BMediaFile* outFile,
|
||||
BView* encoderView = outVidTrack->GetParameterView();
|
||||
if (encoderView) {
|
||||
MediaEncoderWindow* encoderWin
|
||||
= new MediaEncoderWindow(BRect(50, 50, 520, 555), encoderView);
|
||||
= new MediaEncoderWindow(BRect(50, 50, 520, 555),
|
||||
encoderView);
|
||||
encoderWin->Go();
|
||||
// blocks until the window is quit
|
||||
|
||||
|
||||
@@ -343,11 +343,12 @@ MediaConverterWindow::MessageReceived(BMessage *msg)
|
||||
|
||||
BString string, string2;
|
||||
|
||||
// TODO: for preview, launch the default file app instead of hardcoded MediaPlayer
|
||||
// TODO: For preview, launch the default file app instead of hardcoded
|
||||
// MediaPlayer
|
||||
BEntry entry("/boot/system/apps/MediaPlayer", true);
|
||||
char buffer[40];
|
||||
char buffer2[B_PATH_NAME_LENGTH];
|
||||
char *argv[3];
|
||||
const char* argv[3];
|
||||
argv[0] = "-pos";
|
||||
BMediaFile *inFile(NULL);
|
||||
int32 srcIndex = 0;
|
||||
@@ -501,7 +502,7 @@ MediaConverterWindow::MessageReceived(BMessage *msg)
|
||||
string << fStartDurationTC->Text();
|
||||
string << "000";
|
||||
|
||||
strcpy(buffer,string.String());
|
||||
strcpy(buffer, string.String());
|
||||
argv[1] = buffer;
|
||||
srcIndex = fListView->CurrentSelection();
|
||||
status = GetSourceFileAt(srcIndex, &inFile, &inRef);
|
||||
@@ -512,7 +513,7 @@ MediaConverterWindow::MessageReceived(BMessage *msg)
|
||||
strcpy(buffer, string.String());
|
||||
|
||||
strcpy(buffer2, name.Path());
|
||||
argv[2]= buffer2;
|
||||
argv[2] = buffer2;
|
||||
}
|
||||
|
||||
status = be_roster->Launch(&ref, 3, argv);
|
||||
@@ -752,16 +753,19 @@ MediaConverterWindow::SetStatusMessage(const char *message)
|
||||
// #pragma mark -
|
||||
|
||||
|
||||
void
|
||||
bool
|
||||
MediaConverterWindow::AddSourceFile(BMediaFile* file, const entry_ref& ref)
|
||||
{
|
||||
fListView->AddItem(file, ref);
|
||||
if (!fListView->AddMediaItem(file, ref))
|
||||
return false;
|
||||
|
||||
if (!fOutputDirSpecified) {
|
||||
BEntry entry(&ref);
|
||||
entry.GetParent(&entry);
|
||||
_SetOutputFolder(entry);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -44,11 +44,11 @@ class MediaConverterWindow : public BWindow {
|
||||
media_file_format** _format,
|
||||
media_codec_info** _audio,
|
||||
media_codec_info** _video);
|
||||
|
||||
|
||||
void SetStatusMessage(const char *message);
|
||||
void SetFileMessage(const char *message);
|
||||
|
||||
void AddSourceFile(BMediaFile* file,
|
||||
|
||||
bool AddSourceFile(BMediaFile* file,
|
||||
const entry_ref& ref);
|
||||
void RemoveSourceFile(int32 index);
|
||||
int32 CountSourceFiles();
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
// Copyright 1999, Be Incorporated. All Rights Reserved.
|
||||
// Copyright 2000-2004, Jun Suzuki. All Rights Reserved.
|
||||
// Copyright 2007, Stephan Aßmus. All Rights Reserved.
|
||||
// Copyright 2007, 2009 Stephan Aßmus. All Rights Reserved.
|
||||
// This file may be used under the terms of the Be Sample Code License.
|
||||
|
||||
|
||||
#include "MediaFileListView.h"
|
||||
|
||||
#include <new>
|
||||
|
||||
#include <Application.h>
|
||||
#include <MediaFile.h>
|
||||
#include <Messenger.h>
|
||||
@@ -16,9 +20,10 @@
|
||||
|
||||
|
||||
MediaFileListItem::MediaFileListItem(BMediaFile* file, const entry_ref& ref)
|
||||
: BStringItem(ref.name),
|
||||
fRef(ref),
|
||||
fMediaFile(file)
|
||||
:
|
||||
BStringItem(ref.name),
|
||||
fRef(ref),
|
||||
fMediaFile(file)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -49,7 +54,7 @@ MediaFileListView::~MediaFileListView()
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
void
|
||||
MediaFileListView::SetEnabled(bool enabled)
|
||||
{
|
||||
if (enabled == fEnabled)
|
||||
@@ -60,22 +65,27 @@ MediaFileListView::SetEnabled(bool enabled)
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
bool
|
||||
MediaFileListView::IsEnabled() const
|
||||
{
|
||||
return fEnabled;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
MediaFileListView::AddItem(BMediaFile* file, const entry_ref& ref)
|
||||
bool
|
||||
MediaFileListView::AddMediaItem(BMediaFile* file, const entry_ref& ref)
|
||||
{
|
||||
BListView::AddItem(new MediaFileListItem(file, ref));
|
||||
MediaFileListItem* item = new(std::nothrow) MediaFileListItem(file, ref);
|
||||
if (item == NULL || !AddItem(item)) {
|
||||
delete item;
|
||||
return false;
|
||||
}
|
||||
be_app_messenger.SendMessage(FILE_LIST_CHANGE_MESSAGE);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
void
|
||||
MediaFileListView::KeyDown(const char *bytes, int32 numBytes)
|
||||
{
|
||||
switch (bytes[0]) {
|
||||
@@ -90,7 +100,7 @@ MediaFileListView::KeyDown(const char *bytes, int32 numBytes)
|
||||
selection = count - 1;
|
||||
Select(selection);
|
||||
be_app_messenger.SendMessage(FILE_LIST_CHANGE_MESSAGE);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@@ -99,10 +109,10 @@ MediaFileListView::KeyDown(const char *bytes, int32 numBytes)
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
void
|
||||
MediaFileListView::SelectionChanged()
|
||||
{
|
||||
MediaConverterWindow* win = dynamic_cast<MediaConverterWindow *>(Window());
|
||||
MediaConverterWindow* win = dynamic_cast<MediaConverterWindow*>(Window());
|
||||
if (win != NULL)
|
||||
win->SourceFileSelectionChanged();
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ struct entry_ref;
|
||||
|
||||
|
||||
class MediaFileListItem : public BStringItem {
|
||||
public:
|
||||
public:
|
||||
MediaFileListItem(BMediaFile* file, const entry_ref& ref);
|
||||
virtual ~MediaFileListItem();
|
||||
|
||||
@@ -25,22 +25,23 @@ class MediaFileListItem : public BStringItem {
|
||||
|
||||
|
||||
class MediaFileListView : public BListView {
|
||||
public:
|
||||
public:
|
||||
MediaFileListView(BRect frame,
|
||||
uint32 resizingMode);
|
||||
virtual ~MediaFileListView();
|
||||
|
||||
protected:
|
||||
protected:
|
||||
virtual void KeyDown(const char *bytes, int32 numBytes);
|
||||
virtual void SelectionChanged();
|
||||
|
||||
public:
|
||||
void AddItem(BMediaFile* file, const entry_ref& ref);
|
||||
public:
|
||||
bool AddMediaItem(BMediaFile* file,
|
||||
const entry_ref& ref);
|
||||
|
||||
void SetEnabled(bool enabled);
|
||||
bool IsEnabled() const;
|
||||
|
||||
private:
|
||||
private:
|
||||
bool fEnabled;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user