- host_time.mFlags = kAudioTimeStampHostTimeValid;
- AudioDeviceTranslateTime(p_sys->i_selected_dev, inTimeStamp, &host_time);
-
- /* Check for the difference between the Device clock and mdate */
- p_sys->clock_diff = - (mtime_t)
- AudioConvertHostTimeToNanos(AudioGetCurrentHostTime()) / 1000;
- p_sys->clock_diff += mdate();
-
- current_date = p_sys->clock_diff +
- AudioConvertHostTimeToNanos(host_time.mHostTime) / 1000;
- //- ((mtime_t) 1000000 / p_aout->format.i_rate * 31); // 31 = Latency in Frames. retrieve somewhere
-
- if (ioData == NULL || ioData->mNumberBuffers < 1) {
- msg_Err(p_aout, "no iodata or buffers");
- return 0;
- }
- if (ioData->mNumberBuffers > 1)
- msg_Err(p_aout, "well this is weird. seems like there is more than one buffer...");
-
- if (p_sys->i_total_bytes > 0) {
- i_mData_bytes = __MIN(p_sys->i_total_bytes - p_sys->i_read_bytes, ioData->mBuffers[0].mDataByteSize);
- memcpy(ioData->mBuffers[0].mData,
- &p_sys->p_remainder_buffer[p_sys->i_read_bytes],
- i_mData_bytes);
- p_sys->i_read_bytes += i_mData_bytes;
- current_date += (mtime_t) ((mtime_t) 1000000 / p_sys->packet.format.i_rate) *
- (i_mData_bytes / 4 / aout_FormatNbChannels(&p_sys->packet.format)); // 4 is fl32 specific
-
- if (p_sys->i_read_bytes >= p_sys->i_total_bytes)
- p_sys->i_read_bytes = p_sys->i_total_bytes = 0;
- }
-
- while(i_mData_bytes < ioData->mBuffers[0].mDataByteSize) {
- /* We don't have enough data yet */
- block_t * p_buffer;
- p_buffer = aout_PacketNext(p_aout, current_date);
-
- if (p_buffer != NULL)
- {
- /* Do the channel reordering */
- if (p_buffer && p_sys->chans_to_reorder)
- {
- aout_ChannelReorder(p_buffer->p_buffer,
- p_buffer->i_buffer,
- p_sys->chans_to_reorder,
- p_sys->chan_table,
- 32);
- }