1 /* 2 * Driver for USB Audio Device Class devices. 3 * Copyright (c) 2009-13 S.Zharski <imker@gmx.li> 4 * Distributed under the terms of the MIT license. 5 * 6 */ 7 #ifndef _USB_AUDIO_STREAM_H_ 8 #define _USB_AUDIO_STREAM_H_ 9 10 11 #include "AudioStreamingInterface.h" 12 13 14 class Device; 15 16 class Stream : public AudioStreamingInterface { 17 friend class Device; 18 public: 19 Stream(Device* device, size_t interface, 20 usb_interface_list* List); 21 ~Stream(); 22 23 status_t Init(); 24 status_t InitCheck() { return fStatus; } 25 26 status_t Start(); 27 status_t Stop(); 28 bool IsRunning() { return fIsRunning; } 29 void OnRemove(); 30 31 status_t GetBuffers(multi_buffer_list* List); 32 33 status_t OnSetConfiguration(usb_device device, 34 const usb_configuration_info* config); 35 36 bool ExchangeBuffer(multi_buffer_info* Info); 37 status_t GetEnabledChannels(uint32& offset, 38 multi_channel_enable* Enable); 39 status_t SetEnabledChannels(uint32& offset, 40 multi_channel_enable* Enable); 41 status_t GetGlobalFormat(multi_format_info* Format); 42 status_t SetGlobalFormat(multi_format_info* Format); 43 44 protected: 45 46 Device* fDevice; 47 status_t fStatus; 48 49 uint8 fTerminalID; 50 usb_pipe fStreamEndpoint; 51 bool fIsRunning; 52 area_id fArea; 53 size_t fAreaSize; 54 usb_iso_packet_descriptor* fDescriptors; 55 size_t fDescriptorsCount; 56 size_t fCurrentBuffer; 57 uint32 fStartingFrame; 58 size_t fSamplesCount; 59 size_t fPacketSize; 60 int32 fProcessedBuffers; 61 int32 fInsideNotify; 62 63 private: 64 status_t _ChooseAlternate(); 65 status_t _SetupBuffers(); 66 status_t _QueueNextTransfer(size_t buffer, bool start); 67 static void _TransferCallback(void* cookie, status_t status, 68 void* data, size_t actualLength); 69 void _DumpDescriptors(); 70 }; 71 72 73 #endif // _USB_AUDIO_STREAM_H_ 74 75