added a crude hack to play sound
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@17360 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
5dfe4fc749
commit
3e070a9ee4
@ -20,11 +20,13 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <Debug.h>
|
#include <Debug.h>
|
||||||
|
#include <Entry.h>
|
||||||
#include <MediaFile.h>
|
#include <MediaFile.h>
|
||||||
#include <MediaTrack.h>
|
#include <MediaTrack.h>
|
||||||
|
|
||||||
#include "Controller.h"
|
#include "Controller.h"
|
||||||
#include "VideoView.h"
|
#include "VideoView.h"
|
||||||
|
#include "SoundOutput.h"
|
||||||
|
|
||||||
|
|
||||||
#define AUDIO_PRIORITY 10
|
#define AUDIO_PRIORITY 10
|
||||||
@ -43,6 +45,7 @@ HandleError(const char *text, status_t err)
|
|||||||
|
|
||||||
Controller::Controller()
|
Controller::Controller()
|
||||||
: fVideoView(NULL)
|
: fVideoView(NULL)
|
||||||
|
, fName()
|
||||||
, fPaused(false)
|
, fPaused(false)
|
||||||
, fStopped(true)
|
, fStopped(true)
|
||||||
, fMediaFile(0)
|
, fMediaFile(0)
|
||||||
@ -100,6 +103,7 @@ Controller::SetTo(const entry_ref &ref)
|
|||||||
fPosition = 0;
|
fPosition = 0;
|
||||||
fPaused = false;
|
fPaused = false;
|
||||||
fStopped = true;
|
fStopped = true;
|
||||||
|
fName = ref.name;
|
||||||
|
|
||||||
status_t err;
|
status_t err;
|
||||||
|
|
||||||
@ -181,11 +185,14 @@ Controller::AudioTrackCount()
|
|||||||
status_t
|
status_t
|
||||||
Controller::SelectAudioTrack(int n)
|
Controller::SelectAudioTrack(int n)
|
||||||
{
|
{
|
||||||
|
StopAudioPlayback();
|
||||||
|
|
||||||
BMediaTrack *t = (BMediaTrack *)fAudioTrackList->ItemAt(n);
|
BMediaTrack *t = (BMediaTrack *)fAudioTrackList->ItemAt(n);
|
||||||
if (!t)
|
if (!t)
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
fAudioTrack = t;
|
fAudioTrack = t;
|
||||||
|
|
||||||
|
StartAudioPlayback();
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -193,11 +200,14 @@ Controller::SelectAudioTrack(int n)
|
|||||||
status_t
|
status_t
|
||||||
Controller::SelectVideoTrack(int n)
|
Controller::SelectVideoTrack(int n)
|
||||||
{
|
{
|
||||||
|
StopVideoPlayback();
|
||||||
|
|
||||||
BMediaTrack *t = (BMediaTrack *)fVideoTrackList->ItemAt(n);
|
BMediaTrack *t = (BMediaTrack *)fVideoTrackList->ItemAt(n);
|
||||||
if (!t)
|
if (!t)
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
fVideoTrack = t;
|
fVideoTrack = t;
|
||||||
|
|
||||||
|
StartVideoPlayback();
|
||||||
return B_OK;
|
return B_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -332,6 +342,24 @@ Controller::video_play_thread(void *self)
|
|||||||
void
|
void
|
||||||
Controller::AudioPlayThread()
|
Controller::AudioPlayThread()
|
||||||
{
|
{
|
||||||
|
// this is a test...
|
||||||
|
media_format fmt;
|
||||||
|
fmt.type = B_MEDIA_RAW_AUDIO;
|
||||||
|
fmt.u.raw_audio = media_multi_audio_format::wildcard;
|
||||||
|
fmt.u.raw_audio.format = media_multi_audio_format::B_AUDIO_FLOAT;
|
||||||
|
|
||||||
|
fAudioTrack->DecodedFormat(&fmt);
|
||||||
|
|
||||||
|
SoundOutput out(fName.String(), fmt.u.raw_audio);
|
||||||
|
|
||||||
|
int frame_size = (fmt.u.raw_audio.format & 0xf) * fmt.u.raw_audio.channel_count;
|
||||||
|
uint8 buffer[fmt.u.raw_audio.buffer_size];
|
||||||
|
int64 frames;
|
||||||
|
media_header mh;
|
||||||
|
|
||||||
|
while (!fStopAudioPlayback && B_OK == fAudioTrack->ReadFrames(buffer, &frames, &mh)) {
|
||||||
|
out.Play(buffer, frames * frame_size);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
|
|
||||||
#include <MediaDefs.h>
|
#include <MediaDefs.h>
|
||||||
#include <MediaNode.h>
|
#include <MediaNode.h>
|
||||||
|
#include <String.h>
|
||||||
|
|
||||||
class BBitmap;
|
class BBitmap;
|
||||||
class BMediaFile;
|
class BMediaFile;
|
||||||
@ -77,7 +78,7 @@ private:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
VideoView * fVideoView;
|
VideoView * fVideoView;
|
||||||
|
BString fName;
|
||||||
bool fPaused;
|
bool fPaused;
|
||||||
bool fStopped;
|
bool fStopped;
|
||||||
BMediaFile * fMediaFile;
|
BMediaFile * fMediaFile;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user