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