• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2012 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef ANDROID_AUDIO_LIBSNDFILE_SOURCE_H
18 #define ANDROID_AUDIO_LIBSNDFILE_SOURCE_H
19 
20 #include "NBAIO.h"
21 #include "sndfile.h"
22 
23 // Implementation of NBAIO_Source that wraps a libsndfile opened in SFM_READ mode
24 
25 namespace android {
26 
27 class LibsndfileSource : public NBAIO_Source {
28 
29 public:
30     // If 'loop' is true and it permits seeking, then we'll act as an infinite source
31     LibsndfileSource(SNDFILE *sndfile, const SF_INFO &sfinfo, bool loop = false);
32     virtual ~LibsndfileSource();
33 
34     // NBAIO_Port interface
35 
36     //virtual ssize_t negotiate(const NBAIO_Format offers[], size_t numOffers,
37     //                          NBAIO_Format counterOffers[], size_t& numCounterOffers);
38     //virtual NBAIO_Format format() const;
39 
40     // NBAIO_Source interface
41 
42     //virtual size_t framesRead() const;
43     //virtual size_t framesOverrun();
44     //virtual size_t overruns();
45     virtual ssize_t availableToRead();
46     virtual ssize_t read(void *buffer, size_t count);
47     //virtual ssize_t readVia(readVia_t via, size_t total, void *user, size_t block);
48 
49 private:
50     SNDFILE *   mSndfile;
51     sf_count_t  mEstimatedFramesUntilEOF;
52     bool        mLooping;
53     bool        mReadAnyFramesThisLoopCycle;
54 };
55 
56 }   // namespace android
57 
58 #endif  // ANDROID_AUDIO_LIBSNDFILE_SOURCE_H
59