* added notification support to Playlist and Controller

* added AbstractLOAdapter by Ingo Weinhold which makes
  notifications asynchronous
* removed "Player" interface/concept, replaced it by
  the notification mechanism (window loads new file
  when "current" ref index changes in Playlist)
* removed some cross classes dependencies
* the wind buttons are not displayed anymore for now
* lots of changes to the Controller
  - the decoder/player threads are kept running for the
    entire lifetime of the Controller object (in essence, makes
    it possible to playback seamless)
  - abstracted BMediaTrack usage into "Video-" and "AudioSupplier"
    objects (the BMediaTrack pointers are only still there, because
    I have not gotten around to fix the messy/hacky InfoWindow)
  - reaching the end of the stream will trigger a notification,
    so that the next file from the playlist is played
  - fSoundOutput is managed by the Controller
  - tried to make seeking seem more controlled (slider doesn't
    jump back to previous position)
  - playback position is correctly updated in GUI
  - volume is maintained independend of SoundOutput so
    that it can be transfered from one to the next output
  - performance time is maintained correctly (?) even if
    no audio stream is present
* work in progress Playlist window (drag sorting does not work yet!)
* rearranged menus a bit
* rearranged overlay code in the VideoView, but it cannot work
  like it is currently designed, since the buffers need to be
  switched all at once, which the video decoding thread
  is not doing yet
* dragging files into the main window with shift held down
  appends to the existing playlist
* dropping folders adds files recursively
* pressing space toggles playback (instead of changing some
  settings of the GUI)
* fixed some more minor issues or unimplemented stuff in the UI


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21276 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Stephan Aßmus
2007-05-29 22:29:50 +00:00
parent 406228de63
commit 5fa5e5fea7
37 changed files with 4024 additions and 635 deletions
+94 -42
View File
@@ -2,6 +2,7 @@
* Controller.h - Media Player for the Haiku Operating System
*
* Copyright (C) 2006 Marcus Overhagen <[email protected]>
* Copyright (C) 2007 Stephan Aßmus <[email protected]>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -22,22 +23,47 @@
#include <MediaDefs.h>
#include <MediaNode.h>
#include <List.h>
#include <Locker.h>
#include <String.h>
class AudioSupplier;
class BBitmap;
class BMediaFile;
class BMediaTrack;
class SoundOutput;
class VideoSupplier;
class VideoView;
class ControllerView;
class Controller
{
class Controller {
public:
class Listener {
public:
Listener();
virtual ~Listener();
virtual void FileFinished();
virtual void FileChanged();
virtual void VideoTrackChanged(int32 index);
virtual void AudioTrackChanged(int32 index);
virtual void VideoStatsChanged();
virtual void AudioStatsChanged();
virtual void PlaybackStateChanged(uint32 state);
virtual void PositionChanged(float position);
virtual void VolumeChanged(float volume);
};
Controller();
virtual ~Controller();
bool Lock();
status_t LockWithTimeout(bigtime_t timeout);
void Unlock();
status_t SetTo(const entry_ref &ref);
void GetSize(int *width, int *height);
@@ -47,51 +73,67 @@ public:
status_t SelectAudioTrack(int n);
status_t SelectVideoTrack(int n);
bigtime_t Duration();
bigtime_t Position();
status_t Seek(bigtime_t pos);
void Stop();
void Play();
void Pause();
bool IsPaused();
bool IsStopped();
bool IsPaused() const;
bool IsStopped() const;
uint32 PlaybackState() const;
bigtime_t Duration();
bigtime_t Position();
void SetVolume(float value);
float Volume() const;
void SetPosition(float value);
// video view
void SetVideoView(VideoView *view);
void SetControllerView(ControllerView *view);
bool IsOverlayActive();
void LockBitmap();
bool LockBitmap();
void UnlockBitmap();
BBitmap * Bitmap();
void VolumeUp();
void VolumeDown();
void SetVolume(float value);
void SetPosition(float value);
void UpdateVolume(float value);
void UpdatePosition(float value);
// notification support
bool AddListener(Listener* listener);
void RemoveListener(Listener* listener);
private:
static int32 audio_decode_thread(void *self);
static int32 video_decode_thread(void *self);
static int32 audio_play_thread(void *self);
static int32 video_play_thread(void *self);
void _AudioDecodeThread();
void _AudioPlayThread();
void _VideoDecodeThread();
void _VideoPlayThread();
void _StartThreads();
void _StopThreads();
void _EndOfStreamReached(bool isVideo = false);
void _UpdatePosition(bigtime_t position,
bool isVideoPosition = false,
bool force = false);
static int32 _VideoDecodeThreadEntry(void *self);
static int32 _VideoPlayThreadEntry(void *self);
static int32 _AudioDecodeThreadEntry(void *self);
static int32 _AudioPlayThreadEntry(void *self);
void AudioDecodeThread();
void VideoDecodeThread();
void AudioPlayThread();
void VideoPlayThread();
void StartThreads();
void StopThreads();
private:
void _NotifyFileChanged();
void _NotifyFileFinished();
void _NotifyVideoTrackChanged(int32 index);
void _NotifyAudioTrackChanged(int32 index);
void _NotifyVideoStatsChanged();
void _NotifyAudioStatsChanged();
void _NotifyPlaybackStateChanged();
void _NotifyPositionChanged(float position);
void _NotifyVolumeChanged(float volume);
friend class InfoWin;
enum {
@@ -106,24 +148,29 @@ private:
size_t sizeMax;
bigtime_t startTime;
bool formatChanged;
bool endOfStream;
media_format mediaFormat;
};
VideoView * fVideoView;
ControllerView * fControllerView;
BString fName;
volatile bool fPaused;
volatile bool fStopped;
float fVolume;
BMediaFile * fMediaFile;
BMediaTrack * fAudioTrack;
BMediaTrack * fVideoTrack;
BLocker fAudioTrackLock;
BLocker fVideoTrackLock;
BMediaTrack * fAudioTrack;
BMediaTrack * fVideoTrack;
mutable BLocker fDataLock;
VideoSupplier* fVideoSupplier;
AudioSupplier* fAudioSupplier;
BLocker fVideoSupplierLock;
BLocker fAudioSupplierLock;
BList * fAudioTrackList;
BList * fVideoTrackList;
bigtime_t fPosition;
media_format fAudioFormat;
media_format fVideoFormat;
@@ -141,6 +188,7 @@ private:
volatile bool fSeekAudio;
volatile bool fSeekVideo;
volatile bigtime_t fSeekPosition;
bigtime_t fPosition;
bigtime_t fDuration;
int32 fAudioBufferCount;
@@ -157,9 +205,13 @@ private:
bigtime_t fTimeSourceSysTime;
bigtime_t fTimeSourcePerfTime;
bool fAutoplay;
volatile bool fPauseAtEndOfStream;
volatile bool fSeekToStartAfterPause;
BBitmap * fCurrentBitmap;
BLocker fBitmapLock;
BList fListeners;
};