equal
deleted
inserted
replaced
68 |
68 |
69 |
69 |
70 QT_BEGIN_NAMESPACE |
70 QT_BEGIN_NAMESPACE |
71 |
71 |
72 |
72 |
73 namespace |
73 namespace QtMultimediaInternal |
74 { |
74 { |
75 |
75 |
76 static const int default_buffer_size = 8 * 1024; |
76 static const int default_buffer_size = 8 * 1024; |
77 |
77 |
78 |
78 |
235 class MacOutputDevice : public QIODevice |
235 class MacOutputDevice : public QIODevice |
236 { |
236 { |
237 Q_OBJECT |
237 Q_OBJECT |
238 |
238 |
239 public: |
239 public: |
240 MacOutputDevice(QAudioOutputBuffer* audioBuffer, QObject* parent): |
240 MacOutputDevice(QtMultimediaInternal::QAudioOutputBuffer* audioBuffer, QObject* parent): |
241 QIODevice(parent), |
241 QIODevice(parent), |
242 m_audioBuffer(audioBuffer) |
242 m_audioBuffer(audioBuffer) |
243 { |
243 { |
244 open(QIODevice::WriteOnly | QIODevice::Unbuffered); |
244 open(QIODevice::WriteOnly | QIODevice::Unbuffered); |
245 } |
245 } |
261 { |
261 { |
262 return true; |
262 return true; |
263 } |
263 } |
264 |
264 |
265 private: |
265 private: |
266 QAudioOutputBuffer* m_audioBuffer; |
266 QtMultimediaInternal::QAudioOutputBuffer* m_audioBuffer; |
267 }; |
267 }; |
268 |
268 |
269 |
269 |
270 QAudioOutputPrivate::QAudioOutputPrivate(const QByteArray& device, const QAudioFormat& format): |
270 QAudioOutputPrivate::QAudioOutputPrivate(const QByteArray& device, const QAudioFormat& format): |
271 audioFormat(format) |
271 audioFormat(format) |
283 audioUnit = 0; |
283 audioUnit = 0; |
284 audioIO = 0; |
284 audioIO = 0; |
285 startTime = 0; |
285 startTime = 0; |
286 totalFrames = 0; |
286 totalFrames = 0; |
287 audioBuffer = 0; |
287 audioBuffer = 0; |
288 internalBufferSize = default_buffer_size; |
288 internalBufferSize = QtMultimediaInternal::default_buffer_size; |
289 clockFrequency = AudioGetHostClockFrequency() / 1000; |
289 clockFrequency = AudioGetHostClockFrequency() / 1000; |
290 errorCode = QAudio::NoError; |
290 errorCode = QAudio::NoError; |
291 stateCode = QAudio::StoppedState; |
291 stateCode = QAudio::StoppedState; |
292 audioThreadState = Stopped; |
292 audioThreadState = Stopped; |
293 |
293 |
397 if (internalBufferSize < periodSizeBytes * 2) |
397 if (internalBufferSize < periodSizeBytes * 2) |
398 internalBufferSize = periodSizeBytes * 2; |
398 internalBufferSize = periodSizeBytes * 2; |
399 else |
399 else |
400 internalBufferSize -= internalBufferSize % streamFormat.mBytesPerFrame; |
400 internalBufferSize -= internalBufferSize % streamFormat.mBytesPerFrame; |
401 |
401 |
402 audioBuffer = new QAudioOutputBuffer(internalBufferSize, periodSizeBytes, audioFormat); |
402 audioBuffer = new QtMultimediaInternal::QAudioOutputBuffer(internalBufferSize, periodSizeBytes, audioFormat); |
403 connect(audioBuffer, SIGNAL(readyRead()), SLOT(inputReady())); // Pull |
403 connect(audioBuffer, SIGNAL(readyRead()), SLOT(inputReady())); // Pull |
404 |
404 |
405 audioIO = new MacOutputDevice(audioBuffer, this); |
405 audioIO = new MacOutputDevice(audioBuffer, this); |
406 |
406 |
407 // Init |
407 // Init |
433 |
433 |
434 QIODevice* QAudioOutputPrivate::start(QIODevice* device) |
434 QIODevice* QAudioOutputPrivate::start(QIODevice* device) |
435 { |
435 { |
436 QIODevice* op = device; |
436 QIODevice* op = device; |
437 |
437 |
438 if (!open()) { |
438 if (!audioFormat.isValid() || !open()) { |
439 stateCode = QAudio::StoppedState; |
439 stateCode = QAudio::StoppedState; |
440 errorCode = QAudio::OpenError; |
440 errorCode = QAudio::OpenError; |
441 return audioIO; |
441 return audioIO; |
442 } |
442 } |
443 |
443 |
534 return internalBufferSize; |
534 return internalBufferSize; |
535 } |
535 } |
536 |
536 |
537 void QAudioOutputPrivate::setNotifyInterval(int milliSeconds) |
537 void QAudioOutputPrivate::setNotifyInterval(int milliSeconds) |
538 { |
538 { |
|
539 if (intervalTimer->interval() == milliSeconds) |
|
540 return; |
|
541 |
|
542 if (milliSeconds <= 0) |
|
543 milliSeconds = 0; |
|
544 |
539 intervalTimer->setInterval(milliSeconds); |
545 intervalTimer->setInterval(milliSeconds); |
540 } |
546 } |
541 |
547 |
542 int QAudioOutputPrivate::notifyInterval() const |
548 int QAudioOutputPrivate::notifyInterval() const |
543 { |
549 { |
620 } |
626 } |
621 |
627 |
622 void QAudioOutputPrivate::startTimers() |
628 void QAudioOutputPrivate::startTimers() |
623 { |
629 { |
624 audioBuffer->startFillTimer(); |
630 audioBuffer->startFillTimer(); |
625 intervalTimer->start(); |
631 if (intervalTimer->interval() > 0) |
|
632 intervalTimer->start(); |
626 } |
633 } |
627 |
634 |
628 void QAudioOutputPrivate::stopTimers() |
635 void QAudioOutputPrivate::stopTimers() |
629 { |
636 { |
630 audioBuffer->stopFillTimer(); |
637 audioBuffer->stopFillTimer(); |