mirror of
https://github.com/tomahawk-player/tomahawk.git
synced 2025-08-12 17:14:00 +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
|
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();
|
AudioState state();
|
||||||
|
|
||||||
void setCurrentSource(MediaStream stream);
|
void setCurrentSource( const QUrl& stream);
|
||||||
void setCurrentSource(MediaStream* stream);
|
void setCurrentSource( QIODevice* stream);
|
||||||
|
void setCurrentSource( MediaStream* stream );
|
||||||
|
|
||||||
void play();
|
void play();
|
||||||
void pause();
|
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()
|
MediaStream::~MediaStream()
|
||||||
{
|
{
|
||||||
tDebug() << Q_FUNC_INFO;
|
tDebug() << Q_FUNC_INFO;
|
||||||
|
@@ -39,9 +39,8 @@ public:
|
|||||||
enum MediaType { Unknown = -1, Empty = 0, Url = 1, Stream = 2, IODevice = 3 };
|
enum MediaType { Unknown = -1, Empty = 0, Url = 1, Stream = 2, IODevice = 3 };
|
||||||
|
|
||||||
MediaStream( QObject* parent = 0 );
|
MediaStream( QObject* parent = 0 );
|
||||||
MediaStream( const MediaStream& copy );
|
explicit MediaStream( const QUrl &url );
|
||||||
MediaStream( const QUrl &url );
|
explicit MediaStream( QIODevice* device );
|
||||||
MediaStream( QIODevice* device );
|
|
||||||
virtual ~MediaStream();
|
virtual ~MediaStream();
|
||||||
|
|
||||||
MediaType type();
|
MediaType type();
|
||||||
@@ -74,6 +73,8 @@ protected:
|
|||||||
qint64 m_streamSize;
|
qint64 m_streamSize;
|
||||||
|
|
||||||
char m_buffer[1048576];
|
char m_buffer[1048576];
|
||||||
|
private:
|
||||||
|
Q_DISABLE_COPY( MediaStream );
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MEDIASTREAM_H
|
#endif // MEDIASTREAM_H
|
||||||
|
Reference in New Issue
Block a user