#define SAFE_FINALIZE(_x_) {if ((_x_)) {(_x_)->finalize();}};
#define SAFE_REMOVE(_x_) {if ((_x_)) {(_x_)->finalize(); delete (_x_); (_x_) = NULL;}};
+#define DEFAULT_PERIOD_SIZE 50
#endif
#endif /* __TIZEN_MEDIA_CPP_OBJECTS_IO_H__ */
void convertAudioType2StreamType(CAudioInfo::EAudioType audioType, char **streamType);
void convertInputStreamType2AudioType(char *streamType, CAudioInfo::EAudioType *audioType);
void convertOutputStreamType2AudioType(char *streamType, CAudioInfo::EAudioType *audioType);
+ int getSampleSize();
private:
const char *__STREAM_TYPE_TABLE[(unsigned int)EAudioType::AUDIO_TYPE_MAX] = {
Name: capi-media-audio-io
Summary: An Audio Input & Audio Output library in Tizen Native API
-Version: 0.3.49
+Version: 0.3.50
Release: 0
Group: Multimedia/API
License: Apache-2.0
return;
}
+int CAudioInfo::getSampleSize() {
+ int bytes_in_sample = 0;
+ int number_of_channel = 0;
+
+ switch (__mSampleType) {
+ case ESampleType::SAMPLE_TYPE_U8:
+ bytes_in_sample = 1;
+ break;
+ case ESampleType::SAMPLE_TYPE_S16_LE:
+ bytes_in_sample = 2;
+ break;
+ default:
+ AUDIO_IO_LOGW("As unrecognized sample type %d, let's assume S16_LE", __mSampleType);
+ bytes_in_sample = 2;
+ break;
+ }
+
+ switch (__mChannel) {
+ case EChannel::CHANNEL_MONO:
+ number_of_channel = 1;
+ break;
+ case EChannel::CHANNEL_STEREO:
+ number_of_channel = 2;
+ break;
+ default:
+ AUDIO_IO_LOGW("As unrecognized channel %d, let's assume STEREO", __mChannel);
+ number_of_channel = 2;
+ break;
+ }
+
+ return bytes_in_sample * number_of_channel;
+}
+
void CAudioInfo::convertAudioType2StreamType(CAudioInfo::EAudioType audioType, char **streamType) {
if (audioType < CAudioInfo::EAudioType::AUDIO_IN_TYPE_MEDIA || audioType >= CAudioInfo::EAudioType::AUDIO_TYPE_MAX) {
THROW_ERROR_MSG_FORMAT(CAudioError::EError::ERROR_NOT_SUPPORTED_TYPE, "The audioType is not supported [audioType:%d]", audioType);
THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_INITIALIZED, "Did not initialize CAudioInput");
}
- if (__IsReady() == false) {
- AUDIO_IO_LOGD("Warning: Did not prepare CAudioInput, then return zero");
- return 0;
- }
-
- int size = 0;
-
- try {
- size = mpPulseAudioClient->getBufferSize();
- } catch (CAudioError err) {
- throw err;
- }
-
- return size;
+ /* FIXME : return calculated size here to satisfy backward compatibility */
+ return (mAudioInfo.getSampleRate() * DEFAULT_PERIOD_SIZE) / 1000 * mAudioInfo.getSampleSize();
}
void CAudioInput::setStreamCallback(SStreamCallback callback) throw(CAudioError) {
THROW_ERROR_MSG(CAudioError::EError::ERROR_NOT_INITIALIZED, "Did not initialize CAudioOutput");
}
- if (__IsReady() == false) {
- AUDIO_IO_LOGD("Warning: Did not prepare CAudioOutput, then return zero");
- return 0;
- }
-
- int size = 0;
-
- try {
- size = mpPulseAudioClient->getBufferSize();
- } catch (CAudioError err) {
- throw err;
- }
-
- return size;
+ /* FIXME : return calculated size here to satisfy backward compatibility */
+ return (mAudioInfo.getSampleRate() * DEFAULT_PERIOD_SIZE) / 1000 * mAudioInfo.getSampleSize();
}
size_t CAudioOutput::write(const void* buffer, size_t length) throw(CAudioError) {