Ejemplo n.º 1
0
PaError PaHost_CloseStream( internalPortAudioStream   *past )
{
    PaHostSoundControl *pahsc;

    if( past == NULL ) return paBadStreamPtr;
    pahsc = (PaHostSoundControl *) past->past_DeviceData;
    if( pahsc == NULL ) return paNoError;

    if( pahsc->pahsc_OutputHandle != BAD_DEVICE_ID )
    {
        int err = 0;
        DBUG(("PaHost_CloseStream: attempt to close output device handle = %d\n",
              pahsc->pahsc_OutputHandle ));

        Pa_FlushStream(pahsc->pahsc_OutputHandle);

        err = close(pahsc->pahsc_OutputHandle);
        if( err < 0 )
        {
            ERR_RPT(("PaHost_CloseStream: warning, closing output device failed.\n"));
        }
    }

    if( (pahsc->pahsc_InputHandle != BAD_DEVICE_ID) &&
            (pahsc->pahsc_InputHandle != pahsc->pahsc_OutputHandle) )
    {
        int err = 0;
        DBUG(("PaHost_CloseStream: attempt to close input device handle = %d\n",
              pahsc->pahsc_InputHandle ));

        Pa_FlushStream(pahsc->pahsc_InputHandle);

        err = close(pahsc->pahsc_InputHandle);
        if( err < 0 )
        {
            ERR_RPT(("PaHost_CloseStream: warning, closing input device failed.\n"));
        }
    }
    pahsc->pahsc_OutputHandle = BAD_DEVICE_ID;
    pahsc->pahsc_InputHandle = BAD_DEVICE_ID;

    if( pahsc->pahsc_NativeInputBuffer )
    {
        free( pahsc->pahsc_NativeInputBuffer );
        pahsc->pahsc_NativeInputBuffer = NULL;
    }
    if( pahsc->pahsc_NativeOutputBuffer )
    {
        free( pahsc->pahsc_NativeOutputBuffer );
        pahsc->pahsc_NativeOutputBuffer = NULL;
    }

    free( pahsc );
    past->past_DeviceData = NULL;
    return paNoError;
}
Ejemplo n.º 2
0
PaError Pa_SetupOutputDeviceFormat( int devHandle, int numChannels, int sampleRate )
{
    audio_info_t solaris_info;
    AUDIO_INITINFO(&solaris_info);

    /* Sam Bayer/Bryan George 1/10/02: Various folks have
       reported that on Solaris Ultra II, the not-right thing
       happens on read unless you make sure the audio device is
       flushed. The folks who wrote the Robust Audio Tool say:
       + XXX driver issue - on Ultra II's if you don't drain
       * the device before reading commences then the device
       * reads in blocks of 500ms irrespective of the
       * blocksize set. After a minute or so it flips into the
       * correct mode, but obviously this is too late to be + * useful for most apps. grrr.
       */
    /* AS: And the Solaris man audio pages say you should flush before changing formats
       anyway.  So there you go. */
    if (Pa_FlushStream(devHandle) != paNoError)
      return paHostError;

    solaris_info.play.encoding = AUDIO_ENCODING_LINEAR;
    solaris_info.play.sample_rate = sampleRate;
    solaris_info.play.precision = 16;
    solaris_info.play.channels = numChannels;

    if (ioctl(devHandle, AUDIO_SETINFO, &solaris_info) == -1)
      {
        ERR_RPT(("Pa_SetupDeviceFormat: could not set audio info\n" ));
        return paHostError;
      }

    return paNoError;
}