summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/multimedia/opieplayer/playlistwidget.cpp13
-rw-r--r--core/multimedia/opieplayer/wavplugin/wavplugin.cpp2
2 files changed, 6 insertions, 9 deletions
diff --git a/core/multimedia/opieplayer/playlistwidget.cpp b/core/multimedia/opieplayer/playlistwidget.cpp
index 1a0c7ca..a6202bc 100644
--- a/core/multimedia/opieplayer/playlistwidget.cpp
+++ b/core/multimedia/opieplayer/playlistwidget.cpp
@@ -389,74 +389,71 @@ void PlayListWidget::clearList() {
void PlayListWidget::addAllToList() {
DocLnkSet files;
Global::findDocuments(&files, "video/*;audio/*");
QListIterator<DocLnk> dit( files.children() );
for ( ; dit.current(); ++dit )
d->selectedFiles->addToSelection( **dit );
}
void PlayListWidget::addAllMusicToList() {
DocLnkSet files;
Global::findDocuments(&files, "audio/*");
QListIterator<DocLnk> dit( files.children() );
for ( ; dit.current(); ++dit )
d->selectedFiles->addToSelection( **dit );
}
void PlayListWidget::addAllVideoToList() {
DocLnkSet files;
Global::findDocuments(&files, "video/*");
QListIterator<DocLnk> dit( files.children() );
for ( ; dit.current(); ++dit )
d->selectedFiles->addToSelection( **dit );
}
void PlayListWidget::setDocument(const QString& fileref) {
if ( fileref.isNull() ) {
QMessageBox::critical( 0, tr( "Invalid File" ), tr( "There was a problem in getting the file." ) );
return;
}
- if ( mediaPlayerState->playlist() )
- addToSelection( DocLnk( fileref ) );
- else {
- d->setDocumentUsed = TRUE;
- if ( d->current )
- delete d->current;
- d->current = new DocLnk( fileref );
- }
+ addToSelection( DocLnk( fileref ) );
+ d->setDocumentUsed = TRUE;
+ qApp->processEvents();
mediaPlayerState->setPlaying( FALSE );
+ qApp->processEvents();
mediaPlayerState->setPlaying( TRUE );
+ d->selectedFiles->removeSelected( );
}
void PlayListWidget::setActiveWindow() {
// When we get raised we need to ensure that it switches views
char origView = mediaPlayerState->view();
mediaPlayerState->setView( 'l' ); // invalidate
mediaPlayerState->setView( origView ); // now switch back
}
void PlayListWidget::useSelectedDocument() {
d->setDocumentUsed = FALSE;
}
const DocLnk *PlayListWidget::current() {
// qDebug("in Playlist widget ::current");
if ( mediaPlayerState->playlist() ) {
return d->selectedFiles->current();
}
else if ( d->setDocumentUsed && d->current ) {
return d->current;
} else {
return d->files->selected();
}
}
bool PlayListWidget::prev() {
if ( mediaPlayerState->playlist() ) {
diff --git a/core/multimedia/opieplayer/wavplugin/wavplugin.cpp b/core/multimedia/opieplayer/wavplugin/wavplugin.cpp
index 4a0da16..4e82900 100644
--- a/core/multimedia/opieplayer/wavplugin/wavplugin.cpp
+++ b/core/multimedia/opieplayer/wavplugin/wavplugin.cpp
@@ -45,65 +45,64 @@ struct ChunkData {
Q_INT32 avgBytesPerSec;
Q_INT16 blockAlign;
Q_INT16 wBitsPerSample;
};
const int sound_buffer_size = 512; // 4096; // you got to be kidding right?
class WavPluginData {
public:
QFile *input;
int wavedata_remaining;
ChunkData chunkdata;
RiffChunk chunk;
uchar data[sound_buffer_size+32]; // +32 to handle badly aligned input data
int out,max;
int samples_due;
int samples;
WavPluginData() {
max = out = sound_buffer_size;
wavedata_remaining = 0;
samples_due = 0;
samples = -1;
}
// expands out samples to the frequency of 44kHz //not any more
bool add( short *output, long count, long& done, bool stereo )
{
done = 0;
- qApp->processEvents();
if ( input == 0 ) {
qDebug("no input");
return FALSE;
}
while ( count ) {
int l,r;
if ( getSample(l, r) == FALSE ) {
qDebug("didn't get sample");
return FALSE;
}
samples_due += chunkdata.samplesPerSec;
printf("samples due %d\r", samples_due);
fflush(stdout);
while ( count && (samples_due > chunkdata.samplesPerSec) ) {
*output++ = l;
if ( stereo )
*output++ = r;
samples_due -= chunkdata.samplesPerSec;
count--;
done++;
}
}
return TRUE;
}
bool initialise() {
if ( input == 0 )
return FALSE;
wavedata_remaining = -1;
@@ -213,64 +212,65 @@ bool WavPlugin::isFileSupported( const QString& path ) {
char *ext = strrchr( path.latin1(), '.' );
// Test file extension
if ( ext ) {
if ( strncasecmp(ext, ".raw", 4) == 0 )
return TRUE;
if ( strncasecmp(ext, ".wav", 4) == 0 )
return TRUE;
if ( strncasecmp(ext, ".wave", 4) == 0 )
return TRUE;
}
return FALSE;
}
bool WavPlugin::open( const QString& path ) {
// qDebug( "WavPlugin::open" );
d->max = d->out = sound_buffer_size;
d->wavedata_remaining = 0;
d->samples_due = 0;
d->input = new QFile( path );
if ( d->input->open(IO_ReadOnly) == FALSE ) {
qDebug("couldn't open file");
delete d->input;
d->input = 0;
return FALSE;
}
d->initialise();
+ qApp->processEvents();
return TRUE;
}
bool WavPlugin::close() {
// qDebug( "WavPlugin::close" );
d->input->close();
delete d->input;
d->input = 0;
return TRUE;
}
bool WavPlugin::isOpen() {
// qDebug( "WavPlugin::isOpen" );
return ( d->input != 0 );
}
int WavPlugin::audioStreams() {
// qDebug( "WavPlugin::audioStreams" );
return 1;
}
int WavPlugin::audioChannels( int ) {
// qDebug( "WavPlugin::audioChannels" );
return d->chunkdata.channels;// 2; // ### Always scale audio to stereo samples
}