equal
deleted
inserted
replaced
55 #include "qaudiodeviceinfo_alsa_p.h" |
55 #include "qaudiodeviceinfo_alsa_p.h" |
56 |
56 |
57 QT_BEGIN_NAMESPACE |
57 QT_BEGIN_NAMESPACE |
58 |
58 |
59 //#define DEBUG_AUDIO 1 |
59 //#define DEBUG_AUDIO 1 |
60 |
|
61 static const int minimumIntervalTime = 50; |
|
62 |
60 |
63 QAudioOutputPrivate::QAudioOutputPrivate(const QByteArray &device, const QAudioFormat& audioFormat): |
61 QAudioOutputPrivate::QAudioOutputPrivate(const QByteArray &device, const QAudioFormat& audioFormat): |
64 settings(audioFormat) |
62 settings(audioFormat) |
65 { |
63 { |
66 bytesAvailable = 0; |
64 bytesAvailable = 0; |
82 audioSource = 0; |
80 audioSource = 0; |
83 pullMode = true; |
81 pullMode = true; |
84 resuming = false; |
82 resuming = false; |
85 opened = false; |
83 opened = false; |
86 |
84 |
87 QStringList list1 = QString(QLatin1String(device)).split(QLatin1String(":")); |
85 m_device = device; |
88 m_device = QByteArray(list1.at(0).toLocal8Bit().constData()); |
|
89 |
86 |
90 timer = new QTimer(this); |
87 timer = new QTimer(this); |
91 connect(timer,SIGNAL(timeout()),SLOT(userFeed())); |
88 connect(timer,SIGNAL(timeout()),SLOT(userFeed())); |
92 } |
89 } |
93 |
90 |
280 int dir; |
277 int dir; |
281 int err=-1; |
278 int err=-1; |
282 int count=0; |
279 int count=0; |
283 unsigned int freakuency=settings.frequency(); |
280 unsigned int freakuency=settings.frequency(); |
284 |
281 |
285 QString dev = QLatin1String(m_device.constData()); |
282 QString dev = QString(QLatin1String(m_device.constData())); |
286 QList<QByteArray> devices = QAudioDeviceInfoInternal::availableDevices(QAudio::AudioOutput); |
283 QList<QByteArray> devices = QAudioDeviceInfoInternal::availableDevices(QAudio::AudioOutput); |
287 if(dev.compare(QLatin1String("default")) == 0) { |
284 if(dev.compare(QLatin1String("default")) == 0) { |
288 #if(SND_LIB_MAJOR == 1 && SND_LIB_MINOR == 0 && SND_LIB_SUBMINOR >= 14) |
285 #if(SND_LIB_MAJOR == 1 && SND_LIB_MINOR == 0 && SND_LIB_SUBMINOR >= 14) |
289 dev = QLatin1String(devices.first().constData()); |
286 dev = QLatin1String(devices.first()); |
290 #else |
287 #else |
291 dev = QLatin1String("hw:0,0"); |
288 dev = QLatin1String("hw:0,0"); |
292 #endif |
289 #endif |
293 } else { |
290 } else { |
294 #if(SND_LIB_MAJOR == 1 && SND_LIB_MINOR == 0 && SND_LIB_SUBMINOR >= 14) |
291 #if(SND_LIB_MAJOR == 1 && SND_LIB_MINOR == 0 && SND_LIB_SUBMINOR >= 14) |
572 return buffer_size; |
569 return buffer_size; |
573 } |
570 } |
574 |
571 |
575 void QAudioOutputPrivate::setNotifyInterval(int ms) |
572 void QAudioOutputPrivate::setNotifyInterval(int ms) |
576 { |
573 { |
577 if(ms >= minimumIntervalTime) |
574 intervalTime = qMax(0, ms); |
578 intervalTime = ms; |
|
579 else |
|
580 intervalTime = minimumIntervalTime; |
|
581 } |
575 } |
582 |
576 |
583 int QAudioOutputPrivate::notifyInterval() const |
577 int QAudioOutputPrivate::notifyInterval() const |
584 { |
578 { |
585 return intervalTime; |
579 return intervalTime; |
717 } |
711 } |
718 |
712 |
719 if(deviceState != QAudio::ActiveState) |
713 if(deviceState != QAudio::ActiveState) |
720 return true; |
714 return true; |
721 |
715 |
722 if((timeStamp.elapsed() + elapsedTimeOffset) > intervalTime) { |
716 if(intervalTime && (timeStamp.elapsed() + elapsedTimeOffset) > intervalTime) { |
723 emit notify(); |
717 emit notify(); |
724 elapsedTimeOffset = timeStamp.elapsed() + elapsedTimeOffset - intervalTime; |
718 elapsedTimeOffset = timeStamp.elapsed() + elapsedTimeOffset - intervalTime; |
725 timeStamp.restart(); |
719 timeStamp.restart(); |
726 } |
720 } |
727 return true; |
721 return true; |