• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Questions about HAL API.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Questions about HAL API.


  • Subject: Questions about HAL API.
  • From: Tobias Rundström <email@hidden>
  • Date: Tue, 09 Nov 2004 15:33:35 +0100

Hello.

I have written a native CoreAudio outputdriver for XMMS2. The output is working fine but I have some questions.

I hear a quite loud *bang* when I init a song. I thought that is was related to the fact that I am not sure if I fill the buffer fully, I can't see a way for telling CA that my buffer isn't entierly full. Let me show you the code:

--- Callback
static OSStatus
xmms_ca_write_cb (AudioDeviceID inDevice,
                const AudioTimeStamp *inNow,
                const AudioBufferList *inInputData,
                const AudioTimeStamp *inInputTime,
                AudioBufferList *outOutputData,
                const AudioTimeStamp *inOutputTime,
                void *inClientData)
{

      xmms_ca_data_t *data;
      xmms_output_t *output;
      int b;

      output = (xmms_output_t *)inClientData;
      g_return_val_if_fail (output, kAudioHardwareUnspecifiedError);

      data = xmms_output_private_data_get (output);
      g_return_val_if_fail (data, kAudioHardwareUnspecifiedError);

      for (b = 0; b < outOutputData->mNumberBuffers; ++b) {
              gint m;
              gint i;
              gint ret;
              gint16 *buffer;

              m = outOutputData->mBuffers[b].mDataByteSize;

              buffer = g_new0 (gint16, m/2);

              ret = xmms_output_read (output,
                                      (gchar *)buffer,
                                      m/2);

for (i = 0; i < (ret/2) ; i++) {
((gfloat*)outOutputData->mBuffers[0].mData)[i] = ((gfloat) buffer[i] + 32768.0)
/ (32768.0*2);
}


              g_free (buffer);


/** @todo fix so coreaudio knows if we don't fill the buffer ? */

      }

      return kAudioHardwareNoError;

}
----

if xmms_output_read() does not return m/2 it will not be able to fill the buffer, this could probably happen when you start playing or stopping a stream.

As you see there are other questionmarks arising when reading this code.

* Do we know that the buffersize that CA is requesting will stay the same between the requests? In that case I don't have to re-alloc the bufferpointer each time.
* Is there someway to let CA accept 16bit signed int PCM data instead of 32bit float. There are some things about this in the headerfile but it doesn't seem to work when I try to use them.
* Why does this give me a big nice sound*bang* between songs? The only thing I call is


      if (status == XMMS_OUTPUT_STATUS_PLAY) {
              AudioDeviceStart (data->outputdevice, xmms_ca_write_cb);
      } else {
              AudioDeviceStop (data->outputdevice, xmms_ca_write_cb);
      }

between songs.

All input on this is appriciated.

-- Tobias
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Questions about HAL API.
      • From: David Duncan <email@hidden>
  • Prev by Date: Re: Multichannel configs etc.
  • Next by Date: Re: Coreaudio-api Digest, Vol 1, Issue 66
  • Previous by thread: Re: Coreaudio-api Digest, Vol 1, Issue 66
  • Next by thread: Re: Questions about HAL API.
  • Index(es):
    • Date
    • Thread