File indexing completed on 2024-05-12 04:51:02

0001 /*
0002     SPDX-FileCopyrightText: 2005-2008 Sebastian Trueg <trueg@k3b.org>
0003     SPDX-FileCopyrightText: 2010 Michal Malek <michalm@jabster.pl>
0004     SPDX-FileCopyrightText: 1998-2010 Sebastian Trueg <trueg@k3b.org>
0005 
0006     SPDX-License-Identifier: GPL-2.0-or-later
0007 */
0008 
0009 #include "k3brawaudiodatareader.h"
0010 #include "k3brawaudiodatasource.h"
0011 
0012 #include <QFile>
0013 
0014 namespace K3b {
0015 
0016 class RawAudioDataReader::Private
0017 {
0018 public:
0019     Private( RawAudioDataSource& s )
0020     :
0021         source( s )
0022     {
0023     }
0024 
0025     RawAudioDataSource& source;
0026     QFile imageFile;
0027 };
0028 
0029 
0030 RawAudioDataReader::RawAudioDataReader( RawAudioDataSource& source, QObject* parent )
0031     : QIODevice( parent ),
0032       d( new Private( source ) )
0033 {
0034     d->imageFile.setFileName( source.path() );
0035 }
0036 
0037 
0038 RawAudioDataReader::~RawAudioDataReader()
0039 {
0040     close();
0041 }
0042 
0043 
0044 bool RawAudioDataReader::open( OpenMode mode )
0045 {
0046     return d->imageFile.open( mode ) && QIODevice::open( mode );
0047 }
0048 
0049 
0050 void RawAudioDataReader::close()
0051 {
0052     d->imageFile.close();
0053     QIODevice::close();
0054 }
0055 
0056 
0057 bool RawAudioDataReader::isSequential() const
0058 {
0059     return false;
0060 }
0061 
0062 
0063 qint64 RawAudioDataReader::size() const
0064 {
0065     return d->imageFile.size();
0066 }
0067 
0068 
0069 bool RawAudioDataReader::seek( qint64 pos )
0070 {
0071     d->imageFile.seek( pos );
0072     return QIODevice::seek( pos );
0073 }
0074 
0075 
0076 qint64 RawAudioDataReader::writeData( const char* data, qint64 len )
0077 {
0078     return d->imageFile.write( data, len );
0079 }
0080 
0081 
0082 qint64 RawAudioDataReader::readData( char* data, qint64 maxlen )
0083 {
0084     return d->imageFile.read( data, maxlen );
0085 }
0086 
0087 } // namespace K3b