mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-12 09:04:33 +02:00
Don't copy MediaStream instances
With the large char-buffer, a copy of them will be very inefficent. Explicitly add functions for the conversion to a MediaStream but do not allow a copy constructor.
This commit is contained in:
@@ -154,9 +154,16 @@ AudioOutput::setAutoDelete ( bool ad )
|
||||
|
||||
|
||||
void
|
||||
AudioOutput::setCurrentSource( MediaStream stream )
|
||||
AudioOutput::setCurrentSource( const QUrl& stream )
|
||||
{
|
||||
setCurrentSource( new MediaStream(stream) );
|
||||
setCurrentSource( new MediaStream( stream ) );
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
AudioOutput::setCurrentSource( QIODevice* stream )
|
||||
{
|
||||
setCurrentSource( new MediaStream( stream ) );
|
||||
}
|
||||
|
||||
|
||||
|
@@ -46,8 +46,9 @@ public:
|
||||
|
||||
AudioState state();
|
||||
|
||||
void setCurrentSource(MediaStream stream);
|
||||
void setCurrentSource(MediaStream* stream);
|
||||
void setCurrentSource( const QUrl& stream);
|
||||
void setCurrentSource( QIODevice* stream);
|
||||
void setCurrentSource( MediaStream* stream );
|
||||
|
||||
void play();
|
||||
void pause();
|
||||
|
@@ -77,24 +77,6 @@ MediaStream::MediaStream( QIODevice* device )
|
||||
}
|
||||
|
||||
|
||||
MediaStream::MediaStream( const MediaStream& copy )
|
||||
: QObject( copy.parent() )
|
||||
{
|
||||
m_type = copy.m_type;
|
||||
m_url = copy.m_url;
|
||||
m_ioDevice = copy.m_ioDevice;
|
||||
m_started = copy.m_started;
|
||||
m_bufferingFinished = copy.m_bufferingFinished;
|
||||
m_eos = copy.m_eos;
|
||||
m_pos = copy.m_pos;
|
||||
m_streamSize = copy.m_streamSize;
|
||||
|
||||
if ( m_type == IODevice ) {
|
||||
QObject::connect( m_ioDevice, SIGNAL( readChannelFinished() ), this, SLOT( bufferingFinished() ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
MediaStream::~MediaStream()
|
||||
{
|
||||
tDebug() << Q_FUNC_INFO;
|
||||
|
@@ -39,9 +39,8 @@ public:
|
||||
enum MediaType { Unknown = -1, Empty = 0, Url = 1, Stream = 2, IODevice = 3 };
|
||||
|
||||
MediaStream( QObject* parent = 0 );
|
||||
MediaStream( const MediaStream& copy );
|
||||
MediaStream( const QUrl &url );
|
||||
MediaStream( QIODevice* device );
|
||||
explicit MediaStream( const QUrl &url );
|
||||
explicit MediaStream( QIODevice* device );
|
||||
virtual ~MediaStream();
|
||||
|
||||
MediaType type();
|
||||
@@ -74,6 +73,8 @@ protected:
|
||||
qint64 m_streamSize;
|
||||
|
||||
char m_buffer[1048576];
|
||||
private:
|
||||
Q_DISABLE_COPY( MediaStream );
|
||||
};
|
||||
|
||||
#endif // MEDIASTREAM_H
|
||||
|
Reference in New Issue
Block a user