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 Device* fDevice; 46 status_t fStatus; 47 48 uint8 fTerminalID; 49 usb_pipe fStreamEndpoint; 50 51 bool fIsRunning; 52 area_id fArea, fKernelArea; 53 size_t fAreaSize; 54 usb_iso_packet_descriptor* fDescriptors; 55 size_t fDescriptorsCount; 56 uint8* fBuffers; 57 uint8* fKernelBuffers; 58 size_t fCurrentBuffer; 59 size_t fSamplesCount; 60 61 bigtime_t fRealTime; 62 uint32 fStartingFrame; 63 int32 fProcessedBuffers; 64 int32 fInsideNotify; 65 66 private: 67 status_t _ChooseAlternate(); 68 status_t _SetupBuffers(); 69 status_t _QueueNextTransfer(size_t buffer, bool start); 70 static void _TransferCallback(void* cookie, status_t status, 71 void* data, size_t actualLength); 72 void _DumpDescriptors(); 73 }; 74 75 76 #endif // _USB_AUDIO_STREAM_H_ 77 78