mirror of
https://github.com/clangen/musikcube.git
synced 2024-10-02 04:52:32 +00:00
Fixed bug where file is opened then false returned causing program exit
This commit is contained in:
parent
3dbaefd0a3
commit
b87a6dd2bd
@ -36,6 +36,9 @@ EsdOut::EsdOut()
|
||||
:waveHandle(NULL)
|
||||
,maxBuffers(32)
|
||||
,currentVolume(1.0)
|
||||
,currentBits(ESD_BITS16)
|
||||
,currentMode(ESD_STEREO)
|
||||
,currentFunc(ESD_PLAY)
|
||||
,addToRemovedBuffers(false)
|
||||
,device("default")
|
||||
//,output(NULL)
|
||||
@ -43,6 +46,7 @@ EsdOut::EsdOut()
|
||||
#ifdef _DEBUG
|
||||
std::cerr << "EsdOut::EsdOut() called" << std::endl;
|
||||
#endif
|
||||
const char* host;
|
||||
}
|
||||
|
||||
EsdOut::~EsdOut(){
|
||||
@ -192,6 +196,12 @@ void EsdOut::SetFormat(IBuffer *buffer){
|
||||
this->currentChannels = buffer->Channels();
|
||||
this->currentSampleRate = buffer->SampleRate();
|
||||
|
||||
this->waveFormat= this->currentBits | this->currentChannels | this->currentMode | this->currentFunc;
|
||||
|
||||
//this->waveHandle = esd_play_stream(this->waveFormat, (int)this->currentSampleRate, this->host, )
|
||||
int sock = esd_open_sound(NULL);
|
||||
this->waveHandle = &sock;
|
||||
|
||||
//TODO: Do something here?
|
||||
|
||||
// Close old waveout
|
||||
|
@ -90,8 +90,11 @@ class EsdOut : public IOutput{
|
||||
int mode = ESD_STREAM, func = ESD_PLAY ;*/
|
||||
|
||||
// Current format
|
||||
int currentBits;
|
||||
int currentChannels;
|
||||
long currentSampleRate;
|
||||
int currentMode;
|
||||
int currentFunc;
|
||||
double currentVolume;
|
||||
|
||||
typedef std::list<EsdOutBufferPtr> BufferList;
|
||||
|
@ -21,6 +21,6 @@ add_definitions(
|
||||
)
|
||||
|
||||
add_library( flacdecoder SHARED ${flacdecoder_SOURCES} )
|
||||
target_link_libraries( flacdecoder ${musikCube_LINK_LIBS})
|
||||
target_link_libraries( flacdecoder ${musikCube_LINK_LIBS} FLAC++)
|
||||
|
||||
|
||||
|
@ -20,6 +20,6 @@ add_definitions(
|
||||
)
|
||||
|
||||
add_library( taglib_plugin SHARED ${taglib_plugin_SOURCES} )
|
||||
target_link_libraries( taglib_plugin ${musikCube_LINK_LIBS})
|
||||
target_link_libraries( taglib_plugin ${musikCube_LINK_LIBS} tag)
|
||||
|
||||
|
||||
|
@ -41,11 +41,11 @@
|
||||
|
||||
using namespace musik::core::audio;
|
||||
|
||||
PlayerPtr Player::Create(utfstring url,OutputPtr output){
|
||||
PlayerPtr Player::Create(utfstring &url,OutputPtr *output){
|
||||
return PlayerPtr(new Player(url,output));
|
||||
}
|
||||
|
||||
Player::Player(utfstring &url,OutputPtr output)
|
||||
Player::Player(utfstring &url,OutputPtr *output)
|
||||
:volume(1.0)
|
||||
,state(Player::Precache)
|
||||
,url(url)
|
||||
@ -54,8 +54,8 @@ Player::Player(utfstring &url,OutputPtr output)
|
||||
,currentPosition(0)
|
||||
,setPosition(-1)
|
||||
{
|
||||
if(output){
|
||||
this->output = output;
|
||||
if(*output){
|
||||
this->output = *output;
|
||||
}else{
|
||||
// Start by finding out what output to use
|
||||
typedef std::vector<OutputPtr> OutputVector;
|
||||
@ -145,7 +145,6 @@ int Player::State(){
|
||||
void Player::ThreadLoop(){
|
||||
#ifdef _DEBUG
|
||||
std::cerr << "Player::ThreadLoop started" << std::endl;
|
||||
std::cerr << "this->url = " << this->url.c_str() << std::endl;
|
||||
#endif
|
||||
// First start the stream
|
||||
this->stream = Stream::Create();
|
||||
|
@ -57,9 +57,9 @@ class Player : public IPlayer {
|
||||
public:
|
||||
typedef boost::shared_ptr<IOutput> OutputPtr;
|
||||
|
||||
static PlayerPtr Create(utfstring url,OutputPtr output=OutputPtr());
|
||||
static PlayerPtr Create(utfstring &url,OutputPtr *output=&OutputPtr());
|
||||
private:
|
||||
Player(utfstring &url,OutputPtr output);
|
||||
Player(utfstring &url,OutputPtr *output);
|
||||
public:
|
||||
~Player(void);
|
||||
|
||||
|
@ -48,6 +48,9 @@ Stream::Stream(unsigned int options)
|
||||
,decoderSampleRate(0)
|
||||
,decoderSamplePosition(0)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
std::cerr << "Stream::Stream()" << std::endl;
|
||||
#endif
|
||||
// Get all DSPs
|
||||
// TODO: fixing PluginFactory
|
||||
if( (this->options&NoDSP)==0){
|
||||
@ -93,13 +96,18 @@ void Stream::SetPreferedBufferSampleSize(long samples){
|
||||
}
|
||||
*/
|
||||
bool Stream::OpenStream(utfstring uri){
|
||||
#ifdef _DEBUG
|
||||
std::cerr << "Stream::OpenStream()" << std::endl;
|
||||
#endif
|
||||
|
||||
// Open the filestream
|
||||
this->fileStream = musik::core::filestreams::Factory::OpenFile(uri.c_str());
|
||||
if(!this->fileStream){
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
std::cerr << "File opened" << std::endl;
|
||||
#endif
|
||||
|
||||
// Look up what DecoderFactory to use
|
||||
StreamHelper::DecoderFactoryPtr decoderFactory;
|
||||
@ -109,10 +117,18 @@ bool Stream::OpenStream(utfstring uri){
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
std::cerr << "File decoder looked for" << std::endl;
|
||||
#endif
|
||||
|
||||
if(!decoderFactory){
|
||||
// We have failed to get a working decoderFactory
|
||||
return false;
|
||||
}
|
||||
#ifdef _DEBUG
|
||||
std::cerr << "Found file decoder" << std::endl;
|
||||
#endif
|
||||
|
||||
|
||||
// Create the decoder
|
||||
IDecoder *decoderPtr = decoderFactory->CreateDecoder();
|
||||
@ -120,13 +136,19 @@ bool Stream::OpenStream(utfstring uri){
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
std::cerr << "Decoder opened" << std::endl;
|
||||
#endif
|
||||
|
||||
// Open the decoder
|
||||
typedef musik::core::PluginFactory::DestroyDeleter<IDecoder> IDecoderDeleter;
|
||||
this->decoder.reset(decoderPtr,IDecoderDeleter());
|
||||
if( !this->decoder->Open(this->fileStream.get()) ){
|
||||
return false;
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
std::cerr << "File opened by decoder" << std::endl;
|
||||
#endif
|
||||
return true;
|
||||
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ Transport::~Transport(){
|
||||
void Transport::PrepareNextTrack(utfstring trackUrl){
|
||||
|
||||
if(this->gapless && this->currentPlayer){
|
||||
this->nextPlayer = Player::Create(trackUrl,this->currentPlayer->output);
|
||||
this->nextPlayer = Player::Create(trackUrl,&this->currentPlayer->output);
|
||||
this->nextPlayer->Play();
|
||||
}else{
|
||||
this->nextPlayer = Player::Create(trackUrl);
|
||||
@ -82,7 +82,7 @@ void Transport::Start(utfstring url){
|
||||
#ifdef _DEBUG
|
||||
std::cerr << "Transport: new output created for player" << std::endl;
|
||||
#endif
|
||||
player = Player::Create(url, output);
|
||||
player = Player::Create(url, &output);
|
||||
player->SetVolume(this->volume);
|
||||
#ifdef _DEBUG
|
||||
std::cerr << "Transport: new player created" << std::endl;
|
||||
|
@ -62,6 +62,9 @@ Factory::Factory(){
|
||||
|
||||
|
||||
FileStreamPtr Factory::OpenFile(const utfchar *uri){
|
||||
#ifdef _DEBUG
|
||||
std::cerr << "Factory::OpenFile(" << uri << ")" << std::endl;
|
||||
#endif
|
||||
typedef musik::core::PluginFactory::DestroyDeleter<IFileStream> StreamDeleter;
|
||||
|
||||
if(uri){
|
||||
|
@ -76,7 +76,7 @@ bool LocalFileStream::Open(const utfchar *filename,unsigned int options){
|
||||
boost::filesystem::utfpath file(filename);
|
||||
this->filesize = (long)boost::filesystem::file_size(file);
|
||||
this->extension = file.extension();
|
||||
// this->file = UTFFopen(filename,UTF("rb"));
|
||||
this->file = UTFFopen(filename,UTF("rb"));
|
||||
this->fd = new boost::iostreams::file_descriptor(filename);
|
||||
this->fileStream = new boost::iostreams::stream<boost::iostreams::file_descriptor>(*this->fd);
|
||||
this->fileStream->exceptions ( std::ios_base::eofbit | std::ios_base::failbit | std::ios_base::badbit );
|
||||
|
Loading…
Reference in New Issue
Block a user