X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/0bf5064aec5ac43ba2b25d44528bebb27db2f117..21a012a018221fd1e55b8b054d09d7900ed9fd79:/LUFA/Drivers/USB/Class/Host/Audio.h diff --git a/LUFA/Drivers/USB/Class/Host/Audio.h b/LUFA/Drivers/USB/Class/Host/Audio.h index 7e9a48d89..81dcedbcd 100644 --- a/LUFA/Drivers/USB/Class/Host/Audio.h +++ b/LUFA/Drivers/USB/Class/Host/Audio.h @@ -79,8 +79,14 @@ { const struct { - uint8_t DataINPipeNumber; /**< Pipe number of the Audio interface's IN data pipe. */ - uint8_t DataOUTPipeNumber; /**< Pipe number of the Audio interface's OUT data pipe. */ + uint8_t DataINPipeNumber; /**< Pipe number of the Audio interface's IN data pipe. If this interface should not + * bind to an IN endpoint, this may be set to 0 to disable audio input streaming for + * this driver instance. + */ + uint8_t DataOUTPipeNumber; /**< Pipe number of the Audio interface's OUT data pipe. If this interface should not + * bind to an OUT endpoint, this may be set to 0 to disable audio output streaming for + * this driver instance. + */ } Config; /**< Config data for the USB class interface within the device. All elements in this section * must be set or the interface will fail to enumerate and operate correctly. */ @@ -139,7 +145,7 @@ * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum. */ uint8_t Audio_Host_StartStopStreaming(USB_ClassInfo_Audio_Host_t* const AudioInterfaceInfo, - bool EnableStreaming); + const bool EnableStreaming); /** Gets or sets the specified property of a streaming audio class endpoint that is bound to a pipe in the given * class instance. @@ -159,8 +165,8 @@ const uint8_t DataPipeIndex, const uint8_t EndpointProperty, const uint8_t EndpointControl, - uint16_t* const DataLength, - uint8_t* Data); + const uint16_t DataLength, + void* const Data); /* Inline Functions: */ /** General management task for a given Audio host class interface, required for the correct operation of @@ -192,8 +198,14 @@ if ((USB_HostState != HOST_STATE_Configured) || !(AudioInterfaceInfo->State.IsActive)) return false; - Pipe_SelectPipe(AudioInterfaceInfo->Config.DataOUTPipeNumber); - return Pipe_IsINReceived(); + bool SampleReceived = false; + + Pipe_SelectPipe(AudioInterfaceInfo->Config.DataINPipeNumber); + Pipe_Unfreeze(); + SampleReceived = Pipe_IsINReceived(); + Pipe_Freeze(); + + return SampleReceived; } /** Determines if the given audio interface is ready to accept the next sample to be written to it, and selects @@ -213,7 +225,7 @@ if ((USB_HostState != HOST_STATE_Configured) || !(AudioInterfaceInfo->State.IsActive)) return false; - Pipe_SelectPipe(AudioInterfaceInfo->Config.DataINPipeNumber); + Pipe_SelectPipe(AudioInterfaceInfo->Config.DataOUTPipeNumber); return Pipe_IsOUTReady(); } @@ -237,7 +249,11 @@ Sample = Pipe_Read_8(); if (!(Pipe_BytesInPipe())) - Pipe_ClearIN(); + { + Pipe_Unfreeze(); + Pipe_ClearIN(); + Pipe_Freeze(); + } return Sample; } @@ -262,7 +278,11 @@ Sample = (int16_t)Pipe_Read_16_LE(); if (!(Pipe_BytesInPipe())) - Pipe_ClearIN(); + { + Pipe_Unfreeze(); + Pipe_ClearIN(); + Pipe_Freeze(); + } return Sample; } @@ -287,7 +307,11 @@ Sample = (((uint32_t)Pipe_Read_8() << 16) | Pipe_Read_16_LE()); if (!(Pipe_BytesInPipe())) - Pipe_ClearIN(); + { + Pipe_Unfreeze(); + Pipe_ClearIN(); + Pipe_Freeze(); + } return Sample; } @@ -307,8 +331,13 @@ { Pipe_Write_8(Sample); - if (Pipe_BytesInPipe() == AudioInterfaceInfo->State.DataINPipeSize) - Pipe_ClearOUT(); + if (!(Pipe_IsReadWriteAllowed())) + { + Pipe_Unfreeze(); + Pipe_ClearOUT(); + Pipe_WaitUntilReady(); + Pipe_Freeze(); + } } /** Writes the next 16-bit audio sample to the current audio interface. @@ -326,8 +355,13 @@ { Pipe_Write_16_LE(Sample); - if (Pipe_BytesInPipe() == AudioInterfaceInfo->State.DataINPipeSize) - Pipe_ClearOUT(); + if (!(Pipe_IsReadWriteAllowed())) + { + Pipe_Unfreeze(); + Pipe_ClearOUT(); + Pipe_WaitUntilReady(); + Pipe_Freeze(); + } } /** Writes the next 24-bit audio sample to the current audio interface. @@ -346,17 +380,22 @@ Pipe_Write_16_LE(Sample); Pipe_Write_8(Sample >> 16); - if (Pipe_BytesInPipe() == AudioInterfaceInfo->State.DataINPipeSize) - Pipe_ClearOUT(); + if (!(Pipe_IsReadWriteAllowed())) + { + Pipe_Unfreeze(); + Pipe_ClearOUT(); + Pipe_WaitUntilReady(); + Pipe_Freeze(); + } } /* Private Interface - For use in library only: */ #if !defined(__DOXYGEN__) /* Function Prototypes: */ #if defined(__INCLUDE_FROM_AUDIO_HOST_C) - static uint8_t DComp_NextAudioControlInterface(void* CurrentDescriptor); - static uint8_t DComp_NextAudioStreamInterface(void* CurrentDescriptor); - static uint8_t DComp_NextAudioInterfaceDataEndpoint(void* CurrentDescriptor); + static uint8_t DCOMP_Audio_Host_NextAudioControlInterface(void* CurrentDescriptor); + static uint8_t DCOMP_Audio_Host_NextAudioStreamInterface(void* CurrentDescriptor); + static uint8_t DCOMP_Audio_Host_NextAudioInterfaceDataEndpoint(void* CurrentDescriptor); #endif #endif