added starting/stopping of playback threads
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17358 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -26,6 +26,10 @@
|
|||||||
#include "Controller.h"
|
#include "Controller.h"
|
||||||
#include "VideoView.h"
|
#include "VideoView.h"
|
||||||
|
|
||||||
|
|
||||||
|
#define AUDIO_PRIORITY 10
|
||||||
|
#define VIDEO_PRIORITY 10
|
||||||
|
|
||||||
void
|
void
|
||||||
HandleError(const char *text, status_t err)
|
HandleError(const char *text, status_t err)
|
||||||
{
|
{
|
||||||
@@ -49,12 +53,19 @@ Controller::Controller()
|
|||||||
, fPosition(0)
|
, fPosition(0)
|
||||||
, fAudioPlaySem(create_sem(1, "audio playing"))
|
, fAudioPlaySem(create_sem(1, "audio playing"))
|
||||||
, fVideoPlaySem(create_sem(1, "video playing"))
|
, fVideoPlaySem(create_sem(1, "video playing"))
|
||||||
|
, fAudioPlayThread(-1)
|
||||||
|
, fVideoPlayThread(-1)
|
||||||
|
, fStopAudioPlayback(false)
|
||||||
|
, fStopVideoPlayback(false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Controller::~Controller()
|
Controller::~Controller()
|
||||||
{
|
{
|
||||||
|
StopAudioPlayback();
|
||||||
|
StopVideoPlayback();
|
||||||
|
|
||||||
if (fMediaFile)
|
if (fMediaFile)
|
||||||
fMediaFile->ReleaseAllTracks();
|
fMediaFile->ReleaseAllTracks();
|
||||||
delete fMediaFile;
|
delete fMediaFile;
|
||||||
@@ -328,3 +339,49 @@ void
|
|||||||
Controller::VideoPlayThread()
|
Controller::VideoPlayThread()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
Controller::StartAudioPlayback()
|
||||||
|
{
|
||||||
|
if (fAudioPlayThread > 0)
|
||||||
|
return;
|
||||||
|
fStopAudioPlayback = false;
|
||||||
|
fAudioPlayThread = spawn_thread(audio_play_thread, "audio playback", AUDIO_PRIORITY, this);
|
||||||
|
resume_thread(fAudioPlayThread);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
Controller::StartVideoPlayback()
|
||||||
|
{
|
||||||
|
if (fVideoPlayThread > 0)
|
||||||
|
return;
|
||||||
|
fStopVideoPlayback = false;
|
||||||
|
fVideoPlayThread = spawn_thread(video_play_thread, "video playback", VIDEO_PRIORITY, this);
|
||||||
|
resume_thread(fVideoPlayThread);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
Controller::StopAudioPlayback()
|
||||||
|
{
|
||||||
|
if (fAudioPlayThread < 0)
|
||||||
|
return;
|
||||||
|
fStopAudioPlayback = true;
|
||||||
|
status_t dummy;
|
||||||
|
wait_for_thread(fAudioPlayThread, &dummy);
|
||||||
|
fAudioPlayThread = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
Controller::StopVideoPlayback()
|
||||||
|
{
|
||||||
|
if (fVideoPlayThread < 0)
|
||||||
|
return;
|
||||||
|
fStopVideoPlayback = true;
|
||||||
|
status_t dummy;
|
||||||
|
wait_for_thread(fVideoPlayThread, &dummy);
|
||||||
|
fVideoPlayThread = -1;
|
||||||
|
}
|
||||||
|
|||||||
@@ -68,6 +68,11 @@ private:
|
|||||||
void AudioPlayThread();
|
void AudioPlayThread();
|
||||||
void VideoPlayThread();
|
void VideoPlayThread();
|
||||||
|
|
||||||
|
void StartAudioPlayback();
|
||||||
|
void StartVideoPlayback();
|
||||||
|
void StopAudioPlayback();
|
||||||
|
void StopVideoPlayback();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
VideoView * fVideoView;
|
VideoView * fVideoView;
|
||||||
|
|
||||||
@@ -85,6 +90,8 @@ private:
|
|||||||
sem_id fVideoPlaySem;
|
sem_id fVideoPlaySem;
|
||||||
thread_id fAudioPlayThread;
|
thread_id fAudioPlayThread;
|
||||||
thread_id fVideoPlayThread;
|
thread_id fVideoPlayThread;
|
||||||
|
volatile bool fStopAudioPlayback;
|
||||||
|
volatile bool fStopVideoPlayback;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user